aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch
diff options
context:
space:
mode:
authorRiley Park <[email protected]>2024-05-15 17:06:59 -0700
committerGitHub <[email protected]>2024-05-15 17:06:59 -0700
commitf17519338bc589c045e0b32bfc37e048b23544d5 (patch)
treee50182ec698b4a9de8f366f485ee089b1901bbd9 /patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch
parent3fc93581bb876e8149b2ca423375a98f5ca12d27 (diff)
downloadPaper-f17519338bc589c045e0b32bfc37e048b23544d5.tar.gz
Paper-f17519338bc589c045e0b32bfc37e048b23544d5.zip
Expose server build information (#10729)
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <[email protected]> Co-authored-by: masmc05 <[email protected]>
Diffstat (limited to 'patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch')
-rw-r--r--patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch48
1 files changed, 48 insertions, 0 deletions
diff --git a/patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch b/patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch
new file mode 100644
index 0000000000..513faeb27d
--- /dev/null
+++ b/patches/server/0388-Improve-fix-EntityTargetLivingEntityEvent.patch
@@ -0,0 +1,48 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Fri, 9 Dec 2022 03:10:23 -0800
+Subject: [PATCH] Improve/fix EntityTargetLivingEntityEvent
+
+
+diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
+index 5aeef564cdaabeed88a52635e56073cca3a9d1f1..fe635e46569c67dac1d3581ee930d1bfa8b4030e 100644
+--- a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
++++ b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
+@@ -47,17 +47,30 @@ public class StopAttackingIfTargetInvalid {
+ if (entityinsentient.canAttack(entityliving) && (!shouldForgetIfTargetUnreachable || !StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !alternativeCondition.test(entityliving)) {
+ return true;
+ } else {
++ // Paper start - better track target change reason
++ final EntityTargetEvent.TargetReason reason;
++ if (!entityinsentient.canAttack(entityliving)) {
++ reason = EntityTargetEvent.TargetReason.TARGET_INVALID;
++ } else if (shouldForgetIfTargetUnreachable && StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) {
++ reason = EntityTargetEvent.TargetReason.FORGOT_TARGET;
++ } else if (!entityliving.isAlive()) {
++ reason = EntityTargetEvent.TargetReason.TARGET_DIED;
++ } else if (entityliving.level() != entityinsentient.level()) {
++ reason = EntityTargetEvent.TargetReason.TARGET_OTHER_LEVEL;
++ } else {
++ reason = EntityTargetEvent.TargetReason.TARGET_INVALID;
++ }
++ // Paper end
+ // CraftBukkit start
+- LivingEntity old = entityinsentient.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
+- EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
++ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, null, reason); // Paper
+ if (event.isCancelled()) {
+ return false;
+ }
+- if (event.getTarget() == null) {
+- memoryaccessor.erase();
+- return true;
+- }
+- entityliving = ((CraftLivingEntity) event.getTarget()).getHandle();
++ // if (event.getTarget() == null) { // Paper - this is wrong, you are skipping the forgetCallback
++ // memoryaccessor.erase();
++ // return true;
++ // }
++ // entityliving = ((CraftLivingEntity) event.getTarget()).getHandle();
+ // CraftBukkit end
+ forgetCallback.accept(entityinsentient, entityliving);
+ memoryaccessor.erase();