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 have a removeItem() method that if it is called it will remove as much from the item you're holding as the stacks of that item you have in your inventory

Here's my code:

public void removeItem(EntityPlayer playerIn, ItemStack removeitem) {
	IInventory inv = playerIn.inventory;
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		if (inv.getStackInSlot(i) != null) {
			ItemStack j = inv.getStackInSlot(i);
			if (j.getItem() != null && j.getItem() == removeitem.getItem()) {
				inv.decrStackSize(playerIn.inventory.currentItem, 1);
			}
		}
	}
}

I think I remember your piece of code and it was something like:

for (index : all)
{
    player.inventory.decrStackSize(index, 1);
}

 

Learn what loop is, you are not supposed to loop through inventory. (because then indeed you will remove 1 from each stack).

 

Just call: (current item is item held)

player.inventory.decrStackSize(player.inventory.currentItem, 1);

1.7.10 is no longer supported by forge, you are on your own.

Guest
This topic is now closed to further replies.

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.