--- a/net/minecraft/world/entity/ai/goal/target/TargetGoal.java
+++ b/net/minecraft/world/entity/ai/goal/target/TargetGoal.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.entity.ai.goal.target;
 
 import javax.annotation.Nullable;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.LivingEntity;
 import net.minecraft.world.entity.Mob;
 import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -9,8 +10,10 @@
 import net.minecraft.world.level.pathfinder.Node;
 import net.minecraft.world.level.pathfinder.Path;
 import net.minecraft.world.scores.Team;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
 
 public abstract class TargetGoal extends Goal {
+
     private static final int EMPTY_REACH_CACHE = 0;
     private static final int CAN_REACH_CACHE = 1;
     private static final int CANT_REACH_CACHE = 2;
@@ -22,13 +25,14 @@
     private int unseenTicks;
     @Nullable
     protected LivingEntity targetMob;
-    protected int unseenMemoryTicks = 60;
+    protected int unseenMemoryTicks;
 
     public TargetGoal(Mob mob, boolean checkVisibility) {
         this(mob, checkVisibility, false);
     }
 
     public TargetGoal(Mob mob, boolean checkVisibility, boolean checkNavigable) {
+        this.unseenMemoryTicks = 60;
         this.mob = mob;
         this.mustSee = checkVisibility;
         this.mustReach = checkNavigable;
@@ -36,34 +40,37 @@
 
     @Override
     public boolean canContinueToUse() {
-        LivingEntity livingEntity = this.mob.getTarget();
-        if (livingEntity == null) {
-            livingEntity = this.targetMob;
+        LivingEntity entityliving = this.mob.getTarget();
+
+        if (entityliving == null) {
+            entityliving = this.targetMob;
         }
 
-        if (livingEntity == null) {
+        if (entityliving == null) {
             return false;
-        } else if (!this.mob.canAttack(livingEntity)) {
+        } else if (!this.mob.canAttack(entityliving)) {
             return false;
         } else {
-            Team team = this.mob.getTeam();
-            Team team2 = livingEntity.getTeam();
-            if (team != null && team2 == team) {
+            Team scoreboardteambase = this.mob.getTeam();
+            Team scoreboardteambase1 = entityliving.getTeam();
+
+            if (scoreboardteambase != null && scoreboardteambase1 == scoreboardteambase) {
                 return false;
             } else {
-                double d = this.getFollowDistance();
-                if (this.mob.distanceToSqr(livingEntity) > d * d) {
+                double d0 = this.getFollowDistance();
+
+                if (this.mob.distanceToSqr((Entity) entityliving) > d0 * d0) {
                     return false;
                 } else {
                     if (this.mustSee) {
-                        if (this.mob.getSensing().hasLineOfSight(livingEntity)) {
+                        if (this.mob.getSensing().hasLineOfSight(entityliving)) {
                             this.unseenTicks = 0;
                         } else if (++this.unseenTicks > reducedTickDelay(this.unseenMemoryTicks)) {
                             return false;
                         }
                     }
 
-                    this.mob.setTarget(livingEntity);
+                    this.mob.setTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit
                     return true;
                 }
             }
@@ -83,7 +90,7 @@
 
     @Override
     public void stop() {
-        this.mob.setTarget((LivingEntity)null);
+        this.mob.setTarget((LivingEntity) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
         this.targetMob = null;
     }
 
@@ -115,17 +122,20 @@
 
     private boolean canReach(LivingEntity entity) {
         this.reachCacheTime = reducedTickDelay(10 + this.mob.getRandom().nextInt(5));
-        Path path = this.mob.getNavigation().createPath(entity, 0);
-        if (path == null) {
+        Path pathentity = this.mob.getNavigation().createPath((Entity) entity, 0);
+
+        if (pathentity == null) {
             return false;
         } else {
-            Node node = path.getEndNode();
-            if (node == null) {
+            Node pathpoint = pathentity.getEndNode();
+
+            if (pathpoint == null) {
                 return false;
             } else {
-                int i = node.x - entity.getBlockX();
-                int j = node.z - entity.getBlockZ();
-                return (double)(i * i + j * j) <= 2.25D;
+                int i = pathpoint.x - entity.getBlockX();
+                int j = pathpoint.z - entity.getBlockZ();
+
+                return (double) (i * i + j * j) <= 2.25D;
             }
         }
     }
