mojira.dev
MC-97163

Items held with the cursor will drop upon death with the keepInventory gamerule enabled

When a player dies while holding any item(s) in their mouse cursor (in an inventory, or GUI for example) the stack will be removed from that player's inventory and drop as an item entity, even if the keepInventory gamerule is enabled.

Steps to Reproduce:

(Must be in survival mode, with cheats enabled)

  1. Enable 'keepInventory':

    /gamerule keepInventory true
  2. Take continuous damage (ie; stand near a cactus, in fire, falling. etc)

  3. Before dying, open your inventory and hold an item in your cursor

Expected & Observed Behavior:

❌ - What ever you're holding will drop on the ground as an entity where you died.
✔ - The items would be returned to the player inventory.

Linked issues

Attachments

Comments 18

There is no inventory slot for a item you switch slots, so ther is no place in can place it in when you die

Most likely intended due to that reason

The game could just place the item into any free slot. That would still be better than dropping it.

The thing is, fill your enthire inventory with items, including offhand and armor slots.
Go stand in a dropped item and move a item out of a slot, there is no free space left, since you'll pickup the dropped item.

What slot is left to put it in?

As I mentioned in the description, that corner case cannot be solved this way. The item should be dropped as is the case right now. Doesn't mean the behavior is correct or intended for inventories that are not completely full.

IMO this should go to the reddit, post it that it should drop at spawn, when respawning instead, or something like that

As the current situation is the intended situation, as it's not stored in the inventory

8 more comments

I believe this is due to the fact that if you hold an item with you cursor and close a GUI including your inventory it drops the item even if you closed it because you died.

Can confirm in 21w06a. Video attached.

Can confirm in 21w07a.

Can confirm in 1.17.

Can reproduce this in 24w04a. I'd like to request ownership of this issue, as it relates closely to another issue I maintain, MC-234511. @unknown has also been inactive for 4 years.

Fenhl (Max Dominik Weber)

[Mod] Jingy

(Unassigned)

Confirmed

Items

keepinventory

Minecraft 16w07a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9 Pre-Release 3, Minecraft 1.9 Pre-Release 4, ..., 1.19.4, 1.20.4, 24w04a, 1.20.5, 1.21

Retrieved