mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-05 07:01:45 +01:00
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.
This commit is contained in:
parent
a13bff4a5f
commit
c90fc43eb8
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user