44 lines
2.9 KiB
Diff
44 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <mrhua269@gmail.com>
|
|
Date: Thu, 24 Apr 2025 23:11:13 +0800
|
|
Subject: [PATCH] Fix off tickregion sync teleport
|
|
|
|
Folis's teleportAsync implementation has some checks missing during the sync teleportation checks, if we are teleport to the edge of the tickregion, it is still asserting that we are in the same tickregion and moved us directly, but there is actually some logics is already touching the stuff out of current tickregion.So we added some new edge checks to the sync teleportation checks which will check the tickregion belonging in a shape of cycle which is in min(entity's bounding box + simulate distance, 6) of radius to fix that issue
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 4026d465687604965f105ded21a8206fd52bd375..771744d4540fcd163efcde43c27111680b25c928 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4060,6 +4060,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.resetStoredPositions();
|
|
}
|
|
|
|
+ // Luminol start - Fix sync teleport issue
|
|
+ private boolean checkNearbyTickRegions(int destX, int destZ) {
|
|
+ // Dumb end gateway search the chunks in radius of 5 chunks, so we need keep 6(5+1) by default check radius
|
|
+ int sizeBx = Math.min(6, (int) (this.bb.maxX - this.bb.minX) + this.level.getCraftServer().getSimulationDistance());
|
|
+ int sizeBz = Math.min(6, (int) (this.bb.maxZ - this.bb.minZ) + this.level.getCraftServer().getSimulationDistance());
|
|
+
|
|
+ // check tick thread around these area
|
|
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level,
|
|
+ (destX >> 4) - sizeBx,
|
|
+ (destZ >> 4) - sizeBz,
|
|
+ (destX >> 4) + sizeBx,
|
|
+ (destZ >> 4) + sizeBz);
|
|
+ }
|
|
+ // Luminol end
|
|
+
|
|
protected final void transform(TeleportTransition telpeort) {
|
|
PositionMoveRotation move = PositionMoveRotation.calculateAbsolute(
|
|
PositionMoveRotation.of(this), PositionMoveRotation.of(telpeort), telpeort.relatives()
|
|
@@ -4157,7 +4172,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
// check for same region
|
|
if (destination == this.level()) {
|
|
Vec3 currPos = this.position();
|
|
- if (
|
|
+ // Luminol - Prevent entity sync teleported to the edge of tickregion
|
|
+ if (this.checkNearbyTickRegions((int) pos.x, (int) pos.z) && // Luminol - Fix sync teleport issue
|
|
destination.regioniser.getRegionAtUnsynchronised(
|
|
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(currPos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(currPos)
|
|
) == destination.regioniser.getRegionAtUnsynchronised(
|