SPIGOT-6483: Fix cancelling EntityPickupEvent for villagers

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-01 18:52:49 +10:00
parent 14af2c0a70
commit 2784d9c66a
2 changed files with 10 additions and 9 deletions

View File

@@ -90,24 +90,20 @@
this.fq();
this.die();
} else {
@@ -791,9 +811,16 @@
@@ -791,6 +811,13 @@
return;
}
+ // CraftBukkit start
+ ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack1.getCount(), false).isCancelled()) {
+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).a(itemstack);
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, remaining.getCount(), false).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
this.a(entityitem);
this.receive(entityitem, itemstack.getCount());
- ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
+ // ItemStack itemstack1 = inventorysubcontainer.a(itemstack); // CraftBukkit - moved up
if (itemstack1.isEmpty()) {
entityitem.die();
ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
@@ -903,7 +930,7 @@
if (entityirongolem != null) {