Posted September 12, 201411 yr Hi guys I am slightly new to modding in minecraft and may I overlook an important step. But I try to prevent an EntityItem from despawn after the usual five minutes while being collided with a special block (a conveyor belt). The first attempt did not work, I thought somehting like the following would work: @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity){ if(entity instanceof EntityItem){ //some code to move the item ((EntityItem)entity).ticksExisted = 0; } } So ticksExisted is not used to calculate when it despawns?! The second, more promising, attempt was to use the lovely Forge Events: I wrote a little EventHandler: @Subscribe public void handleItemExpire(ItemExpireEvent event){ World world = event.entityItem.worldObj; double xPos = event.entityItem.lastTickPosX; double yPos = event.entityItem.lastTickPosY; double zPos = event.entityItem.lastTickPosZ; System.out.println("Item despawn event happend"); if(world.getBlock((int)xPos, (int)yPos, (int)zPos) != null && world.getBlock((int)xPos, (int)yPos, (int)zPos) instanceof ConveyorBelt){ event.extraLife = 20 * 60 * 5;//adding another 5min System.out.println("prevented item despawn on conveyor belt"); } } And registered this event handling class in my main mod file, in the init method: @EventHandler public void init(FMLInitializationEvent initEvent) { //Event handerls: MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); } But as well as the first attempt, the second didn't work and I am a little confused. Maybe some of you could help me? Thanks in advance! Sincerely -pick Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
September 12, 201411 yr Author Thank you! That really solved the issue. Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
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.