Posted February 16, 201510 yr I've made an item which you can drink. However in 1.7.10 (This was fixed in 1. If you eat/drink an item and stop holding right click on the last tick (It seems to be the last tick), then don't change the item you're holding, it continues to consume the item. So for example attempting to eat an enchanted golden apple, you can eat one of them, stop eating at a very specific time, two of the apples will be consumed. This happens with the item I made that you drink and I'd like to find a way around that so it only consumes one. [spoiler=Code] public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player) { player.addPotionEffect(PotionHelper.createCure(0)); for (CustomCureEffect customEffect : ZombieInfectionAPI.getCustomCureEffects()) { customEffect.run(player, stack); } stack.stackSize = player.capabilities.isCreativeMode ? stack.stackSize : stack.stackSize - 1; if (stack.stackSize == 0) { stack = new ItemStack(Items.glass_bottle); } else { boolean increased = false; for (int i = 0; i < player.inventory.getSizeInventory(); i ++) { if (player.inventory.getStackInSlot(i) != null) { if (player.inventory.getStackInSlot(i).getUnlocalizedName().equalsIgnoreCase("item.glassBottle")) { if (player.inventory.getStackInSlot(i).stackSize < 64) { player.inventory.getStackInSlot(i).stackSize ++; increased = true; break; } } } } if (!increased) { int emptySlotPos = player.inventory.getFirstEmptyStack(); if (emptySlotPos > -1) { player.inventory.setInventorySlotContents(emptySlotPos, new ItemStack(Items.glass_bottle)); } else { player.dropPlayerItemWithRandomChoice(new ItemStack(Items.glass_bottle), false); } } } player.setItemInUse(null, 0); return stack; } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { player.setItemInUse(stack, getMaxItemUseDuration(stack)); return stack; } public int getMaxItemUseDuration(ItemStack stack) { return 32; } public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.drink; } As you can see I tried sticking "player.setItemInUse(null, 0);" in the onItemUseFinish method, however that didn't seem to solve it. If anyone knows how to fix it, it would really help. Thanks
February 16, 201510 yr Author I'm doing this mod as a collab with someone else, who has a modpack with about 40 mods, most of which aren't updated. He want's to keep it on 1.7.10 for the purpose of having it in his modpack, I don't mind. We do have a 1.8 version of the mod. If the bug is fixable then it would be nice to fix in the 1.7.10 version, if not then it'll have to just be a bug permanently in 1.7.10 I guess
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.