Improve entity high velocity fixes
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s

This commit is contained in:
2026-08-14 01:49:37 +08:00
parent 1537d45e4d
commit dfe2c124e6
9 changed files with 49 additions and 24 deletions
@@ -8,10 +8,10 @@ On folia, entity usually cannot move out of the tickregion, but sometimes it act
Reference from : https://github.com/KaiijuMC/Kaiiju/blob/ver/1.20.1/patches/server/0040-Teleport-async-if-we-cannot-move-entity-off-main.patch
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0..58054c571757eca2e86d53706bed7a2ce5259d6f 100644
index d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0..6e09efff84414d5507a639b6c14362f32b3c5416 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1164,6 +1164,19 @@ public abstract class Entity
@@ -1164,6 +1164,20 @@ public abstract class Entity
this.moveStartZ = this.getZ();
this.moveVector = delta;
}
@@ -22,15 +22,40 @@ index d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0..58054c571757eca2e86d53706bed7a2c
+ // not NaN (Prevent incorrect checks under NaN minecarts)
+ if (!Double.isNaN(finalPosition.x) && !Double.isNaN(finalPosition.y) && !Double.isNaN(finalPosition.z)) {
+ // kill tick passively if it's moving out of region and we'll catch this exception
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level,finalPosition)) {
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level, finalPosition)) {
+ throw new io.nanachiyo0721.shiroha.utils.entity.EntityMoveOutOfRegionException(this, delta, moverType);
+ }
+ }
+ }
+ // Guard delta too large at the initial input
+ // Shiroha end
try {
// Paper end - detailed watchdog information
if (this.noPhysics) {
@@ -1202,6 +1216,23 @@ public abstract class Entity
}
// Paper end
+ // Shiroha start - Fix high velocity moving issue
+ // Filter the threads as it may be called by the chunk system worker thread
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.FoliaEntityMovingFixConfig.enabled && ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()){
+ var finalPosition = delta.add(this.position);
+ // not NaN (Prevent incorrect checks under NaN minecarts)
+ if (!Double.isNaN(finalPosition.x) && !Double.isNaN(finalPosition.y) && !Double.isNaN(finalPosition.z)) {
+ // kill tick passively if it's moving out of region and we'll catch this exception
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level, finalPosition)) {
+ throw new io.nanachiyo0721.shiroha.utils.entity.EntityMoveOutOfRegionException(this, delta, moverType);
+ }
+ }
+ }
+ // Guard against delta too large when it was processed above
+ // note: following method call "maybeBackOffFromEdge" have indirect access to world data, so gurad is needed.
+ // We ignore to check the final delta movemnt after calling "colliding" as it's clamped at least unless the AABB of the entity is
+ // in a large scale, but it's never allowed and reasonable to have
+ // Shiroha end
delta = this.maybeBackOffFromEdge(delta, moverType);
Vec3 movement = this.collide(delta);
double movementLength = movement.lengthSqr();
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index a0eb1f608a99301e0197ab1d1a6fbbb0a0be4ce0..21b3fcba9e80082ad33a4331f27758cffef163f8 100644
--- a/net/minecraft/world/level/Level.java