9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/removed/1.19.4/server/0026-Fix-mobs-attacking-themselves.patch
2023-03-27 02:03:05 +03: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..1de734820a5a4b1580c123a8e4a2513d52c42a4b 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; // DivineMC - avoid entities with suicidal thoughts /s
mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
}
}