Posted September 17, 20178 yr Hey, so I have this item, and I want to make it heal the player 1/2 a heart when picked up. However, when the item stacks to a number higher than one, it still heals only half a heart instead of multiple hearts depending on the amount of items in the stack. If you know what I mean... My question is: how do I get the amount of items in a single stack? My code: @SubscribeEvent(priority = EventPriority.HIGHEST) //Tuskerer's Healing event public void itemPickup(ItemPickupEvent e) { EntityPlayer p = e.player; if (e.pickedUp.getEntityItem().getItem() == DinocraftItems.TUSKERERS_HEART) { p.heal(1); //here I need to somehow get the amount of items per stack p.inventory.clearMatchingItems(DinocraftItems.TUSKERERS_HEART, 0, 37 * 64, null); } } Please leave suggestions below. Thanks!
September 17, 20178 yr getItem().stacksize will give you the amount of items 13 minutes ago, Differentiation said: if (e.pickedUp.getEntityItem().getItem() == DinocraftItems.TUSKERERS_HEART) { you are comparing itemstack to a item
September 17, 20178 yr Author I tried this, but it didn't work @SubscribeEvent (priority = EventPriority.HIGHEST) //Tuskerer's Healing event public void itemPickup(ItemPickupEvent e) { EntityPlayer p = e.player; if (e.pickedUp.getEntityItem().getItem().equals(DinocraftItems.TUSKERERS_HEART)) { p.heal(e.pickedUp.getEntityItem().stackSize); p.inventory.clearMatchingItems(DinocraftItems.TUSKERERS_HEART, 0, 37 * 64, null); } } Am I doing something wrong? Please help. Thanks!
September 17, 20178 yr https://github.com/MinecraftForge/MinecraftForge/issues/3419#issuecomment-308583108 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.