Fix MultiBlockChangePacket read

This commit is contained in:
themode 2021-12-28 16:33:59 +01:00 committed by TheMode
parent 48b262fee7
commit 91a8607710
3 changed files with 12 additions and 1 deletions

View File

@ -17,7 +17,7 @@ public record MultiBlockChangePacket(long chunkSectionPosition,
}
public MultiBlockChangePacket(BinaryReader reader) {
this(reader.readLong(), reader.readBoolean(), reader.readLongArray());
this(reader.readLong(), reader.readBoolean(), reader.readVarLongArray());
}
@Override

View File

@ -153,6 +153,15 @@ public class BinaryReader extends InputStream {
return array;
}
public long[] readVarLongArray() {
final int size = readVarInt();
long[] array = new long[size];
for (int i = 0; i < size; i++) {
array[i] = readVarLong();
}
return array;
}
public long[] readLongArray() {
final int size = readVarInt();
long[] array = new long[size];

View File

@ -106,6 +106,8 @@ public class PacketWriteReadTest {
SERVER_PACKETS.add(new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER,
new PlayerInfoPacket.AddPlayer(UUID.randomUUID(), "TheMode911", List.of(new PlayerInfoPacket.AddPlayer.Property("name", "value")), GameMode.CREATIVE, 5, COMPONENT)));
SERVER_PACKETS.add(new PlayerInfoPacket(PlayerInfoPacket.Action.REMOVE_PLAYER, new PlayerInfoPacket.RemovePlayer(UUID.randomUUID())));
//SERVER_PACKETS.add(new MultiBlockChangePacket(5,5,5,true, new long[]{0,5,543534,1321}));
}
@BeforeAll