I'm having items spawn in the world, but each will have a unique variable value assigned to them. To prevent players from hunting and pecking, I want to make it so that variable is only assigned once the player picks up the item. Is that possible?
/**
* Adds the item stack to the inventory, returns false if it is impossible.
*/
public boolean addItemStackToInventory(ItemStack par1ItemStack)
{
if (entityplayer.inventory.hasItem(Item.appleGold.shiftedIndex))
{
return false;
}
//REST OF CODE...
Not here to help, but is there a way to find if the player has an item in his/her hand? Or has armor on? I am trying to make my tools/armor admit light when the player is holding/wearing the item(s). If there is a way it would be of great help.
yes, you have to add the method to detect if the player has the item you are looking for in their inventory and then edit the pre-made variable type to be what you want, i.e. assign in the item block whatever,
public static int test;
and inside the if else statement add
itemnamehere.test = 1;
this should work if not ill try and resolve as much as i can
If needed you might make a class that extends EntityItem that uses
before
in the method
But that might require modifying quite a few other classes... :/
EDIT: How about adding
in InventoryPlayer.addItemStackToInventory(ItemStack par1ItemStack);
Not quite understanding how to utilize that last part.
entityplayer cannot be resolved?
I'm placing this in the specific item class.
EDIT: Tried this. I think I'm doing it wrong.
EDIT: Woo! 200th post!