From c90fc43eb897ec5b864982839ab83e5ad0f12375 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 4 Aug 2023 15:53:36 +0200 Subject: [PATCH] Only erase allay memory on non-item targets Spigot incorrectly instanceOf checks the EntityTargetEvent#getTarget against the internal ItemEntity type and removes the nearest wanted item memory if said instanceOf check fails, (which is always the case) causing allays to behave differently as they constantly lose their target item. This commit fixes the faulty behaviour by instance performing a check against the CraftItem type. --- .../world/entity/ai/behavior/GoToWantedItem.java.patch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java.patch index 081aa95a6..d9692605c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java +++ b/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java -@@ -28,6 +28,20 @@ +@@ -28,6 +28,21 @@ ItemEntity entityitem = (ItemEntity) behaviorbuilder_b.get(memoryaccessor2); if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && startCondition.test(entityliving) && entityitem.closerThan(entityliving, (double) radius) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition()) && entityliving.canPickUpLoot()) { @@ -11,8 +11,9 @@ + if (event.isCancelled()) { + return false; + } -+ if (!(event.getTarget() instanceof ItemEntity)) { ++ if (!(event.getTarget() instanceof org.bukkit.craftbukkit.entity.CraftItem)) { // Paper - only erase allay memory on non-item targets + memoryaccessor2.erase(); ++ return false; // Paper - only erase allay memory on non-item targets + } + + entityitem = (ItemEntity) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();