papermc/CraftBukkit-Patches/0069-Nerf-Zombie-Lag-Issues.patch

106 lines
4.1 KiB
Diff

From f0fcf1cdd831dea90719d24c8f8f48ea18c14863 Mon Sep 17 00:00:00 2001
From: Dylan Xaldin <Puremin0rez515@gmail.com>
Date: Sat, 14 Sep 2013 11:02:34 +1000
Subject: [PATCH] Nerf Zombie Lag Issues
Nerf the Zombie Lag issues in MC 1.6 - "Fixes" MC-17630
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java
index a07c6cf..ee4bc7e 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java
@@ -63,19 +63,88 @@ public class PathfinderGoalMeleeAttack extends PathfinderGoal {
this.b.getNavigation().h();
}
+ // Spigot start
+ private double pathX;
+ private double pathY;
+ private double pathZ;
+ private boolean prevPathOK;
+ private int fullRangeSearchDelay;
+ // Spigot end
public void e() {
EntityLiving entityliving = this.b.getGoalTarget();
this.b.getControllerLook().a(entityliving, 30.0F, 30.0F);
+ double goalDistanceSq = this.b.e( entityliving.locX, entityliving.boundingBox.b, entityliving.locZ ); // Spigot
if ((this.e || this.b.getEntitySenses().canSee(entityliving)) && --this.h <= 0) {
- this.h = 4 + this.b.aD().nextInt(7);
- this.b.getNavigation().a((Entity) entityliving, this.d);
+ // Spigot start
+ double targetMovement = entityliving.e( pathX, pathY, pathZ );
+ // If this is true, then we are re-pathing
+ if ( ( this.h <= 0 && targetMovement >= 1.0D ) || ( this.h <= 0 && this.b.aD().nextInt( 200 ) == 0 ) ) /* EntityCreature random instance */
+
+ {
+ AttributeInstance rangeAttr = this.b.getAttributeInstance( GenericAttributes.b );
+ double origRange = rangeAttr.getValue();
+ if ( fullRangeSearchDelay > 0 )
+ {
+
+ double dist = Math.sqrt( goalDistanceSq );
+ if ( dist <= 8.0D )
+ {
+ dist = 8.0D;
+ }
+ if ( dist > origRange )
+ {
+ dist = origRange;
+ }
+ rangeAttr.setValue( dist );
+ }
+
+ prevPathOK = this.b.getNavigation().a( (Entity) entityliving, this.d );
+
+ if ( fullRangeSearchDelay > 0 )
+ {
+ fullRangeSearchDelay--;
+ if ( origRange > 40.0D )
+ {
+ origRange = 40.0D;
+ }
+ rangeAttr.setValue( origRange );
+ }
+
+ pathX = entityliving.locX;
+ pathY = entityliving.boundingBox.b;
+ pathZ = entityliving.locZ;
+ this.h = 4 + this.b.aD().nextInt( 7 ); /* EntityCreature random instance */
+
+ if ( goalDistanceSq > 256.0D )
+ {
+ if ( goalDistanceSq > 1024.0D )
+ {
+ this.h += 8;
+ } else
+ {
+ this.h += 16;
+ }
+ } else if ( !prevPathOK )
+ {
+ this.h += 24;
+ }
+
+ if ( !prevPathOK || goalDistanceSq <= 256.0D )
+ {
+ if ( fullRangeSearchDelay <= 0 )
+ {
+ fullRangeSearchDelay = 4 + this.b.aD().nextInt( 4 ); /* EntityCreature random instance */
+ }
+ }
+ }
}
+ // Spigot end
this.c = Math.max(this.c - 1, 0);
double d0 = (double) (this.b.width * 2.0F * this.b.width * 2.0F + entityliving.width);
- if (this.b.e(entityliving.locX, entityliving.boundingBox.b, entityliving.locZ) <= d0) {
+ if (goalDistanceSq <= d0) { // Spigot
if (this.c <= 0) {
this.c = 20;
if (this.b.aZ() != null) {
--
1.8.1.2