diff options
author | Jake Potrebic <[email protected]> | 2024-07-16 16:39:57 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-16 16:39:57 -0700 |
commit | 506f1651e549c290142df8d1e2e8ea831bc381c0 (patch) | |
tree | 250f8cb16a8e94a588aa9df694e199f3e45ae824 /patches/server/1016-API-for-checking-sent-chunks.patch | |
parent | a6ceda12c54cd8b7d272fe50e744c9b9a26d0838 (diff) | |
download | Paper-506f1651e549c290142df8d1e2e8ea831bc381c0.tar.gz Paper-506f1651e549c290142df8d1e2e8ea831bc381c0.zip |
Don't store removed components in multiple places (#11091)
Diffstat (limited to 'patches/server/1016-API-for-checking-sent-chunks.patch')
-rw-r--r-- | patches/server/1016-API-for-checking-sent-chunks.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/patches/server/1016-API-for-checking-sent-chunks.patch b/patches/server/1016-API-for-checking-sent-chunks.patch new file mode 100644 index 0000000000..5129c9a08a --- /dev/null +++ b/patches/server/1016-API-for-checking-sent-chunks.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Flo0 <[email protected]> +Date: Mon, 8 Apr 2024 16:43:16 +0200 +Subject: [PATCH] API for checking sent chunks + + +diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +index f063ab3ff122b920bcc4aa4f5bf9a442a8eb32fd..95d2d4417591b921d1ddf73025565cff6aabddd7 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java ++++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +@@ -1072,5 +1072,10 @@ public final class RegionizedPlayerChunkLoader { + + // now all tickets should be removed, which is all of our external state + } ++ ++ // For external checks ++ public it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunksRaw() { ++ return this.sentChunks; ++ } + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 62bfde27a182be24710eb3b72448e82da58afc8f..d01b45a48d412e3cb591acee101730704574448a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -3484,6 +3484,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + // Paper end + ++ // Paper start - Add chunk view API ++ @Override ++ public Set<java.lang.Long> getSentChunkKeys() { ++ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); ++ return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable( ++ this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().clone() ++ ); ++ } ++ ++ @Override ++ public Set<org.bukkit.Chunk> getSentChunks() { ++ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); ++ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw(); ++ final it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<org.bukkit.Chunk> chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(rawChunkKeys.size()); ++ final org.bukkit.World world = this.getWorld(); ++ ++ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().longIterator(); ++ while (iter.hasNext()) chunks.add(world.getChunkAt(iter.nextLong(), false)); ++ ++ return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks); ++ } ++ ++ @Override ++ public boolean isChunkSent(final long chunkKey) { ++ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); ++ return this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey); ++ } ++ // Paper end ++ + public Player.Spigot spigot() + { + return this.spigot; |