Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
skip entity move if movement is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Sep 9, 2024
1 parent 225c7fd commit b5dd1e2
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 4 deletions.
41 changes: 41 additions & 0 deletions patches/server/0103-vmp-skip-entity-move-if-movement-is-zero.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 404Setup <[email protected]>
Date: Mon, 9 Sep 2024 09:26:31 +0800
Subject: [PATCH] vmp: skip entity move if movement is zero

Original code by RelativityMC, licensed under MIT
You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings)

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 31c6840e819eacb9fde4f3ea0e2314bd5c947852..16027780d6ce37cf2b069cc3a0af87972175a434 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -323,6 +323,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public float yRotO;
public float xRotO;
private AABB bb;
+ private boolean boundingBoxChanged = false; // vmp: skip entity move if movement is zero
public boolean onGround;
public boolean horizontalCollision;
public boolean verticalCollision;
@@ -1207,6 +1208,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
// Paper end - detailed watchdog information

public void move(MoverType movementType, Vec3 movement) {
+ // vmp start - skip entity move if movement is zero
+ if (!boundingBoxChanged && movement.equals(Vec3.ZERO)) {
+ boundingBoxChanged = false;
+ return;
+ }
+ // vmp end
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot move an entity off-main");
@@ -4310,6 +4317,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}

public final void setBoundingBox(AABB boundingBox) {
+ if (!this.bb.equals(boundingBox)) boundingBoxChanged = true; // vmp - skip entity move if movement is zero
// CraftBukkit start - block invalid bounding boxes
double minX = boundingBox.minX,
minY = boundingBox.minY,
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ index ee8e9c0e3690e78f3cc621ddfca89ea4256d4803..0466b04f24830539f2c927481c1c7995
}

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 31c6840e819eacb9fde4f3ea0e2314bd5c947852..6eade6f119c48687a62d13926831b20ff301eec2 100644
index 16027780d6ce37cf2b069cc3a0af87972175a434..f83c55a65ce97f9944049d7e7a9cf763ea957054 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -547,6 +547,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -548,6 +548,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
* Overriding this field will cause memory leaks.
*/
private final boolean hardCollides;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ index 035a40836a6986a2740f02712276d5a261f2aa3c..0682e8b10ff65d5a63bcf4768473ec1f
flag5 = true;
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6eade6f119c48687a62d13926831b20ff301eec2..ad87599640d36fc06fee7a212c7aa5d82dc2df7e 100644
index f83c55a65ce97f9944049d7e7a9cf763ea957054..7f60b07f12d0f209bcec9c78ff5837fc74259e41 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -443,6 +443,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -444,6 +444,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
private long lastPlayerScanTime;
private boolean playerInRange;
// Canvas end
Expand Down

0 comments on commit b5dd1e2

Please sign in to comment.