Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've made an item which you can drink. However in 1.7.10 (This was fixed in 1.8) 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

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.