Alright, so I'm trying to make a mod where blood is basically the essence of life, and the most important item is not working correctly.
What I'm trying to do is make it so that onItemRightClick the Item removes itself, hurts the player and gives itself an other Item.
My Item Class:
package p0rtal.items;
import p0rtal.main.Strings;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class needle extends Item {
{
this.setUnlocalizedName("needle");
this.setTextureName(Strings.modid + ":" + "needle");
this.setMaxStackSize(1);
setContainerItem(smItems.needle_use);
}
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
if(stack != null){
--stack.stackSize;
getContainerItem();
player.attackTargetEntityWithCurrentItem(player);
}
return stack;
}
}
I've tried adding the setContainerItem() inside the if Statement (where the --stack.stackSize; and stuff is)and right before the return line, same thing with getContainerItem(). Each time I use the item though, it only damages me and gets rid of the item. Is there a way to do this?
Thanks in advance,
P0rtal.