3
\$\begingroup\$

My question is about programming Minecraft mods. So i added a block to my Mod. Now I want, that when you drop a sugar on it, that it waits some time and then, if the sugar is still there, it will consume the sugar and spawn an item that i made for my mod. But I don't know how to test wether the item is sugar. I use the event onLanded with an

@Override
public void onLanded(World worldIn, Entity entityIn)
{
    if(entityIn instanceof EntityItem && !worldIn.isRemote)
    {

    }
}                                                                                             }

but I don't know where to specify the item and where to get the position of the block.

I hope anyone can help me and sorry for my bad english I'm not a native speaker. Thank you in advance Nova

\$\endgroup\$
0
\$\begingroup\$

I have not tried it but to be more precise you could write:

//specialBlock is the 
//block on which the sugar is supposed to react on
if(specialBlock.getLocation().getBlock().getRelative(BlockFace.UP) != null && 
   entityIn instance of Item.sugar) {

}

I called your block here specialBlock. Now you check if there is something on your block and if it is sugar..

\$\endgroup\$
  • \$\begingroup\$ The problem is: how do I know the position of the entity? \$\endgroup\$ – Nova Shadowflame Dec 3 '15 at 16:20
  • \$\begingroup\$ Do you want the x position? entity.posX would be attribute \$\endgroup\$ – ByteBiter Dec 14 '15 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.