Skip to content

Commit 186a317

Browse files
committed
Backport fix HurtByTargetGoal npe
58575d0
1 parent 9d2cc99 commit 186a317

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

leaf-server/minecraft-patches/features/0235-Async-target-finding.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ index fb160a59c873d5c3f2c3d31966ca1a653f1b384d..96ccafe979c5c15e26c12f6ca98ad1e8
14111411
return this.potentialTarget != null && !(this.potentialTarget instanceof Player player1 && (player1.isSpectator() || player1.isCreative()));
14121412
}
14131413
diff --git a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
1414-
index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..412fc8e049ba3763314ec2a56dce378cb0e4cc5f 100644
1414+
index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..c2b4bc95ee4cb4167c06556b14656c0fa59051a3 100644
14151415
--- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
14161416
+++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
14171417
@@ -73,6 +73,46 @@ public class HurtByTargetGoal extends TargetGoal {
@@ -1485,9 +1485,9 @@ index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..412fc8e049ba3763314ec2a56dce378c
14851485

14861486
+ // Leaf start - Async target finding
14871487
+ public void poll() {
1488-
+ if (!(this.mob.getGoalCtx().result() instanceof List toAlert)) return;
1488+
+ if (!(this.mob.getGoalCtx().result() instanceof List<?> toAlert)) return;
14891489
+ LivingEntity lastHurtByMob = this.mob.getLastHurtByMob();
1490-
+ if (lastHurtByMob.getType() == EntityType.PLAYER && getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) {
1490+
+ if (lastHurtByMob == null || (lastHurtByMob.getType() == EntityType.PLAYER && getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER))) {
14911491
+ return;
14921492
+ }
14931493
+ for (Class<?> clazz : this.toIgnoreDamage) {

0 commit comments

Comments
 (0)