Skip to content

Instantly share code, notes, and snippets.

@aikar
Created October 25, 2018 05:40
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/56c482cd74949cfeea95821a497fdab9 to your computer and use it in GitHub Desktop.
Save aikar/56c482cd74949cfeea95821a497fdab9 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..1af92ed007 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 mergeEntityMovement = 0.075D;
+ private void mergeEntityMovement() {
+ mergeEntityMovement = getDouble("merge-entity-movement", mergeEntityMovement);
+ }
+
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e8c811dd94..743b5b4ae3 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;
}
@@ -580,6 +586,23 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
} else {
+ // Paper start
+ final double optimizeMin = this.world.paperConfig.mergeEntityMovement;
+ if (optimizeMin > 0 && enummovetype == EnumMoveType.SELF) {
+ if (pendingX != 0D) {
+ d0 += pendingX;
+ pendingX = 0D;
+ }
+ if (pendingY != 0D) {
+ d1 += pendingY;
+ pendingY = 0D;
+ }
+ if (pendingZ != 0D) {
+ d2 += pendingZ;
+ pendingZ = 0D;
+ }
+ }
+ // Paper end
if (enummovetype == EnumMoveType.PISTON) {
this.activatedTick = MinecraftServer.currentTick + 20; // Paper
long i = this.world.getTime();
@@ -683,6 +706,17 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
+ // Paper start
+ if (optimizeMin > 0 && enummovetype == EnumMoveType.SELF && !(this instanceof EntityLiving && ((EntityLiving) this).isJumping()) && d0 * d0 < optimizeMin && d1 * d1 < optimizeMin && d2 * d2 < optimizeMin) {
+ pendingX = d0;
+ pendingY = d1;
+ pendingZ = d2;
+ d0 = d7 = 0;
+ d1 = d8 = 0;
+ d2 = d9 = 0;
+ }
+ // Paper end
+
AxisAlignedBB axisalignedbb = this.getBoundingBox();
if (d0 != 0.0D || d1 != 0.0D || d2 != 0.0D) {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 923bc0cc72..bef0cd6595 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -89,7 +89,7 @@ public abstract class EntityLiving extends Entity {
protected float bd;
protected int be; protected int getKillCount() { return this.be; } // Paper - OBFHELPER
public float lastDamage;
- protected boolean bg;
+ protected boolean bg; public boolean isJumping() { return bg; } // Paper - OBFHELPER
public float bh;
public float bi;
public float bj;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment