Started by
SingularityV3
on
Topic category: Advanced modding
I am making a block that when you right click on it with certain objects in your hand it adds other items to your inventory. The problem is that Lapis has metadata, and I am not sure how to check for metadata that is not in the ItemStack() method. My current code checks for ANY dye, then gives you a piece of Lapis:
if (entity.inventory.getCurrentItem() != null && entity.inventory.getCurrentItem().getItem() == Items.DYE) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(Items.DYE, 1, 4));
Try On block rightclicked
do what ever you want to do there and change (in All Cases) to itemInPlayersHand[] == item
that should do
I have it so that On Block Right Clicked it checks for the rest of the items, and I am manually adding in Lapis because MCreator does not support any dye other than the generic "Dye" in the context of events; therefor if I did that it would check for any dye in the player's hand then give you an Ink Sack.
Sorry I spelled "Therefore" wrong.
Try this:
if (entity.inventory.getCurrentItem() != null && entity.inventory.getCurrentItem().getItem() == Items.LAPIS) { if (entity instanceof EntityPlayer) ((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(Items.LAPIS, 1, 4));
Already tried that. Lapis is a metadata of the more general class "DYE", and has no ID of it's own. The only reason the "new ItemStack(Items.DYE, 1, 4)" code works is because ItemStack() takes metadata as a parameter (The 4), so it gives you a dye with metadata of 4, which happens to be Lapis. The reason this code does not work in the context of "entity.inventory.getCurrentItem().getItem() == Items.LAPIS", is that it is an If statement and, therefore, does not allow for the inclusion of parameters in general.