mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Remove threadlocal buffer cache in ChunkDataPacket
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
399eb860a7
commit
d4e51f562c
@ -33,7 +33,6 @@ public class ChunkDataPacket implements ServerPacket {
|
||||
public Map<Integer, Block> entries = new HashMap<>();
|
||||
|
||||
private static final byte CHUNK_SECTION_COUNT = 16;
|
||||
private static final PacketUtils.LocalCache BLOCK_CACHE = PacketUtils.LocalCache.get("chunk-block-cache", 262_144);
|
||||
|
||||
/**
|
||||
* Heightmaps NBT, as read from raw packet data.
|
||||
@ -49,7 +48,7 @@ public class ChunkDataPacket implements ServerPacket {
|
||||
writer.writeInt(chunkX);
|
||||
writer.writeInt(chunkZ);
|
||||
|
||||
ByteBuffer blocks = BLOCK_CACHE.get();
|
||||
ByteBuffer blocks = PacketUtils.localBuffer();
|
||||
|
||||
Int2LongRBTreeMap maskMap = new Int2LongRBTreeMap();
|
||||
|
||||
|
@ -38,6 +38,12 @@ public final class PacketUtils {
|
||||
private PacketUtils() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@ApiStatus.Experimental
|
||||
public static ByteBuffer localBuffer() {
|
||||
return COMPRESSION_CACHE.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet to an audience. This method performs the following steps in the
|
||||
* following order:
|
||||
@ -200,7 +206,7 @@ public final class PacketUtils {
|
||||
@ApiStatus.Internal
|
||||
public static FramedPacket allocateTrimmedPacket(@NotNull ServerPacket packet) {
|
||||
final var temp = PacketUtils.createFramedPacket(packet);
|
||||
final var buffer= ByteBuffer.allocateDirect(temp.position()).put(temp.flip()).asReadOnlyBuffer();
|
||||
final var buffer = ByteBuffer.allocateDirect(temp.position()).put(temp.flip()).asReadOnlyBuffer();
|
||||
return new FramedPacket(packet.getId(), buffer, packet);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user