From 6f87ada41cb5dc7a065e0aa124eecc175b7bef5a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 9 May 2021 16:57:25 +1000 Subject: [PATCH] SPIGOT-6452: Call EntityPickupItemEvent for villagers By: Julian van den Berkmortel --- .../world/entity/npc/EntityVillager.patch | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch index a214d54c87..87653bc4a9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/npc/EntityVillager.patch @@ -90,7 +90,25 @@ this.fq(); this.die(); } else { -@@ -903,7 +923,7 @@ +@@ -791,9 +811,16 @@ + return; + } + ++ // CraftBukkit start ++ ItemStack itemstack1 = inventorysubcontainer.a(itemstack); ++ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack1.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(); +@@ -903,7 +930,7 @@ if (entityirongolem != null) { if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) { @@ -99,7 +117,7 @@ return entityirongolem; } -@@ -981,7 +1001,7 @@ +@@ -981,7 +1008,7 @@ @Override public void entitySleep(BlockPosition blockposition) { super.entitySleep(blockposition); @@ -108,7 +126,7 @@ this.bg.removeMemory(MemoryModuleType.WALK_TARGET); this.bg.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -989,7 +1009,7 @@ +@@ -989,7 +1016,7 @@ @Override public void entityWakeup() { super.entityWakeup();