Jump to content

P0rtal

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by P0rtal

  1. Just abandon replying. I some how managed to fix it (must of been when I changed the name of the needle_used item while adding a new item) thanks for helping!
  2. Alright so I changed it from the container to a new itemstack: 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); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ if(stack != null){ --stack.stackSize; player.attackTargetEntityWithCurrentItem(player); player.inventory.addItemStackToInventory(new ItemStack(smItems.needle_use)); } return stack; } } It spawns in the item now, yes, but it deletes it also at the same time. They don't share the same ID too...
  3. 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.
  4. Put this code near the bottom of your item class: @Override public ItemStack getContainerItem(ItemStack stack) { if (stack.attemptDamageItem(1, itemRand)) { return null; } return stack; } And if you want it to stay in your crafting grid add this under the last one: @Override public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { return false; } and in your crafting manager, use it like this for simplicity: GameRegistry.addShapelessRecipe(new ItemStack(IronRod.iRod, 4), new ItemStack(IronFile.iFile, 1, OreDictionary.WILDCARD_VALUE), (IronPlate.iPlate)); Hope this helps.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.