Files
MiraiMC/patches/server/0082-Fix-mobs-attacking-themselves.patch
etil2jz ac9967167c Update Upstream (Pufferfish)
Also drop merged PRs and patches replaced by the new chunk system
2022-10-13 12:48:37 +02:00

22 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: etil2jz <81570777+etil2jz@users.noreply.github.com>
Date: Fri, 29 Apr 2022 12:08:22 +0200
Subject: [PATCH] Fix mobs attacking themselves
If an entity is provoked by a second one using commands,
the second will join in the fight against itself,
causing it to attack itself repeatedly. See https://bugs.mojang.com/browse/MC-110386.
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
index 39ea15c7577af186d93d4ad9a48034d746a86fc8..214c1733ba2b5628b36ae6f5b653aa462cf3f86d 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
@@ -114,6 +114,7 @@ public class HurtByTargetGoal extends TargetGoal {
}
protected void alertOther(Mob mob, LivingEntity target) {
+ if (mob == target) return; // Mirai - avoid entities with suicidal thoughts /s
mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
}
}