diff --git a/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java index 8373dae03..c50f39d19 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java @@ -24,7 +24,7 @@ public record MultiBlockChangePacket(long chunkSectionPosition, public void write(@NotNull BinaryWriter writer) { writer.writeLong(chunkSectionPosition); writer.writeBoolean(suppressLightUpdates); - writer.writeLongArray(blocks); + writer.writeVarLongArray(blocks); } @Override diff --git a/src/main/java/net/minestom/server/utils/binary/BinaryWriter.java b/src/main/java/net/minestom/server/utils/binary/BinaryWriter.java index 4462370a5..2642b3cad 100644 --- a/src/main/java/net/minestom/server/utils/binary/BinaryWriter.java +++ b/src/main/java/net/minestom/server/utils/binary/BinaryWriter.java @@ -221,6 +221,17 @@ public class BinaryWriter extends OutputStream { } } + public void writeVarLongArray(long[] array) { + if (array == null) { + writeVarInt(0); + return; + } + writeVarInt(array.length); + for (long element : array) { + writeVarLong(element); + } + } + public void writeLongArray(long[] array) { if (array == null) { writeVarInt(0);