Jump to content

[1.8] How to create a portal when item is in lava


DaryBob

Recommended Posts

Hey guys! I am trying to make a portal. There are 3 custom blocks on each side and in the middle, one block down, there is the a 9x9 hole filled with lava (Kinda like the end-portal in the stronghold). And I can't figure out how to turn the lava blocks to a portal block if the player throws (Q-Button) a netherstar in the lava.

 

I thought maybe I can check the entityitem's position to locate if there is lava or not.. But I never did stuff with EntityItem's or something

so maybe someone can help me? thanks for your support!

Link to comment
Share on other sites

I can't think of a graceful way to do this if you are throwing a vanilla item.  It can be done, but it is a bit ugly.

 

Now, if you create a custom item you are throwing in, then you can have a custom entityitem for that item.  In that custom entityitem you can search for the conditions.  Also you can keep the entity item from going poof on contact with the lava.

 

 

Wait, on second though, look around for entity death event, check if it is an entityitem, then if it is a netherstar, then look for your conditions.  That will probably work and is fairly easy.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Wait, on second though, look around for entity death event, check if it is an entityitem, then if it is a netherstar, then look for your conditions.  That will probably work and is fairly easy.

 

There's no such event.

LivingDeathEvent

is only for living entities (i.e. entities that extend

EntityLivingBase

).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

So should I make a boolean method to check if the custom blocks are there? And in the method where it will check the contact with lava I will first write an if-Statement and check if the boolean method returns true. If it returns true, I will replace the lava with the portal block..

Link to comment
Share on other sites

He is doing it the very involved way I thought of. 

 

Do what I suggested, it will be easier on you.

 

When you see your custom entityitem die (onDeath or something like that), do your search and if it is satisfied, build your portal.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Hey guys! I made a custom entity item! So, if you drop a nether star, its entity item will actually convert to my custom entity item.

I wrote "this.isImmuneToFire = true;" in my custom entity item class. It is immune to fire, but if I check if its in lava, it doesn't call everything..

I used the boolean "isInLava"... So do you have any thoughts of why it doesn't equal to true?

 

Heres my event handler and EntityItem class:

 

Event Handler:

 

 

package netcrafter.mods.event;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.init.Items;

import net.minecraft.item.ItemStack;

import net.minecraft.network.play.server.S42PacketCombatEvent.Event;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraft.world.storage.WorldInfo;

import net.minecraftforge.event.entity.EntityJoinWorldEvent;

import net.minecraftforge.event.entity.living.LivingDropsEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import netcrafter.mods.aoto.entity.item.AOTOEntityItem;

import netcrafter.mods.aoto.init.AOTOItems;

import netcrafter.mods.event.item.EntityItemDeathEvent;

import netcrafter.mods.util.Helper;

import akka.actor.ActorSystem.Settings;

 

public class AOTOEventHandler {

 

/*Test code

    @SubscribeEvent

    public void onEntityDrop(LivingDropsEvent event) {

    if(event.entityLiving instanceof EntityZombie) {

    event.entityLiving.dropItem(Items.diamond, 1);

    }

    }

    *///End of test code

   

    @SubscribeEvent

    public void onEntityJoinWorld(EntityJoinWorldEvent event) {

        if( !event.world.isRemote && event.entity instanceof EntityItem && !(event.entity instanceof AOTOEntityItem) ) {

            EntityItem eItem = (EntityItem) event.entity;

            ItemStack stack = eItem.getEntityItem();

            if(eItem.getEntityItem().getItem().getUnlocalizedName().equals(Items.nether_star.getUnlocalizedName())) {

            System.out.println("Its the nether star! Trying to remove it and replace it with another entity item!");

                AOTOEntityItem aEntityItem = new AOTOEntityItem(event.world, eItem, eItem.getEntityItem());

                event.world.spawnEntityInWorld(aEntityItem);

            eItem.setDead();

           

            //Checking if E is dead and A is here.

            if(eItem.isDead && aEntityItem.isEntityAlive()) { System.out.println("E is dead and A is alive"); }

           

                int dx = MathHelper.floor_double(aEntityItem.motionX);

                int dy = MathHelper.floor_double(aEntityItem.motionY);

                int dz = MathHelper.floor_double(aEntityItem.motionZ);

               

            if(aEntityItem.isInLava()) {

            System.out.println("Item is in Lava and died");

                    WorldInfo wInfo = event.world.getWorldInfo();

                event.world.addWeatherEffect(new EntityLightningBolt(event.world, dx, dy, dz));

                    wInfo.setRainTime(1000);

                    wInfo.setThunderTime(1000);

                    wInfo.setRaining(true);

                    wInfo.setThundering(true);

                    aEntityItem.setDead();

                    event.setCanceled(true);

           

            }

            }

        }

    }

}

 

 

 

