-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, Minecraft 1.12.2 Pre-Release 2, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45a, Minecraft 17w45b, Minecraft 17w46a, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w03b, Minecraft 18w06a, Minecraft 18w07b, Minecraft 18w09a, Minecraft 18w10d, Minecraft 18w14b, Minecraft 1.13-pre1, Minecraft 1.13-pre3, Minecraft 1.13-pre6, Minecraft 1.13-pre10, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w04b, Minecraft 19w05a, Minecraft 19w06a, 1.14.4, 1.15 Pre-release 6, 1.15.1, 20w21a, 1.16 Pre-release 4, 1.16 Pre-release 6, 1.16, 1.16.4, 20w48a, 20w51a, 1.16.5, 21w05b, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1, 21w41a, 21w42a, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 4, 1.18 Pre-release 5, 1.18 Pre-release 6, 1.18 Pre-release 8, 1.18 Release Candidate 1, 1.18 Release Candidate 3, 1.18.1, 1.19, 1.19.1, 1.19.3, 23w05a, 1.19.4, 1.20.1, 1.20.6, 24w19b, 1.21
-
Confirmed
-
Networking
-
Normal
-
Platform
The bug
Picking up only a part of an item stack of an item entity because your inventory is nearly full is not correctly detected by the server causing:
- Server-side:
- Missing statistics change
- Client-side:
- Missing sound and animation
- Item stack of item entity not updated
How to reproduce
It's easiest to reproduce this by starting in creative mode and then switching to survival partway through.
- Fill all of your inventory except for the first hotbar slot with one item (e.g. wooden swords), fill the hotbar slot with a nearly full stack of for example stone
/give @s wooden_sword 36 /item replace entity @s hotbar.0 with minecraft:stone 63
- Switch to survival mode (This is needed because in creative you can pick items up even when the inventory is full.)
/gamemode survival
- Summon an item entity containing two stone items
/summon item ~ ~ ~ {Item:{id:"stone",Count:2b}}
→
The item entity still shows two items, there was no sound, no animation, etc.
Code analysis
Based on 1.12.2 decompiled using MCP 9.40
The method net.minecraft.entity.item.EntityItem.onCollideWithPlayer(EntityPlayer) tests if net.minecraft.entity.player.InventoryPlayer.addItemStackToInventory(ItemStack) returns true. Since this is only the case if the complete stack was picked up, it should instead test if the stack size decreased.
The following shows the problems with the current code:
ItemStack itemstack = this.getItem(); Item item = itemstack.getItem(); int i = itemstack.getCount(); // Don't test for entityIn.inventory.addItemStackToInventory(itemstack) == true if (this.pickupDelay == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getName())) && entityIn.inventory.addItemStackToInventory(itemstack)) { // Change this, picked up count can be < i entityIn.onItemPickup(this, i); if (itemstack.isEmpty()) { this.setDead(); itemstack.setCount(i); } // Change this, picked up count can be < i entityIn.addStat(StatList.getObjectsPickedUpStats(item), i); }
- discovered while testing
-
MC-100918 Picking up item from stack makes no sound
- Resolved
- is duplicated by
-
MC-100918 Picking up item from stack makes no sound
- Resolved
-
MC-122737 Items Picked Up Statistics Incorrect
- Resolved
-
MC-165858 item on ground apperence
- Resolved
-
MC-185944 visual glitch when picking up items
- Resolved
-
MC-210738 In specific circumstances, dropped items can appear as a larger stack than they are
- Resolved
-
MC-226288 A single dropped item appears as if it is multiple items in certain cases
- Resolved
-
MC-230619 Block Drop Bug
- Resolved
-
MC-230622 Block Drop Bug
- Resolved
-
MC-230955 Minecraft sometimes gets confused and renders 1 item as multiple items
- Resolved
-
MC-262719 Picked up statistic does not increase
- Resolved
-
MC-263643 Item entities don't update visually when not picking the full stack
- Resolved
- relates to
-
MC-250000 Allays and villagers create ghost items when they take items from a stack and cannot fit the whole stack in their inventory
- Resolved
-
MC-170863 Dropping item stacks from the player's hotbar in any creative inventory tab other than "Survival Inventory" deletes items
- Resolved