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
@@ -30,10 +30,10 @@ index ea93ac07ec6d4e83d1d0904daf721132e2bbecc3..947413df55b972a5f866d5717fdb9e92
public static class IntBounds {
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 58054c571757eca2e86d53706bed7a2ce5259d6f..f97c1aa936d1a9b1ea80b701b279b24553d0ecd2 100644
index 6e09efff84414d5507a639b6c14362f32b3c5416..dbf449e258bcd66d0182f003e029bde3b58558cc 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4725,7 +4725,7 @@ public abstract class Entity
@@ -4743,7 +4743,7 @@ public abstract class Entity
portalInfoCompletable.complete(
new TeleportTransition(destination, Vec3.atCenterOf(targetPos), Vec3.ZERO,
90.0f, 0.0f,
@@ -42,7 +42,7 @@ index 58054c571757eca2e86d53706bed7a2ce5259d6f..f97c1aa936d1a9b1ea80b701b279b245
);
return;
}
@@ -4737,7 +4737,7 @@ public abstract class Entity
@@ -4755,7 +4755,7 @@ public abstract class Entity
portalInfoCompletable.complete(
net.minecraft.world.level.block.NetherPortalBlock.createDimensionTransition(
destination, portal, originalPortalDirection, relativePos,
@@ -25,10 +25,10 @@ index 9933e59dfebf5d731ea73585c2b08f9e4ff42d53..01a93a747d2fec6248909165bd450833
// Folia start - region threading
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index f97c1aa936d1a9b1ea80b701b279b24553d0ecd2..98ce2b377e125c1de123a406c3978f495c5023db 100644
index dbf449e258bcd66d0182f003e029bde3b58558cc..34dff91f9694b6a884bac2039891d05fdec7c12c 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4744,10 +4744,10 @@ public abstract class Entity
@@ -4762,10 +4762,10 @@ public abstract class Entity
);
// kick off search for existing portal or creation
@@ -8,10 +8,10 @@ As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2e
Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE)
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 98ce2b377e125c1de123a406c3978f495c5023db..9ed6850abef3afed5694f4862c18b39fbb97d3f2 100644
index 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269470670af 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4642,15 +4642,19 @@ public abstract class Entity
@@ -4660,15 +4660,19 @@ public abstract class Entity
targetPos, 16, // load 16 blocks to be safe from block physics
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
(chunks) -> {
@@ -35,7 +35,7 @@ index 98ce2b377e125c1de123a406c3978f495c5023db..9ed6850abef3afed5694f4862c18b39f
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
@@ -4666,13 +4670,17 @@ public abstract class Entity
@@ -4684,13 +4688,17 @@ public abstract class Entity
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
(chunks) -> {
BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos);
@@ -56,7 +56,7 @@ index 98ce2b377e125c1de123a406c3978f495c5023db..9ed6850abef3afed5694f4862c18b39f
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
@@ -4851,6 +4859,10 @@ public abstract class Entity
@@ -4869,6 +4877,10 @@ public abstract class Entity
return false;
}
@@ -67,7 +67,7 @@ index 98ce2b377e125c1de123a406c3978f495c5023db..9ed6850abef3afed5694f4862c18b39f
Vec3 initialPosition = this.position();
ChunkPos initialPositionChunk = new ChunkPos(
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition),
@@ -4914,9 +4926,14 @@ public abstract class Entity
@@ -4932,9 +4944,14 @@ public abstract class Entity
info.postTeleportTransition().onTransition(teleported);
}
@@ -171,10 +171,10 @@ index f03fa06c0ba56f7f5e1e45bc1568a490751efde3..eee1c14249addbf4714df733870da974
+ // KioCG end
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 9ed6850abef3afed5694f4862c18b39fbb97d3f2..66593eb947035bd9489c4d31a0e9156c1c81b464 100644
index 453261efff85beec55fb0f9796be0269470670af..b22211aaa7c2ec9b96a6de6d84200593b838cecc 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -6439,4 +6439,6 @@ public abstract class Entity
@@ -6457,4 +6457,6 @@ public abstract class Entity
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
}
// Paper end
@@ -240,7 +240,7 @@ index 6e08d50794c4af4405f3e164a3fd46f376b3f78f..dd2d0940eece3e85078e574f66f71a4c
int getContainerSize();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 66593eb947035bd9489c4d31a0e9156c1c81b464..280d6ff1fcbfb74d194a8ade94c2af02fe2cd41b 100644
index b22211aaa7c2ec9b96a6de6d84200593b838cecc..b339904e8894774321c322f15842a41ede87ee4e 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -324,7 +324,7 @@ public abstract class Entity
@@ -252,7 +252,7 @@ index 66593eb947035bd9489c4d31a0e9156c1c81b464..280d6ff1fcbfb74d194a8ade94c2af02
private final VecDeltaCodec packetPositionCodec = new VecDeltaCodec();
public boolean needsSync;
public boolean syncPosition;
@@ -4469,11 +4469,13 @@ public abstract class Entity
@@ -4487,11 +4487,13 @@ public abstract class Entity
}
protected Entity transformForAsyncTeleport(ServerLevel destination, Vec3 pos, Float yaw, Float pitch, Vec3 velocity) {
@@ -266,7 +266,7 @@ index 66593eb947035bd9489c4d31a0e9156c1c81b464..280d6ff1fcbfb74d194a8ade94c2af02
if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
// for example, clearing of inventory after switching dimensions
@@ -6040,8 +6042,29 @@ public abstract class Entity
@@ -6058,8 +6060,29 @@ public abstract class Entity
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end - Block invalid positions and bounding box
@@ -10,7 +10,7 @@ VMP (https://github.com/RelativityMC/VMP-fabric)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 280d6ff1fcbfb74d194a8ade94c2af02fe2cd41b..ccd7cfb1db04628adda7346ee7f1825c15f70afd 100644
index b339904e8894774321c322f15842a41ede87ee4e..bf55500a27000b22de7e17bf31993d698945bbef 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1153,8 +1153,14 @@ public abstract class Entity
@@ -28,7 +28,7 @@ index 280d6ff1fcbfb74d194a8ade94c2af02fe2cd41b..ccd7cfb1db04628adda7346ee7f1825c
final Vec3 originalMovement = delta; // Paper - Expose pre-collision velocity
// Paper start - detailed watchdog information
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
@@ -5534,6 +5540,11 @@ public abstract class Entity
@@ -5552,6 +5558,11 @@ public abstract class Entity
}
public final void setBoundingBox(final AABB bb) {
@@ -20,10 +20,10 @@ As part of: Akarin (https://github.com/Akarin-project/Akarin)
Licensed under: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index ccd7cfb1db04628adda7346ee7f1825c15f70afd..8c0f34566f04fdf4d8b595250d7ea52cbd62b7c9 100644
index bf55500a27000b22de7e17bf31993d698945bbef..4f863e68fb2323a442f868a2531a9eda816a2555 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -2439,8 +2439,8 @@ public abstract class Entity
@@ -2457,8 +2457,8 @@ public abstract class Entity
}
public void push(final Entity entity) {
@@ -7,10 +7,10 @@ License: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://github.com/GaleMC/Gale
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 8c0f34566f04fdf4d8b595250d7ea52cbd62b7c9..18087b6f3f3152c1a9699985e28209a9231e57cd 100644
index 4f863e68fb2323a442f868a2531a9eda816a2555..ecd17c6bdf9668842879aa687505afc7c7430dad 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1300,8 +1300,17 @@ public abstract class Entity
@@ -1318,8 +1318,17 @@ public abstract class Entity
}
}