From dcdb966994588e3ab55b2f52a49316b2017c6091 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Sun, 1 Dec 2024 01:24:33 -0300 Subject: [PATCH] Only attempt to resync display entities' position when it has actually changed to fix teleport interpolation issues On display entities, any new Pos/Rot packet causes the teleport duration interpolation to reset While this does not cause issues when you spawn a display entity -> set the interpolation -> teleport after the data has been sent to the client, this DOES cause issues on entities that have lived for >60 ticks, where if you spawn a display with interpolation -> wait ~8 ticks -> teleport it, the end of the teleport will look slow due to the server resyncing the display entity position/rotation --- .../server/0011-Optimize-canSee-checks.patch | 6 ++--- .../server/0023-Parallel-world-ticking.patch | 12 ++++----- ...to-be-exclusive-instead-of-inclusiv.patch} | 0 ...resync-display-entities-position-whe.patch | 27 +++++++++++++++++++ ...p-SparklyPower-hacky-legacy-NBT-tag.patch} | 0 ...0027-SPARKLYPOWER-Add-custom-blocks.patch} | 0 6 files changed, 36 insertions(+), 9 deletions(-) rename patches/server/{0026-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch => 0024-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch} (100%) create mode 100644 patches/server/0025-Only-attempt-to-resync-display-entities-position-whe.patch rename patches/server/{0024-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch => 0026-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch} (100%) rename patches/server/{0025-SPARKLYPOWER-Add-custom-blocks.patch => 0027-SPARKLYPOWER-Add-custom-blocks.patch} (100%) diff --git a/patches/server/0011-Optimize-canSee-checks.patch b/patches/server/0011-Optimize-canSee-checks.patch index c23236c..ea2103b 100644 --- a/patches/server/0011-Optimize-canSee-checks.patch +++ b/patches/server/0011-Optimize-canSee-checks.patch @@ -14,10 +14,10 @@ This seems stupid, but it does seem that it improves the performance a bit, and We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 5b3a886c624b36557cbfaccdc3fb05a46a4ba36a..f0fbc31f5acd49fa233e92d595060cf0382d7522 100644 +index 52a6a4badace15a983f0acb431036bd704d9cebd..7c19a4d11546bbcbf144feddee72733915bd3abd 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1295,7 +1295,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1289,7 +1289,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper end - Configurable entity tracking range by Y // CraftBukkit start - respect vanish API @@ -27,7 +27,7 @@ index 5b3a886c624b36557cbfaccdc3fb05a46a4ba36a..f0fbc31f5acd49fa233e92d595060cf0 } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7aa3ba20f63be469ec82637e79f864262e41f3c6..528eff25628242b8933e486e6871657277370dd0 100644 +index 554714e449d1d2439b05d7e15f72afccd17d4df5..405a65b52f5b4cd9a9a19e3e6369d98c39f306bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -205,7 +205,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/0023-Parallel-world-ticking.patch b/patches/server/0023-Parallel-world-ticking.patch index a2e2996..1a691f5 100644 --- a/patches/server/0023-Parallel-world-ticking.patch +++ b/patches/server/0023-Parallel-world-ticking.patch @@ -529,7 +529,7 @@ index 8f9fde5489c0e1d0a91203536caddec5a9c96f6c..84617a7d6fae4a67f07d50a8e9410e35 } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 5568bf6dabc01ca551eeae3305d67fc7554f5bc8..8d13504d3f93f724d0dc52db3fa27ce6a1479665 100644 +index fd5a0b0eaece1fcee3513df52f0c1ad420832af8..c9149c3b3da4589844ef721a62210b8b47227654 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -3,9 +3,6 @@ package net.minecraft.server; @@ -905,7 +905,7 @@ index e49e8e98ebbd3c8ba8a784f1626132699209b4e3..d952d42b8faee38f9d55fe578c030891 // SparklyPaper start - Spooky month optimizations halloweenManager.startHalloweenEpochTask(); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index be488eb582f15996921eab5d63bcc73655e61a0b..7bed72ff80fbb088edaf790419bce3929568b5b0 100644 +index 8de30b5dff3dc0e30f1a56303abcb31df8f85c9f..b3917c319c32eb9926418f788faf4adecf40a09a 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -200,7 +200,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1074,10 +1074,10 @@ index 30de3d1a7792c38ae946f19cb0e14637919b5001..0ea2d2b32aacdbfca80c0c626520bd86 entityplayer1.connection = entityplayer.connection; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ed5b00620527c1776722d25b1b45f1544802a341..8ef7f08488413737f8dbc9048d9aec57bb14fe99 100644 +index a15546e433ebba6c0de01bdaaef201a3d99a87b5..3e440c7ce88d7ebd50eba488c629bfa0bd0d242f 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -926,7 +926,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -882,7 +882,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // CraftBukkit start public void postTick() { // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle @@ -1086,7 +1086,7 @@ index ed5b00620527c1776722d25b1b45f1544802a341..8ef7f08488413737f8dbc9048d9aec57 this.handlePortal(); } } -@@ -4030,6 +4030,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3986,6 +3986,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } private Entity teleportCrossDimension(ServerLevel world, TeleportTransition teleportTarget) { @@ -1129,7 +1129,7 @@ index 33e7d2884195677c4d6340d8b84c1dd85c636ec1..02a719aaf7c860efbb51aed7d21cc83e world.capturedBlockStates.clear(); StructureGrowEvent structureEvent = null; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 97b31dffbaf965e86ad706a1bba7586cd3514ead..43ae7091a3603908eb6c68c8b10c72b0bbb99428 100644 +index 39d5633ae7cdb8609f5840de5ba26237d501d8a2..856aab98edbd67c68d33e529d0199c0506b11da8 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -175,6 +175,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl diff --git a/patches/server/0026-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch b/patches/server/0024-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch similarity index 100% rename from patches/server/0026-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch rename to patches/server/0024-Fix-getMaxHeight-to-be-exclusive-instead-of-inclusiv.patch diff --git a/patches/server/0025-Only-attempt-to-resync-display-entities-position-whe.patch b/patches/server/0025-Only-attempt-to-resync-display-entities-position-whe.patch new file mode 100644 index 0000000..d0821ac --- /dev/null +++ b/patches/server/0025-Only-attempt-to-resync-display-entities-position-whe.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Sun, 1 Dec 2024 01:12:50 -0300 +Subject: [PATCH] Only attempt to resync display entities' position when it has + actually changed to fix teleport interpolation issues + + +diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java +index ff5bf212e194dd0914c06e636a8268e8e8f6fff8..b09664593f6fc2392e2943cb84dbaee19e7f6d93 100644 +--- a/src/main/java/net/minecraft/server/level/ServerEntity.java ++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +@@ -221,6 +221,7 @@ public class ServerEntity { + + if (!this.forceStateResync && !flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker + if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) { ++ if (!(this.entity instanceof net.minecraft.world.entity.Display) || (flag || flag1)) { // SparklyPaper start - Only attempt to resync display entities' position when it has actually changed to fix teleport interpolation issues + if (flag2) { + packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround()); + flag3 = true; +@@ -228,6 +229,7 @@ public class ServerEntity { + packet1 = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), b0, b1, this.entity.onGround()); + flag4 = true; + } ++ } // SparklyPaper end + } else { + packet1 = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), b0, b1, this.entity.onGround()); + flag3 = true; diff --git a/patches/server/0024-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch b/patches/server/0026-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch similarity index 100% rename from patches/server/0024-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch rename to patches/server/0026-SPARKLYPOWER-Remap-SparklyPower-hacky-legacy-NBT-tag.patch diff --git a/patches/server/0025-SPARKLYPOWER-Add-custom-blocks.patch b/patches/server/0027-SPARKLYPOWER-Add-custom-blocks.patch similarity index 100% rename from patches/server/0025-SPARKLYPOWER-Add-custom-blocks.patch rename to patches/server/0027-SPARKLYPOWER-Add-custom-blocks.patch