Entity Item

 

 

import java.lang.reflect.Field;

import java.util.Hashtable;

 

import net.minecraft.block.material.Material;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.item.ItemStack;

import net.minecraft.util.BlockPos;

import net.minecraft.util.DamageSource;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraftforge.common.MinecraftForge;

import netcrafter.mods.event.item.EntityItemDeathEvent;

import netcrafter.mods.event.item.EntityItemHurtEvent;

 

public class AOTOEntityItem extends EntityItem {

 

    private DamageSource previousDamageSource;

 

    public AOTOEntityItem(World world) {

        super(world);

    }

 

    public AOTOEntityItem(World world, EntityItem oldEntity, ItemStack stack) {

        super(world, oldEntity.posX, oldEntity.posY, oldEntity.posZ, stack);

        this.motionX = oldEntity.motionX;

        this.motionY = oldEntity.motionY;

        this.motionZ = oldEntity.motionZ;

        //this.age = oldEntity.age; <-- age is now private in 1.8

        this.setPickupDelay(10);

        this.hoverStart = oldEntity.hoverStart;

        this.lifespan = oldEntity.lifespan;

        this.isImmuneToFire = true;

    }

 

}

 

 

 

Thanks to delpi for giving me the suggestion to create the custom entity item class.

Link to comment
Share on other sites

I tried this:

 

event.world.isAABBInMaterial(aEntityItem.getBoundingBox(), Material.lava)

 

to check if it is in lava..

 

                if (event.world.isAABBInMaterial(aEntityItem.getBoundingBox(), Material.lava)) {

               

                    int dx = MathHelper.floor_double(aEntityItem.motionX);

                    int dy = MathHelper.floor_double(aEntityItem.motionY);

                    int dz = MathHelper.floor_double(aEntityItem.motionZ);

                    if (((BlockRVPortal)AOTOBlocks.rvPortal).tryToCreatePortal(event.world, dx, dy, dz)) {

                    WorldInfo wInfo = event.world.getWorldInfo();

                    event.world.addWeatherEffect(new EntityLightningBolt(event.world, dx, dy, dz));

                        wInfo.setRainTime(1000);

                        wInfo.setThunderTime(1000);

                        wInfo.setRaining(true);

                        wInfo.setThundering(true);

                        aEntityItem.setDead();

                        event.setCanceled(true);

                    }

                }

 

Still doesn't work.. But if gives me an error if I throw the nether star..

(But it doesn't crash)

 

[18:55:59] [server thread/ERROR] [FML]: Index: 3 Listeners:

[18:55:59] [server thread/ERROR] [FML]: 0: HIGHEST

[18:55:59] [server thread/ERROR] [FML]: 1: ASM: net.minecraftforge.common.ForgeInternalHandler@7fb27a08 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V

[18:55:59] [server thread/ERROR] [FML]: 2: NORMAL

[18:55:59] [server thread/ERROR] [FML]: 3: ASM: netcrafter.mods.aoto.event.AOTOEventHandler@4bfb3772 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V

[18:55:59] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException

java.util.concurrent.ExecutionException: java.lang.NullPointerException

at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_79]

at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_79]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]

at java.lang.Thread.run(Unknown Source) [?:1.7.0_79]

Caused by: java.lang.NullPointerException

at net.minecraft.world.World.isAABBInMaterial(World.java:2318) ~[World.class:?]

at netcrafter.mods.aoto.event.AOTOEventHandler.onEntityJoinWorld(AOTOEventHandler.java:54) ~[AOTOEventHandler.class:?]

at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_AOTOEventHandler_onEntityJoinWorld_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?]

at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]

at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?]

at net.minecraft.world.World.spawnEntityInWorld(World.java:1230) ~[World.class:?]

