Add feature patch hook for overrides

This commit is contained in:
Nassim Jahnke
2024-12-05 13:00:22 +01:00
parent 193eebecdf
commit 2a20fde332
9 changed files with 110 additions and 21 deletions

View File

@@ -6,6 +6,7 @@ import com.google.common.io.BaseEncoding;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import io.netty.buffer.Unpooled;
import io.papermc.paper.FeatureHooks;
import it.unimi.dsi.fastutil.shorts.ShortArraySet;
import it.unimi.dsi.fastutil.shorts.ShortSet;
import java.io.ByteArrayOutputStream;
@@ -3489,27 +3490,19 @@ 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 FeatureHooks.getSentChunkKeys(this.getHandle());
}
@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 org.bukkit.World world = this.getWorld();
this.getHandle().getChunkTrackingView().forEach(pos -> {
final org.bukkit.Chunk chunk = world.getChunkAt(pos.longKey);
chunks.add(chunk);
});
return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks);
return FeatureHooks.getSentChunks(this.getHandle());
}
@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 FeatureHooks.isChunkSent(this.getHandle(), chunkKey);
}
// Paper end