mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 20:16:02 +01:00
convert height maps, fix 1.16 chunk reading
This commit is contained in:
parent
e22bba0360
commit
b80902ec10
@ -34,7 +34,8 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
// Read blocks
|
||||
long[] blockData = new long[Type.VAR_INT.read(buffer)];
|
||||
if (blockData.length > 0) {
|
||||
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
||||
char valuesPerLong = (char) (64 / bitsPerBlock);
|
||||
int expectedLength = (ChunkSection.SIZE + valuesPerLong - 1) / valuesPerLong;
|
||||
if (blockData.length != expectedLength) {
|
||||
throw new IllegalStateException("Block data length (" + blockData.length + ") does not match expected length (" + expectedLength + ")! bitsPerBlock=" + bitsPerBlock + ", originalBitsPerBlock=" + originalBitsPerBlock);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
@ -16,6 +17,7 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -82,6 +84,14 @@ public class WorldPackets {
|
||||
blockEntity.put(skullOwnerTag);
|
||||
}
|
||||
}
|
||||
|
||||
CompoundTag heightMaps = chunk.getHeightMap();
|
||||
for (String key : heightMaps.keySet()) {
|
||||
LongArrayTag heightMap = heightMaps.get(key);
|
||||
int[] heightMapData = new int[256];
|
||||
CompactArrayUtil.iterateCompactArray(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
|
||||
heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ public class CompactArrayUtil {
|
||||
long divideMul = Integer.toUnsignedLong(MAGIC[magicIndex]);
|
||||
long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
|
||||
int divideShift = MAGIC[magicIndex + 2];
|
||||
int size = (4096 + valuesPerLong - 1) / valuesPerLong;
|
||||
int size = (entries + valuesPerLong - 1) / valuesPerLong;
|
||||
|
||||
long[] data = new long[size];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user