Skip to content

Instantly share code, notes, and snippets.

@aikar
Created October 25, 2018 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/143709837fa8423c3f8671ff7e0b1faa to your computer and use it in GitHub Desktop.
Save aikar/143709837fa8423c3f8671ff7e0b1faa to your computer and use it in GitHub Desktop.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index b766e00d0b..2042b9bd71 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -569,4 +569,10 @@ public class PaperWorldConfig {
private void preventMovingIntoUnloadedChunks() {
preventMovingIntoUnloadedChunks = getBoolean("settings.prevent-moving-into-unloaded-chunks", false);
}
+
+ public double optimizeEntityMovement = 0.5D;
+ private void optimizeEntityMovement() {
+ optimizeEntityMovement = getDouble("optimize-entity-movement", optimizeEntityMovement);
+ }
+
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e8c811dd94..9aa928a9b5 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -558,6 +558,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
+ // Paper start
+ double pendingX = 0D;
+ double pendingY = 0D;
+ double pendingZ = 0D;
+ // Paper end
+
public void extinguish() {
this.fireTicks = 0;
}
@@ -683,6 +689,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
+ // Paper start
+ d0 += pendingX;
+ d1 += pendingY;
+ d2 += pendingZ;
+ if ((d0 * d0 + d1 * d1 + d2 * d2) < this.world.paperConfig.optimizeEntityMovement) {
+ pendingX = d0;
+ pendingY = d1;
+ pendingZ = d2;
+ System.out.println(this + " Optimized movement " + d0+"," +d1+","+ d2);
+ d0 = d7;
+ d1 = d8;
+ d2 = d9;
+ }
+ // Paper end
+
AxisAlignedBB axisalignedbb = this.getBoundingBox();
if (d0 != 0.0D || d1 != 0.0D || d2 != 0.0D) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment