mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Reduce allocations for chunk packet writing
This commit is contained in:
parent
024f8d36bd
commit
af82bf1236
@ -33,7 +33,6 @@ public class ChunkDataPacket implements ServerPacket {
|
|||||||
public Map<Integer, Block> entries = new HashMap<>();
|
public Map<Integer, Block> entries = new HashMap<>();
|
||||||
|
|
||||||
private static final byte CHUNK_SECTION_COUNT = 16;
|
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.
|
* Heightmaps NBT, as read from raw packet data.
|
||||||
@ -49,7 +48,7 @@ public class ChunkDataPacket implements ServerPacket {
|
|||||||
writer.writeInt(chunkX);
|
writer.writeInt(chunkX);
|
||||||
writer.writeInt(chunkZ);
|
writer.writeInt(chunkZ);
|
||||||
|
|
||||||
ByteBuffer blocks = BLOCK_CACHE.get();
|
ByteBuffer blocks = PacketUtils.localBuffer();
|
||||||
|
|
||||||
Int2LongRBTreeMap maskMap = new Int2LongRBTreeMap();
|
Int2LongRBTreeMap maskMap = new Int2LongRBTreeMap();
|
||||||
|
|
||||||
|
@ -45,6 +45,12 @@ public final class PacketUtils {
|
|||||||
private 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
|
* Sends a packet to an audience. This method performs the following steps in the
|
||||||
* following order:
|
* following order:
|
||||||
|
Loading…
Reference in New Issue
Block a user