--- a/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
+++ b/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java
@@ -4,6 +4,7 @@
 import java.util.Iterator;
 import java.util.List;
 import javax.annotation.Nullable;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.EntitySelector;
 import net.minecraft.world.entity.EntityType;
 import net.minecraft.world.entity.LivingEntity;
@@ -16,6 +17,7 @@
 import net.minecraft.world.phys.AABB;
 
 public class HurtByTargetGoal extends TargetGoal {
+
     private static final TargetingConditions HURT_BY_TARGETING = TargetingConditions.forCombat().ignoreLineOfSight().ignoreInvisibilityTesting();
     private static final int ALERT_RANGE_Y = 10;
     private boolean alertSameType;
@@ -33,18 +35,24 @@
     @Override
     public boolean canUse() {
         int i = this.mob.getLastHurtByMobTimestamp();
-        LivingEntity livingEntity = this.mob.getLastHurtByMob();
-        if (i != this.timestamp && livingEntity != null) {
-            if (livingEntity.getType() == EntityType.PLAYER && this.mob.level().getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) {
+        LivingEntity entityliving = this.mob.getLastHurtByMob();
+
+        if (i != this.timestamp && entityliving != null) {
+            if (entityliving.getType() == EntityType.PLAYER && this.mob.level().getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) {
                 return false;
             } else {
-                for(Class<?> class_ : this.toIgnoreDamage) {
-                    if (class_.isAssignableFrom(livingEntity.getClass())) {
+                Class[] aclass = this.toIgnoreDamage;
+                int j = aclass.length;
+
+                for (int k = 0; k < j; ++k) {
+                    Class<?> oclass = aclass[k];
+
+                    if (oclass.isAssignableFrom(entityliving.getClass())) {
                         return false;
                     }
                 }
 
-                return this.canAttack(livingEntity, HURT_BY_TARGETING);
+                return this.canAttack(entityliving, HurtByTargetGoal.HURT_BY_TARGETING);
             }
         } else {
             return false;
@@ -59,7 +67,7 @@
 
     @Override
     public void start() {
-        this.mob.setTarget(this.mob.getLastHurtByMob());
+        this.mob.setTarget(this.mob.getLastHurtByMob(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
         this.targetMob = this.mob.getTarget();
         this.timestamp = this.mob.getLastHurtByMobTimestamp();
         this.unseenMemoryTicks = 300;
@@ -71,44 +79,41 @@
     }
 
     protected void alertOthers() {
-        double d = this.getFollowDistance();
-        AABB aABB = AABB.unitCubeFromLowerCorner(this.mob.position()).inflate(d, 10.0D, d);
-        List<? extends Mob> list = this.mob.level().getEntitiesOfClass(this.mob.getClass(), aABB, EntitySelector.NO_SPECTATORS);
-        Iterator var5 = list.iterator();
+        double d0 = this.getFollowDistance();
+        AABB axisalignedbb = AABB.unitCubeFromLowerCorner(this.mob.position()).inflate(d0, 10.0D, d0);
+        List<? extends Mob> list = this.mob.level().getEntitiesOfClass(this.mob.getClass(), axisalignedbb, EntitySelector.NO_SPECTATORS);
+        Iterator iterator = list.iterator();
 
-        while(true) {
-            Mob mob;
-            while(true) {
-                if (!var5.hasNext()) {
-                    return;
-                }
+        while (iterator.hasNext()) {
+            Mob entityinsentient = (Mob) iterator.next();
 
-                mob = (Mob)var5.next();
-                if (this.mob != mob && mob.getTarget() == null && (!(this.mob instanceof TamableAnimal) || ((TamableAnimal)this.mob).getOwner() == ((TamableAnimal)mob).getOwner()) && !mob.isAlliedTo(this.mob.getLastHurtByMob())) {
-                    if (this.toIgnoreAlert == null) {
-                        break;
-                    }
+            if (this.mob != entityinsentient && entityinsentient.getTarget() == null && (!(this.mob instanceof TamableAnimal) || ((TamableAnimal) this.mob).getOwner() == ((TamableAnimal) entityinsentient).getOwner()) && !entityinsentient.isAlliedTo((Entity) this.mob.getLastHurtByMob())) {
+                if (this.toIgnoreAlert != null) {
+                    boolean flag = false;
+                    Class[] aclass = this.toIgnoreAlert;
+                    int i = aclass.length;
 
-                    boolean bl = false;
+                    for (int j = 0; j < i; ++j) {
+                        Class<?> oclass = aclass[j];
 
-                    for(Class<?> class_ : this.toIgnoreAlert) {
-                        if (mob.getClass() == class_) {
-                            bl = true;
+                        if (entityinsentient.getClass() == oclass) {
+                            flag = true;
                             break;
                         }
                     }
 
-                    if (!bl) {
-                        break;
+                    if (flag) {
+                        continue;
                     }
                 }
-            }
 
-            this.alertOther(mob, this.mob.getLastHurtByMob());
+                this.alertOther(entityinsentient, this.mob.getLastHurtByMob());
+            }
         }
+
     }
 
     protected void alertOther(Mob mob, LivingEntity target) {
-        mob.setTarget(target);
+        mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
     }
 }