at net.minecraft.entity.player.EntityPlayer.joinEntityItemWithWorld(EntityPlayer.java:934) ~[EntityPlayer.class:?]

at net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(ForgeHooks.java:421) ~[ForgeHooks.class:?]

at net.minecraft.entity.player.EntityPlayer.dropOneItem(EntityPlayer.java:854) ~[EntityPlayer.class:?]

at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:513) ~[NetHandlerPlayServer.class:?]

at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:53) ~[C07PacketPlayerDigging.class:?]

at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:76) ~[C07PacketPlayerDigging.class:?]

at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_79]

at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_79]

at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]

... 5 more

 

Your right.. I changed it:

if(stack.getItem() == Items.nether_star)

Link to comment
Share on other sites

Well, I was dumb and put the bounding box in..

But I needed the entity bounding box..

 

Still doesn't work if I throw the item in the lava..

 

is AABB (entity bounding box) In Material (Material.lava)?

The entity of the boats in minecraft does this too with water (Material.water)

 

 

if (event.world.isAABBInMaterial(aEntityItem.getEntityBoundingBox(), Material.lava)) {       

                    int dx = MathHelper.floor_double(aEntityItem.motionX);

                    int dy = MathHelper.floor_double(aEntityItem.motionY);

                    int dz = MathHelper.floor_double(aEntityItem.motionZ);

                    if (((BlockRVPortal)AOTOBlocks.rvPortal).tryToCreatePortal(event.world, dx, dy, dz)) {

                    WorldInfo wInfo = event.world.getWorldInfo();

                    event.world.addWeatherEffect(new EntityLightningBolt(event.world, dx, dy, dz));

                        wInfo.setRainTime(1000);

                        wInfo.setThunderTime(1000);

                        wInfo.setRaining(true);

                        wInfo.setThundering(true);

                        aEntityItem.setDead();

                        event.setCanceled(true);

                    }

[spoiler/]

Link to comment
Share on other sites

I don't think this should be in your event handler, since the item usually won't be in lava at the moment it's dropped.

Entity#setOnFireFromLava

will be called when the item is in lava, you should be able to override this to check for the portal activation criteria.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Is it neccesary to check if the item is in lava?

Because the method is basically being called

if it catches fire of lava..

 

It shouldn't be necessary to check if it's in lava, the method should only be called if it's already known that it is in lava.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Hey guy's, i've found a new problem..

If I throw the nether star into the lava,

it creates the portal, but sometimes

it doesn't check if it is in lava..

So it only creates a portal every

10 times or something..

Any thoughts on why this

is so?

 

Custom Entity Item

 

 

package netcrafter.mods.aoto.entity.item;

 

import java.lang.reflect.Field;

import java.util.Hashtable;

 

import net.minecraft.block.material.Material;

import net.minecraft.entity.Entity;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.item.ItemStack;

import net.minecraft.util.BlockPos;

import net.minecraft.util.DamageSource;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraft.world.storage.WorldInfo;

import net.minecraftforge.common.MinecraftForge;

import netcrafter.mods.aoto.blocks.BlockRVPortal;

import netcrafter.mods.aoto.event.item.EntityItemDeathEvent;

import netcrafter.mods.aoto.event.item.EntityItemHurtEvent;

import netcrafter.mods.aoto.init.AOTOBlocks;

 

public class RVSummonerEntityItem extends EntityItem {

 

    private DamageSource previousDamageSource;

 

    public RVSummonerEntityItem(World world) {

        super(world);

    }

 

    public RVSummonerEntityItem(World world, EntityItem oldEntity, ItemStack stack) {

        super(world, oldEntity.posX, oldEntity.posY, oldEntity.posZ, stack);

        this.motionX = oldEntity.motionX;

        this.motionY = oldEntity.motionY;

        this.motionZ = oldEntity.motionZ;

        //this.age = oldEntity.getAge();

        this.setPickupDelay(60);

        this.hoverStart = oldEntity.hoverStart;

        this.lifespan = oldEntity.lifespan;

        //this.isImmuneToFire = true;

    }

 

    @Override

    public boolean attackEntityFrom(DamageSource dmgSource, float attackPts) {

        return !dmgSource.isFireDamage() && super.attackEntityFrom(dmgSource, attackPts);

    }

   

    @Override

    public void setOnFireFromLava() {

   

        //if (worldObj.isAABBInMaterial(this.getEntityBoundingBox(), Material.lava)) {       

   

        //Get the position of the entity item

            int dx = MathHelper.floor_double(this.getPosition().getX());

            int dy = MathHelper.floor_double(this.getPosition().getY());

            int dz = MathHelper.floor_double(this.getPosition().getZ());

           

            //try to create portal

            if(((BlockRVPortal)AOTOBlocks.rvPortal).tryToCreatePortal(worldObj, dx, dy, dz)) {

            WorldInfo wInfo = worldObj.getWorldInfo();

            worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, dx, dy, dz));

            worldObj.setWorldTime(18000);

                wInfo.setRainTime(18000);

                wInfo.setThunderTime(18000);

                wInfo.setRaining(true);

                wInfo.setThundering(true);

                worldObj.setRainStrength(2);

                worldObj.setThunderStrength(2);

                this.setDead();

            }             

        //}   

    }

}

 

 

 

