Files
KeYiMC/patches/server/0014-Skip-entity-move-if-no-movement.patch
2022-11-29 05:29:56 -05:00

45 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalgic853 <yuu8583@proton.me>
Date: Mon, 24 Oct 2022 11:01:36 +0800
Subject: [PATCH] Skip entity move if no movement
Copyright (c) 2021-2022 ishland
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 d0b001ec4265dda8d130122c2e946ea07f9aa3ac..9a9d2e4cf955da26edc3b20d567294b2b2775ac4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -399,6 +399,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
private UUID originWorld;
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
public @Nullable Boolean immuneToFire = null; // Purpur - Fire immune API
+ private boolean boundingBoxChanged = false; // KeYi
public void setOrigin(@javax.annotation.Nonnull Location location) {
this.origin = location.toVector();
@@ -1036,6 +1037,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end - detailed watchdog information
public void move(MoverType movementType, Vec3 movement) {
+ // KeYi start
+ if (!boundingBoxChanged && movement.equals(Vec3.ZERO)) {
+ boundingBoxChanged = false;
+ return;
+ }
+ // KeYi end
+
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
synchronized (this.posLock) {
@@ -3797,6 +3805,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public final void setBoundingBox(AABB boundingBox) {
+ if (!this.bb.equals(boundingBox)) boundingBoxChanged = true; // KeYi
// CraftBukkit start - block invalid bounding boxes
double minX = boundingBox.minX,
minY = boundingBox.minY,