Posted September 9, 20196 yr When the player right-clicks my custom block, I want the a single item from the stack to be removed from the players inventory, i.e. if the player has 50 of an item it goes down to 49. I can easily add items to the players inventory use player.addItemStackToInventory but can't seem to find something similar for removing an item. I thought player.entityDropItem might work but that doesn't seem to work; my block also knows what item was used on right-click. Any help is appreciated. Edited September 15, 20196 yr by Blu_Nighttime topic solved
September 10, 20196 yr Author OK, I have this implemented now; thanks for the redirection from the old API. However, how do I get the slot number that the ItemStack is at? I see get slots but that just returns the number of slots available so is there another way? Cheers.
September 10, 20196 yr Author Actually, I thought i had it working but turns out when I right-clicked my block, the game crashed. I add this line IItemHandler inv = (IItemHandler) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) but I don't think this is right, any pointers on this one? And PlayerInventory#currentItem is what I was looking for. Thanks.
September 15, 20196 yr Author Thanks, I messed around this this and never got it to work how I wanted it too. So I just used player.inventory.decrStackSize() and used currentItem() and the value of 1 which did what I needed.
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.