13
0
geforkt von Mirrors/Paper

Optimize Small Entity Movement

Optimizes small movements by entities by merging the movement
into the entities next larger movement, until enough movement
velocity has been hit.

This reduces collision detection and able to reduce movement
cpu cost by 5-7%.

The default option of 0.75 seems to provide all the gains without
any noticable behavior change to entity movement.

We have to exclude slimes due to weird jumping animation bugs.
Dieser Commit ist enthalten in:
Aikar 2018-11-01 20:05:18 -04:00
Ursprung ecc751796d
Commit 51bc97bd90
2 geänderte Dateien mit 115 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,8 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MisterVector <whizkid3000@hotmail.com>
Date: Thu, 1 Nov 2018 14:50:05 -0700
Subject: [PATCH] MC-136865: Use valid item for enchantment checks on block break
Subject: [PATCH] MC-136865: Use valid item for enchantment checks on block
break
When an itemstack runs out of durability, the amount is reduced to
0 which then marks the item as invalid. This causes the last unit
@ -11,9 +12,8 @@ check sees the item as a dud.
keep the clone of the item used to a non empty value so it represents
the item used.
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index 23fc4d8e..dbbd1f33 100644
index 23fc4d8e14..dbbd1f3341 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -0,0 +0,0 @@ public class PlayerInteractManager {

Datei anzeigen

@ -0,0 +1,112 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 1 Nov 2018 19:45:51 -0400
Subject: [PATCH] Optimize Small Entity Movement
Optimizes small movements by entities by merging the movement
into the entities next larger movement, until enough movement
velocity has been hit.
This reduces collision detection and able to reduce movement
cpu cost by 5-7%.
The default option of 0.75 seems to provide all the gains without
any noticable behavior change to entity movement.
We have to exclude slimes due to weird jumping animation bugs.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index eabb2c1bad..f6d4c476bc 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
private void preventMovingIntoUnloadedChunks() {
preventMovingIntoUnloadedChunks = getBoolean("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 32b90f30d9..6023824e3d 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
+ // Paper start
+ protected double pendingX = 0D;
+ protected double pendingY = 0D;
+ protected double pendingZ = 0D;
+ public boolean shouldMergeMovement(int mergeMin, double d0, double d1, double d2) {
+ return d0 * d0 < mergeMin && d1 * d1 < mergeMin && d2 * d2 < mergeMin;
+ }
+ // Paper end
+
public void extinguish() {
this.fireTicks = 0;
}
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
} else {
+ // Paper start
+ final double mergeMin = this.world.paperConfig.mergeEntityMovement;
+ if (mergeMin > 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();
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
+ // Paper start
+ if (mergeMin > 0 && enummovetype == EnumMoveType.SELF && shouldMergeMovement(mergeMin, d0, d1, d2)) {
+ 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/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
index e63f4afa9b..1941faaebd 100644
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -0,0 +0,0 @@ public class EntitySlime extends EntityInsentient implements IMonster {
}
// Paper start
+ @Override
+ public boolean shouldMergeMovement(int mergeMin, double d0, double d1, double d2) {
+ // Slimes have weird movement bugs when a move is skipped, ideally we can fix this and fix that state
+ return false;
+ }
+
private boolean canWander = true;
public boolean canWander() {
return canWander;
--