Topic category: Advanced modding
Basically, what I want to do is have a block where you simply right-click on the block, and the block gives you the item that you already have in your right hand (for example, if you held a diamond and you right-clicked the Cloning Block, the Block would drop a diamond, so now you would have two diamonds in your hand). However, I don't know what to write in the code section, as it is not a default option.
Here is the code:
if (entity.inventory.getCurrentItem() != null && entity.inventory.getCurrentItem().getItem() == whatdoIwritehere) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(whatdoIwritehere, 1));
I've tried using itemInPlayersHand[] but it doesn't work. Please help.
Just remove the 2nd check and as a parameter in addItemStackToInventory use the ItemStack from getCurrentItem() (and it would be a good idea to call ItemStack#copy()), so you will end up with something like this:
Thanks very much! It's working great.