From da1004744296426cca32c8e60ea48281967c40b0 Mon Sep 17 00:00:00 2001 From: wangxyper Date: Tue, 3 Oct 2023 18:04:37 +0800 Subject: [PATCH] Rework fix can not move entity off main --- ...005-Fix-can-not-move-entity-off-main.patch | 52 ++++++++----------- ...ce-entity-fluid-lookups-if-no-fluids.patch | 8 +-- ...Skip-entity-move-if-movement-is-zero.patch | 6 +-- .../0020-Leaves-Leaves-Server-Utils.patch | 8 +-- .../0024-Leaves-fakeplayer-support.patch | 4 +- .../0034-Gale-Optimize-sun-burn-tick.patch | 4 +- ...iju-Vanilla-end-portal-teleportation.patch | 8 +-- .../0042-Kaiiju-Unsafe-teleportation.patch | 4 +- .../server/0044-Pufferfish-Entity-TTL.patch | 4 +- 9 files changed, 44 insertions(+), 54 deletions(-) diff --git a/patches/server/0005-Fix-can-not-move-entity-off-main.patch b/patches/server/0005-Fix-can-not-move-entity-off-main.patch index a2dd0d3..50ff792 100644 --- a/patches/server/0005-Fix-can-not-move-entity-off-main.patch +++ b/patches/server/0005-Fix-can-not-move-entity-off-main.patch @@ -24,7 +24,7 @@ index d334b3aa4f311f57f2c41ced6c2265c817b78a76..92ad4c7105d5a5d8040d52c85d2274ab } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..8ed500a51d88e3267a1a8ea6a318dc9c92459bf3 100644 +index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..a428bea07b5a019b8c0d08cd6669407258d103fb 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -7,6 +7,7 @@ import com.google.common.collect.Lists; @@ -44,34 +44,24 @@ index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..8ed500a51d88e3267a1a8ea6a318dc9c import net.minecraft.BlockUtil; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; -@@ -1122,7 +1125,29 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - } - -- this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); -+ //Molia start - Fix can not move entity off main -+ var finalX = this.getX() + vec3d1.x; -+ var finalY = this.getY() + vec3d1.y; -+ var finalZ = this.getZ() + vec3d1.z; -+ -+ if (MoliaConfig.fixCanNotMoveEntityOffMain){ -+ if (TickThread.isTickThreadFor((ServerLevel) this.level,(int)finalX >> 4,(int)finalZ >> 4)){ -+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); -+ }else { -+ this.teleportAsync( -+ ((ServerLevel) this.level), -+ this.position().add(vec3d1), -+ this.getYRot(), -+ this.getXRot(), -+ null, -+ PlayerTeleportEvent.TeleportCause.UNKNOWN, -+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, null -+ ); -+ } -+ }else{ -+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); -+ } -+ //Molia end - } +@@ -767,6 +770,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + } - this.level().getProfiler().pop(); + public void setPos(double x, double y, double z) { ++ //Molia start - Teleport if the pos is in another region ++ if (MoliaConfig.fixCanNotMoveEntityOffMain && !TickThread.isTickThreadFor((ServerLevel) this.level,(int)x >> 4,(int)z >> 4)){ ++ this.teleportAsync( ++ ((ServerLevel) this.level), ++ new Vec3(x,y,z), ++ this.getYRot(), ++ this.getXRot(), ++ null, ++ PlayerTeleportEvent.TeleportCause.UNKNOWN, ++ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, null ++ ); ++ return; ++ } ++ //Molia end + this.setPosRaw(x, y, z, true); // Paper - force bounding box update + // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw + } diff --git a/patches/server/0016-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch b/patches/server/0016-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch index 712b99c..b21e15c 100644 --- a/patches/server/0016-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch +++ b/patches/server/0016-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Pufferfish Reduce entity fluid lookups if no fluids diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad 100644 +index 370f9ef44b0935e1ae3cb7ff341eb70f1caf1e92..e7b47944fc2ab66f27585a6f79c63f903bac8e0a 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -5106,16 +5106,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -5098,16 +5098,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -34,7 +34,7 @@ index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8 double d1 = 0.0D; boolean flag = this.isPushedByFluid(); boolean flag1 = false; -@@ -5123,14 +5125,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -5115,14 +5117,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); @@ -102,7 +102,7 @@ index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8 if (d2 >= axisalignedbb.minY) { flag1 = true; -@@ -5152,9 +5201,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -5144,9 +5193,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit end } } diff --git a/patches/server/0017-Gale-Skip-entity-move-if-movement-is-zero.patch b/patches/server/0017-Gale-Skip-entity-move-if-movement-is-zero.patch index d059eff..4248365 100644 --- a/patches/server/0017-Gale-Skip-entity-move-if-movement-is-zero.patch +++ b/patches/server/0017-Gale-Skip-entity-move-if-movement-is-zero.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Gale Skip entity move if movement is zero diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b54615029 100644 +index e7b47944fc2ab66f27585a6f79c63f903bac8e0a..66d257c3ff9501c41c6bcdf6c2070230198036bd 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -16,7 +16,7 @@ index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b public boolean onGround; public boolean horizontalCollision; public boolean verticalCollision; -@@ -1080,6 +1081,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1094,6 +1095,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // Paper end - detailed watchdog information public void move(MoverType movementType, Vec3 movement) { @@ -28,7 +28,7 @@ index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b // Paper start - detailed watchdog information io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); synchronized (this.posLock) { -@@ -4790,6 +4796,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4782,6 +4788,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public final void setBoundingBox(AABB boundingBox) { diff --git a/patches/server/0020-Leaves-Leaves-Server-Utils.patch b/patches/server/0020-Leaves-Leaves-Server-Utils.patch index 284ae91..6f844ec 100644 --- a/patches/server/0020-Leaves-Leaves-Server-Utils.patch +++ b/patches/server/0020-Leaves-Leaves-Server-Utils.patch @@ -31,7 +31,7 @@ index 46954db7ecd35ac4018fdf476df7c8020d7ce6c8..044c51ebb058fc36074fd178929e3279 public PlayerAreaMap() { super(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa9fd8c980 100644 +index 66d257c3ff9501c41c6bcdf6c2070230198036bd..8a2fd5aba5200dd7e78138f4860f8861bed40105 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -500,6 +500,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -43,7 +43,7 @@ index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa public net.minecraft.server.level.FullChunkStatus chunkStatus; public int sectionX = Integer.MIN_VALUE; -@@ -2479,6 +2481,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2471,6 +2473,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { nbt.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -51,7 +51,7 @@ index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa return nbt; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2647,6 +2650,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2639,6 +2642,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { freezeLocked = nbt.getBoolean("Paper.FreezeLock"); } // Paper end @@ -63,7 +63,7 @@ index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); -@@ -2661,6 +2669,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2653,6 +2661,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return true; } diff --git a/patches/server/0024-Leaves-fakeplayer-support.patch b/patches/server/0024-Leaves-fakeplayer-support.patch index d3098fe..f26507d 100644 --- a/patches/server/0024-Leaves-fakeplayer-support.patch +++ b/patches/server/0024-Leaves-fakeplayer-support.patch @@ -324,10 +324,10 @@ index 4f7a9a4ca030c8349a684080b44547f66ed0d2d7..ec3b14457146d1fa18a475e94114d029 + // Leaves end - fakeplayer support } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 4bad93036bf7d18785bed9dab3a615fa9fd8c980..9bc9bae8faea19bb065850a91ea67efef6901da2 100644 +index 8a2fd5aba5200dd7e78138f4860f8861bed40105..bbc4adf6e71b7ae2f8a5f46dff8f2183ca538617 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1486,7 +1486,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1478,7 +1478,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return offsetFactor; } diff --git a/patches/server/0034-Gale-Optimize-sun-burn-tick.patch b/patches/server/0034-Gale-Optimize-sun-burn-tick.patch index 69eb064..daa361d 100644 --- a/patches/server/0034-Gale-Optimize-sun-burn-tick.patch +++ b/patches/server/0034-Gale-Optimize-sun-burn-tick.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Gale Optimize sun burn tick diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 9bc9bae8faea19bb065850a91ea67efef6901da2..89544a19d0ce49ed5dc32823ecb249c4ddf2d08f 100644 +index bbc4adf6e71b7ae2f8a5f46dff8f2183ca538617..39fac1d0da5e0e43e9257ce1526229f9cf4ffe83 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -17,7 +17,7 @@ index 9bc9bae8faea19bb065850a91ea67efef6901da2..89544a19d0ce49ed5dc32823ecb249c4 public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public private ChunkPos chunkPosition; private Vec3 deltaMovement; -@@ -2035,9 +2035,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2027,9 +2027,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { /** @deprecated */ @Deprecated public float getLightLevelDependentMagicValue() { diff --git a/patches/server/0039-Kaiiju-Vanilla-end-portal-teleportation.patch b/patches/server/0039-Kaiiju-Vanilla-end-portal-teleportation.patch index fbc409a..77a44eb 100644 --- a/patches/server/0039-Kaiiju-Vanilla-end-portal-teleportation.patch +++ b/patches/server/0039-Kaiiju-Vanilla-end-portal-teleportation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Vanilla end portal teleportation diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904459491b4 100644 +index 39fac1d0da5e0e43e9257ce1526229f9cf4ffe83..b6b4e9c3ece0e8357f470d3d7ab4ee637fd1635b 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4082,12 +4082,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4074,12 +4074,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { targetPos, 16, // load 16 blocks to be safe from block physics ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH, (chunks) -> { @@ -28,7 +28,7 @@ index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904 ); } ); -@@ -4274,6 +4279,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4266,6 +4271,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (!this.canPortalAsync(takePassengers)) { return false; } @@ -39,7 +39,7 @@ index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904 Vec3 initialPosition = this.position(); ChunkPos initialPositionChunk = new ChunkPos( -@@ -4332,7 +4341,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4324,7 +4333,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // place passengerTree.root.placeInAsync( originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L), diff --git a/patches/server/0042-Kaiiju-Unsafe-teleportation.patch b/patches/server/0042-Kaiiju-Unsafe-teleportation.patch index ff1d59d..fd2fe36 100644 --- a/patches/server/0042-Kaiiju-Unsafe-teleportation.patch +++ b/patches/server/0042-Kaiiju-Unsafe-teleportation.patch @@ -25,7 +25,7 @@ index 405bc9c2ea13e8b70c70f52c1fc81336b4dd432e..e95a14cec8a6c276adbf787c4af850db breakRedstoneOnTripDoorEarly = getBoolean("fixes.break_redstone_early_on_tripdoor",breakRedstoneOnTripDoorEarly); allowVoidTrading = getBoolean("fixes.allow_void_trading",allowVoidTrading); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 391369b487a092677b0f1e072738c904459491b4..1fbf7a09556b1dd60c63c21c7005415a6d2310c0 100644 +index b6b4e9c3ece0e8357f470d3d7ab4ee637fd1635b..1de6570188d28e53cb81188f05274416bcb8dfad 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -60,7 +60,6 @@ import net.minecraft.network.syncher.EntityDataSerializers; @@ -36,7 +36,7 @@ index 391369b487a092677b0f1e072738c904459491b4..1fbf7a09556b1dd60c63c21c7005415a import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -@@ -3997,6 +3996,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3989,6 +3988,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { protected boolean tryEndPortal() { io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async"); diff --git a/patches/server/0044-Pufferfish-Entity-TTL.patch b/patches/server/0044-Pufferfish-Entity-TTL.patch index 6a3b501..1e219b7 100644 --- a/patches/server/0044-Pufferfish-Entity-TTL.patch +++ b/patches/server/0044-Pufferfish-Entity-TTL.patch @@ -51,10 +51,10 @@ index 4f73701bb810f456146714c8ff67ff9ec423f79b..cde3d3b0cf541cace5c3afeb1467c5cb fakeplayerSupport = getBoolean("gameplay.leaves.fakeplayer.enabled",fakeplayerSupport); fakeplayerLimit = getInt("gameplay.leaves.fakeplayer.fake_player_limit",fakeplayerLimit); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f34a79f573bd473f6a23a953d9022ff0693ab80e..d4f65c32f747a15dbad3a430c87b1377f3e08efa 100644 +index 75d3ac95eaca5f29e020675af8d5f61a925202b4..03ced7057d0a39c0ddd2d623aefcd58e315b5c90 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -811,6 +811,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -825,6 +825,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void tick() {