--- a/net/minecraft/entity/ai/goal/MeleeAttackGoal.java
+++ b/net/minecraft/entity/ai/goal/MeleeAttackGoal.java
@@ -20,6 +20,8 @@
    private int field_234037_i_;
    private final int field_188493_g = 20;
    private long field_220720_k;
+   private int failedPathFindingPenalty = 0;
+   private boolean canPenalize = false;
 
    public MeleeAttackGoal(CreatureEntity p_i1636_1_, double p_i1636_2_, boolean p_i1636_4_) {
       this.field_75441_b = p_i1636_1_;
@@ -40,6 +42,15 @@
          } else if (!livingentity.func_70089_S()) {
             return false;
          } else {
+           if (canPenalize) {
+               if (--this.field_75445_i <= 0) {
+                  this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(livingentity, 0);
+                  this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7);
+                  return this.field_75438_g != null;
+               } else {
+                  return true;
+               }
+            }
             this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(livingentity, 0);
             if (this.field_75438_g != null) {
                return true;
@@ -92,6 +103,18 @@
          this.field_151495_j = livingentity.func_226278_cu_();
          this.field_151496_k = livingentity.func_226281_cx_();
          this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7);
+         if (this.canPenalize) {
+            this.field_75445_i += failedPathFindingPenalty;
+            if (this.field_75441_b.func_70661_as().func_75505_d() != null) {
+               net.minecraft.pathfinding.PathPoint finalPathPoint = this.field_75441_b.func_70661_as().func_75505_d().func_75870_c();
+               if (finalPathPoint != null && livingentity.func_70092_e(finalPathPoint.field_75839_a, finalPathPoint.field_75837_b, finalPathPoint.field_75838_c) < 1)
+                  failedPathFindingPenalty = 0;
+               else
+                  failedPathFindingPenalty += 10;
+            } else {
+               failedPathFindingPenalty += 10;
+            }
+         }
          if (d0 > 1024.0D) {
             this.field_75445_i += 10;
          } else if (d0 > 256.0D) {
