From 1fcc4162d11613d1a0ceff0657e966aa0a6ec3d3 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 17 Jun 2025 17:47:50 -0700 Subject: [PATCH] Implement FeatureHooks#isChunkSent for Moonrise chunk system Need to use the player chunk loader, as that will contain the sent chunks. --- .../0016-Moonrise-optimisation-patches.patch | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch index cdcf6022e2b..ad230d1686d 100644 --- a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch @@ -22986,7 +22986,7 @@ index 0000000000000000000000000000000000000000..f1f72a051083b61273202cb4e67ecb11 + private SaveUtil() {} +} diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda670a6811b 100644 +index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..766671824c7ea0dc0fe7b70de4148155cd6125aa 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -1,6 +1,9 @@ @@ -23012,7 +23012,7 @@ index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda6 } public static LevelChunkSection createSection(final Registry biomeRegistry, final Level level, final ChunkPos chunkPos, final int chunkSection) { -@@ -59,18 +65,19 @@ public final class FeatureHooks { +@@ -59,111 +65,58 @@ public final class FeatureHooks { } public static Set getSentChunkKeys(final ServerPlayer player) { @@ -23025,6 +23025,9 @@ index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda6 public static Set getSentChunks(final ServerPlayer player) { - final ObjectSet chunks = new ObjectOpenHashSet<>(); + // Paper start - rewrite chunk system ++ if (player.moonrise$getChunkLoader() == null) { ++ return ObjectSets.EMPTY_SET; ++ } + final LongOpenHashSet rawChunkKeys = player.moonrise$getChunkLoader().getSentChunksRaw(); + final ObjectSet chunks = new ObjectOpenHashSet<>(rawChunkKeys.size()); final World world = player.level().getWorld(); @@ -23040,7 +23043,11 @@ index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda6 return ObjectSets.unmodifiable(chunks); } -@@ -79,91 +86,32 @@ public final class FeatureHooks { + public static boolean isChunkSent(final ServerPlayer player, final long chunkKey) { +- return player.getChunkTrackingView().contains(new ChunkPos(chunkKey)); ++ // Paper start - rewrite chunk system ++ return player.moonrise$getChunkLoader() != null && player.moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey); ++ // Paper end - rewrite chunk system } public static boolean isSpiderCollidingWithWorldBorder(final Spider spider) { @@ -23138,7 +23145,7 @@ index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda6 org.bukkit.Chunk chunk = null; for (net.minecraft.server.level.Ticket ticket : tickets) { -@@ -183,15 +131,15 @@ public final class FeatureHooks { +@@ -183,15 +136,15 @@ public final class FeatureHooks { } public static int getViewDistance(net.minecraft.server.level.ServerLevel world) { @@ -23157,7 +23164,7 @@ index 0a80ab83ca69b8b51fb1bb8c12ee6fcf439a3ac4..a42a773503ca0e0dc36dd44440b3eda6 } public static void setViewDistance(net.minecraft.server.level.ServerLevel world, int distance) { -@@ -209,35 +157,31 @@ public final class FeatureHooks { +@@ -209,35 +162,31 @@ public final class FeatureHooks { } public static void setSendViewDistance(net.minecraft.server.level.ServerLevel world, int distance) {