mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-24 17:03:51 -07:00
More moving around of hunks
This commit is contained in:
@@ -4,45 +4,48 @@ 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
|
||||
diff --git a/src/main/java/io/papermc/paper/FeatureHooks.java b/src/main/java/io/papermc/paper/FeatureHooks.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ 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()
|
||||
+ );
|
||||
--- a/src/main/java/io/papermc/paper/FeatureHooks.java
|
||||
+++ b/src/main/java/io/papermc/paper/FeatureHooks.java
|
||||
@@ -0,0 +0,0 @@ package io.papermc.paper;
|
||||
import io.papermc.paper.command.PaperSubcommand;
|
||||
import io.papermc.paper.command.subcommands.ChunkDebugCommand;
|
||||
import io.papermc.paper.command.subcommands.FixLightCommand;
|
||||
+import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
-import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSets;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
@@ -0,0 +0,0 @@ public final class FeatureHooks {
|
||||
}
|
||||
|
||||
@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 -> {
|
||||
public static Set<Long> getSentChunkKeys(final ServerPlayer player) {
|
||||
- final LongSet keys = new LongOpenHashSet();
|
||||
- player.getChunkTrackingView().forEach(pos -> keys.add(pos.longKey));
|
||||
- return LongSets.unmodifiable(keys);
|
||||
+ return LongSets.unmodifiable(player.moonrise$getChunkLoader().getSentChunksRaw().clone());
|
||||
}
|
||||
|
||||
public static Set<Chunk> getSentChunks(final ServerPlayer player) {
|
||||
- final ObjectSet<Chunk> chunks = new ObjectOpenHashSet<>();
|
||||
+ final LongOpenHashSet rawChunkKeys = player.moonrise$getChunkLoader().getSentChunksRaw();
|
||||
+ final ObjectSet<org.bukkit.Chunk> chunks = new ObjectOpenHashSet<>(rawChunkKeys.size());
|
||||
final World world = player.serverLevel().getWorld();
|
||||
- player.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);
|
||||
+ final LongIterator iter = player.moonrise$getChunkLoader().getSentChunksRaw().longIterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ chunks.add(world.getChunkAt(iter.nextLong(), false));
|
||||
+ }
|
||||
return 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);
|
||||
public static boolean isChunkSent(final ServerPlayer player, final long chunkKey) {
|
||||
- return player.getChunkTrackingView().contains(new ChunkPos(chunkKey));
|
||||
+ return player.moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user