-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
None
-
All
-
git-Spigot-a596182-edd8fdf (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
-
Yes
If either EntityPickupItemEvent or PlayerPickupItemEvent is cancelled but the player would otherwise be able to pick up the item, the quantity of the item on the ground is incorrectly altered to be the amount that would have been picked up.
For example, if the player has capacity to hold two stone blocks, walking over a stack of stone blocks would reduce their number to two.
The bug seems obvious in the code:
From EntityItem.java in pickup(EntityHuman):
if (this.pickupDelay <= 0 && canHold > 0) {
// RIGHT HERE
itemstack.setCount(canHold);
PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player)entityhuman.getBukkitEntity(), (Item)getBukkitEntity(), remaining);
playerEvent.setCancelled(!entityhuman.canPickUpLoot);
this.world.getServer().getPluginManager().callEvent(playerEvent);
if (playerEvent.isCancelled())
EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((Player)entityhuman.getBukkitEntity(), (Item)getBukkitEntity(), remaining);
entityEvent.setCancelled(!entityhuman.canPickUpLoot);
this.world.getServer().getPluginManager().callEvent(entityEvent);
if (entityEvent.isCancelled()) { return; }
itemstack.setCount(canHold + remaining);