Add back more optimization patches
This commit is contained in:
parent
04dad71064
commit
0008fa17e9
24 changed files with 54 additions and 103 deletions
61
patches/server/1014-API-for-checking-sent-chunks.patch
Normal file
61
patches/server/1014-API-for-checking-sent-chunks.patch
Normal file
|
@ -0,0 +1,61 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Flo0 <flo.roma@web.de>
|
||||
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 dba09cb32844533c383635e7623f5180a468f636..a88c7113652b268c0fdc355710b00f452f9b5431 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
|
||||
@@ -1055,5 +1055,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 ecd975855d92ae5948ee926f42396cb004843aed..c868abef790aa80863721490f69087343aba13e7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -3483,6 +3483,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;
|
Loading…
Add table
Add a link
Reference in a new issue