-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent keep inventory deaths from dropping open container/cursor items #11533
base: master
Are you sure you want to change the base?
Prevent keep inventory deaths from dropping open container/cursor items #11533
Conversation
Before: Dying with item on cursor while in inventory protected area (item drops): Dying with item in anvil inventory while in inventory protected area (item drops): Dying with item in crafting grid while in inventory protected area (item drops): |
After (with config option enabled) Dying with item in merchant inventory while in inventory protected area (item returned to inventory): Dying with item on cursor while in inventory protected area (item returned to inventory): Dying with item in anvil inventory while in inventory protected area (item returned to inventory): Dying with item in crafting grid while in inventory protected area (item returned to inventory): |
The only inventory this doesn't apply to is beacons, because they never return items to inventory and always drop (see: https://bugs.mojang.com/browse/MC-177476) @Override // where is placeItemBackInInventory here?? MC-177476
public void removed(Player player) {
super.removed(player);
if (!player.level().isClientSide) {
ItemStack itemstack = this.paymentSlot.remove(this.paymentSlot.getMaxStackSize());
if (!itemstack.isEmpty()) {
player.drop(itemstack, false);
}
}
} I could easily add a fix for this to the patch and add keep inventory support, what do you think? |
ye this would be helpful |
I have just seem the changes for 1.21.3 and this PR patch will definitely need rewritten, gonna wait a couple weeks for 1.21.3 to be stable. |
When a player has an open inventory—such as with a merchant, anvil or their own crafting grid—and
places items in it, or has an item on their cursor, closing the inventory typically
returns those items to the player's main inventory. However, if the player dies with
the inventory still open, the items are dropped onto the ground.
This usually isn't a problem, as their entire inventory would be dropped anyway.
But when keep inventory is enabled, these items should return directly to the player's inventory
to prevent valuable items from being accidentally dropped—especially
in spawn areas where keep inventory is active.
This patch makes the items return directly to the inventory if they die with keep inventory.