From c2245f39157d92b5cdd7743418bc3cc6d4d1e01c Mon Sep 17 00:00:00 2001 From: themode Date: Thu, 30 Dec 2021 11:27:07 +0100 Subject: [PATCH] Use local buffer to create chunks array --- src/main/java/net/minestom/server/instance/DynamicChunk.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java index 244d59e57..9d368732a 100644 --- a/src/main/java/net/minestom/server/instance/DynamicChunk.java +++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java @@ -15,6 +15,7 @@ import net.minestom.server.network.packet.server.play.UpdateLightPacket; import net.minestom.server.network.packet.server.play.data.ChunkData; import net.minestom.server.network.packet.server.play.data.LightData; import net.minestom.server.utils.MathUtils; +import net.minestom.server.utils.PacketUtils; import net.minestom.server.utils.Utils; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.chunk.ChunkUtils; @@ -196,7 +197,7 @@ public class DynamicChunk extends Chunk { "WORLD_SURFACE", NBT.LongArray(Utils.encodeBlocks(worldSurface, bitsForHeight)))); } // Data - final BinaryWriter writer = new BinaryWriter(); + final BinaryWriter writer = new BinaryWriter(PacketUtils.localBuffer()); for (Section section : sections) writer.write(section); return new ChunkDataPacket(chunkX, chunkZ, new ChunkData(heightmapsNBT, writer.toByteArray(), entries),