Portal Block:

 

 

package netcrafter.mods.aoto.blocks;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.block.state.IBlockState;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.init.Blocks;

import net.minecraft.util.BlockPos;

import net.minecraft.world.World;

import netcrafter.mods.aoto.init.AOTOBlocks;

 

public class BlockRVPortal extends Block {

 

public BlockRVPortal(Material materialIn) {

super(materialIn);

}

 

public boolean tryToCreatePortal(World world, int dx, int dy, int dz) {

 

    if (isGoodPortalPool(world, dx, dy, dz)) {

      world.addWeatherEffect(new EntityLightningBolt(world, dx, dy, dz));

      System.out.println("Yeah!");

     

      transmuteWaterToPortal(world, dx, dy, dz);

     

      return true;

    }

    return false;

 

  }

 

  public void transmuteWaterToPortal(World world, int dx, int dy, int dz){

    int px = dx;

    int pz = dz;

   

    if (world.getBlockState(new BlockPos(px - 1, dy, pz)).getBlock().getMaterial() == Material.lava) {

      px--;

    }

    if (world.getBlockState(new BlockPos(px, dy, pz - 1)).getBlock().getMaterial() == Material.lava) {

      pz--;

    }

   

    world.setBlockState(new BlockPos(px + 0, dy, pz + 0), AOTOBlocks.rvPortal.getDefaultState());

    world.setBlockState(new BlockPos(px + 1, dy, pz + 0), AOTOBlocks.rvPortal.getDefaultState());

    world.setBlockState(new BlockPos(px + 1, dy, pz + 1), AOTOBlocks.rvPortal.getDefaultState());

    world.setBlockState(new BlockPos(px + 0, dy, pz + 1), AOTOBlocks.rvPortal.getDefaultState());

  }

 

  public boolean isGoodPortalPool(World world, int dx, int dy, int dz) {

    boolean flag = false;

   

    flag |= isGoodPortalPoolStrict(world, dx + 0, dy, dz + 0);

   

    flag |= isGoodPortalPoolStrict(world, dx - 1, dy, dz - 1);

    flag |= isGoodPortalPoolStrict(world, dx + 0, dy, dz - 1);

    flag |= isGoodPortalPoolStrict(world, dx + 1, dy, dz - 1);

   

    flag |= isGoodPortalPoolStrict(world, dx - 1, dy, dz + 0);

    flag |= isGoodPortalPoolStrict(world, dx + 1, dy, dz + 0);

   

    flag |= isGoodPortalPoolStrict(world, dx - 1, dy, dz + 1);

    flag |= isGoodPortalPoolStrict(world, dx + 0, dy, dz + 1);

    flag |= isGoodPortalPoolStrict(world, dx + 1, dy, dz + 1);

   

    return flag;

  }

 

