9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

Backport fix HurtByTargetGoal npe

58575d0adc
This commit is contained in:
hayanesuru
2025-06-29 13:14:25 +09:00
parent 9d2cc999a9
commit 186a317f5d

View File

@@ -1411,7 +1411,7 @@ index fb160a59c873d5c3f2c3d31966ca1a653f1b384d..96ccafe979c5c15e26c12f6ca98ad1e8
return this.potentialTarget != null && !(this.potentialTarget instanceof Player player1 && (player1.isSpectator() || player1.isCreative())); return this.potentialTarget != null && !(this.potentialTarget instanceof Player player1 && (player1.isSpectator() || player1.isCreative()));
} }
diff --git a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java diff --git a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..412fc8e049ba3763314ec2a56dce378cb0e4cc5f 100644 index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..c2b4bc95ee4cb4167c06556b14656c0fa59051a3 100644
--- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java --- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
+++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
@@ -73,6 +73,46 @@ public class HurtByTargetGoal extends TargetGoal { @@ -73,6 +73,46 @@ public class HurtByTargetGoal extends TargetGoal {
@@ -1485,9 +1485,9 @@ index a8ec1d5f4b0fb0ff26a234235b7d8d9c4b4a2a98..412fc8e049ba3763314ec2a56dce378c
+ // Leaf start - Async target finding + // Leaf start - Async target finding
+ public void poll() { + public void poll() {
+ if (!(this.mob.getGoalCtx().result() instanceof List toAlert)) return; + if (!(this.mob.getGoalCtx().result() instanceof List<?> toAlert)) return;
+ LivingEntity lastHurtByMob = this.mob.getLastHurtByMob(); + LivingEntity lastHurtByMob = this.mob.getLastHurtByMob();
+ if (lastHurtByMob.getType() == EntityType.PLAYER && getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) { + if (lastHurtByMob == null || (lastHurtByMob.getType() == EntityType.PLAYER && getServerLevel(this.mob).getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER))) {
+ return; + return;
+ } + }
+ for (Class<?> clazz : this.toIgnoreDamage) { + for (Class<?> clazz : this.toIgnoreDamage) {