Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Don't read remaining bytes in 1.18 chunk type
Dieser Commit ist enthalten in:
Ursprung
111cd2fd46
Commit
c5e27b89af
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk1_18;
|
||||
@ -47,12 +46,15 @@ public final class Chunk1_18Type extends Type<Chunk> {
|
||||
final int chunkZ = buffer.readInt();
|
||||
final CompoundTag heightMap = Type.NBT.read(buffer);
|
||||
|
||||
Type.VAR_INT.readPrimitive(buffer); // Data size in bytes
|
||||
|
||||
// Read sections
|
||||
final ByteBuf sectionsBuf = buffer.readBytes(Type.VAR_INT.readPrimitive(buffer));
|
||||
final ChunkSection[] sections = new ChunkSection[ySectionCount];
|
||||
for (int i = 0; i < ySectionCount; i++) {
|
||||
sections[i] = Types1_18.CHUNK_SECTION.read(buffer);
|
||||
try {
|
||||
for (int i = 0; i < ySectionCount; i++) {
|
||||
sections[i] = Types1_18.CHUNK_SECTION.read(sectionsBuf);
|
||||
}
|
||||
} finally {
|
||||
sectionsBuf.release();
|
||||
}
|
||||
|
||||
final int blockEntitiesLength = Type.VAR_INT.readPrimitive(buffer);
|
||||
@ -61,14 +63,6 @@ public final class Chunk1_18Type extends Type<Chunk> {
|
||||
blockEntities.add(Types1_18.BLOCK_ENTITY.read(buffer));
|
||||
}
|
||||
|
||||
// Read all the remaining bytes (workaround for #681)
|
||||
if (buffer.readableBytes() > 0) {
|
||||
final byte[] array = Type.REMAINING_BYTES.read(buffer);
|
||||
if (Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
return new Chunk1_18(chunkX, chunkZ, sections, heightMap, blockEntities);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren