Jump to content

(SOLVED)[1.14.4] Remove Single Item from Player Inventory


Blu_Nighttime

Recommended Posts

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 by Blu_Nighttime
topic solved
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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