aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1071-Implement-chunk-view-API.patch
blob: b324cf7b6e4ad3db91e10fbe17ef8a4dd30d8b3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Flo0 <flo.roma@web.de>
Date: Thu, 5 Dec 2024 12:15:07 +0100
Subject: [PATCH] Implement chunk view API


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 4365fd116767b9aba8759d8b3083995fd0c460de..84c494ca81b8f58604b372ac7236147776817a4f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3489,27 +3489,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
     @Override
     public Set<java.lang.Long> getSentChunkKeys() {
         org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
-        final it.unimi.dsi.fastutil.longs.LongOpenHashSet keys = new it.unimi.dsi.fastutil.longs.LongOpenHashSet();
-        this.getHandle().getChunkTrackingView().forEach(pos -> keys.add(pos.longKey));
-        return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable(keys);
+        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.objects.ObjectOpenHashSet<org.bukkit.Chunk> chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>();
+        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();
-        this.getHandle().getChunkTrackingView().forEach(pos -> {
-            final org.bukkit.Chunk chunk = world.getChunkAt(pos.longKey);
-            chunks.add(chunk);
-        });
+
+        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().getChunkTrackingView().contains(new net.minecraft.world.level.ChunkPos(chunkKey));
+        return this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey);
     }
     // Paper end