  public boolean isGoodPortalPoolStrict(World world, int dx, int dy, int dz) {

    boolean flag = true;

 

    flag &= world.getBlockState(new BlockPos(dx + 0, dy, dz + 0)).getBlock().getMaterial() == Material.lava;

    flag &= world.getBlockState(new BlockPos(dx + 1, dy, dz + 0)).getBlock().getMaterial() == Material.lava;

    flag &= world.getBlockState(new BlockPos(dx + 1, dy, dz + 1)).getBlock().getMaterial() == Material.lava;

    flag &= world.getBlockState(new BlockPos(dx + 0, dy, dz + 1)).getBlock().getMaterial() == Material.lava;

   

    flag &= isGrassOrDirt(world, dx - 1, dy, dz - 1);

    flag &= isGrassOrDirt(world, dx - 1, dy, dz + 0);

    flag &= isGrassOrDirt(world, dx - 1, dy, dz + 1);

    flag &= isGrassOrDirt(world, dx - 1, dy, dz + 2);

   

    flag &= isGrassOrDirt(world, dx + 0, dy, dz - 1);

    flag &= isGrassOrDirt(world, dx + 1, dy, dz - 1);

   

    flag &= isGrassOrDirt(world, dx + 0, dy, dz + 2);

    flag &= isGrassOrDirt(world, dx + 1, dy, dz + 2);

   

    flag &= isGrassOrDirt(world, dx + 2, dy, dz - 1);

    flag &= isGrassOrDirt(world, dx + 2, dy, dz + 0);

    flag &= isGrassOrDirt(world, dx + 2, dy, dz + 1);

    flag &= isGrassOrDirt(world, dx + 2, dy, dz + 2);

   

    flag &= world.getBlockState(new BlockPos(dx + 0, dy - 1, dz + 0)).getBlock().getMaterial().isSolid();

    flag &= world.getBlockState(new BlockPos(dx + 1, dy - 1, dz + 0)).getBlock().getMaterial().isSolid();

    flag &= world.getBlockState(new BlockPos(dx + 1, dy - 1, dz + 1)).getBlock().getMaterial().isSolid();

    flag &= world.getBlockState(new BlockPos(dx + 0, dy - 1, dz + 1)).getBlock().getMaterial().isSolid();

   

    flag &= isNatureBlock(world, dx - 1, dy + 1, dz - 1);

    flag &= isNatureBlock(world, dx - 1, dy + 1, dz + 0);

    flag &= isNatureBlock(world, dx - 1, dy + 1, dz + 1);

    flag &= isNatureBlock(world, dx - 1, dy + 1, dz + 2);

   

    flag &= isNatureBlock(world, dx + 0, dy + 1, dz - 1);

    flag &= isNatureBlock(world, dx + 1, dy + 1, dz - 1);

   

    flag &= isNatureBlock(world, dx + 0, dy + 1, dz + 2);

    flag &= isNatureBlock(world, dx + 1, dy + 1, dz + 2);

   

    flag &= isNatureBlock(world, dx + 2, dy + 1, dz - 1);

    flag &= isNatureBlock(world, dx + 2, dy + 1, dz + 0);

    flag &= isNatureBlock(world, dx + 2, dy + 1, dz + 1);

    flag &= isNatureBlock(world, dx + 2, dy + 1, dz + 2);

   

    return flag;

  }

 

  public boolean isNatureBlock(World world, int dx, int dy, int dz) {

    Block block = world.getBlockState(new BlockPos(dx, dy, dz)).getBlock();

    if (block == AOTOBlocks.red_void_blocks)  {

 

      return true;

    }

    return false;

  }

 

  public void func_149695_a(World world, int x, int y, int z, Block notUsed)

  {

    boolean good = true;

    if (world.getBlockState(new BlockPos(x - 1, y, z)) == this) {

      good &= isGrassOrDirt(world, x + 1, y, z);

    } else if (world.getBlockState(new BlockPos(x + 1, y, z)) == this) {

      good &= isGrassOrDirt(world, x - 1, y, z);

    } else {

      good = false;

    }

    if (world.getBlockState(new BlockPos(x, y, z - 1)) == this) {

      good &= isGrassOrDirt(world, x, y, z + 1);

    } else if (world.getBlockState(new BlockPos(x, y, z + 1)) == this) {

      good &= isGrassOrDirt(world, x, y, z - 1);

    } else {

      good = false;

    }

    if (!good) {

      world.setBlockState(new BlockPos(x, y, z), Blocks.lava.getDefaultState());

    }

  }

 

  protected boolean isGrassOrDirt(World world, int dx, int dy, int dz) {

    return (world.getBlockState(new BlockPos(dx, dy, dz)).getBlock() == Blocks.obsidian);

  }

 

}

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.