--- a/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java
+++ b/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.entity.ai.goal.target;
 
 import java.util.EnumSet;
+import java.util.Iterator;
 import java.util.List;
 import javax.annotation.Nullable;
 import net.minecraft.world.entity.LivingEntity;
@@ -12,10 +13,11 @@
 import net.minecraft.world.phys.AABB;
 
 public class DefendVillageTargetGoal extends TargetGoal {
+
     private final IronGolem golem;
     @Nullable
     private LivingEntity potentialTarget;
-    private final TargetingConditions attackTargeting = TargetingConditions.forCombat().range(64.0);
+    private final TargetingConditions attackTargeting = TargetingConditions.forCombat().range(64.0D);
 
     public DefendVillageTargetGoal(IronGolem golem) {
         super(golem, false, true);
@@ -25,28 +27,38 @@
 
     @Override
     public boolean canUse() {
-        AABB aABB = this.golem.getBoundingBox().inflate(10.0, 8.0, 10.0);
-        List<? extends LivingEntity> list = this.golem.level().getNearbyEntities(Villager.class, this.attackTargeting, this.golem, aABB);
-        List<Player> list2 = this.golem.level().getNearbyPlayers(this.attackTargeting, this.golem, aABB);
+        AABB axisalignedbb = this.golem.getBoundingBox().inflate(10.0D, 8.0D, 10.0D);
+        List<? extends LivingEntity> list = this.golem.level().getNearbyEntities(Villager.class, this.attackTargeting, this.golem, axisalignedbb);
+        List<Player> list1 = this.golem.level().getNearbyPlayers(this.attackTargeting, this.golem, axisalignedbb);
+        Iterator iterator = list.iterator();
 
-        for (LivingEntity livingEntity : list) {
-            Villager villager = (Villager)livingEntity;
+        while (iterator.hasNext()) {
+            LivingEntity entityliving = (LivingEntity) iterator.next();
+            Villager entityvillager = (Villager) entityliving;
+            Iterator iterator1 = list1.iterator();
+
+            while (iterator1.hasNext()) {
+                Player entityhuman = (Player) iterator1.next();
+                int i = entityvillager.getPlayerReputation(entityhuman);
 
-            for (Player player : list2) {
-                int i = villager.getPlayerReputation(player);
                 if (i <= -100) {
-                    this.potentialTarget = player;
+                    this.potentialTarget = entityhuman;
                 }
             }
         }
 
-        return this.potentialTarget != null
-            && (!(this.potentialTarget instanceof Player) || !this.potentialTarget.isSpectator() && !((Player)this.potentialTarget).isCreative());
+        if (this.potentialTarget == null) {
+            return false;
+        } else if (this.potentialTarget instanceof Player && (this.potentialTarget.isSpectator() || ((Player) this.potentialTarget).isCreative())) {
+            return false;
+        } else {
+            return true;
+        }
     }
 
     @Override
     public void start() {
-        this.golem.setTarget(this.potentialTarget);
+        this.golem.setTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason
         super.start();
     }
 }
