Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-29 09:30:08 +01:00
Merge pull request #1742 from Gerrygames/abstraction
convert height maps, fix 1.16 chunk reading
Dieser Commit ist enthalten in:
Commit
f7b841faf3
@ -34,7 +34,8 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
// Read blocks
|
// Read blocks
|
||||||
long[] blockData = new long[Type.VAR_INT.read(buffer)];
|
long[] blockData = new long[Type.VAR_INT.read(buffer)];
|
||||||
if (blockData.length > 0) {
|
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) {
|
if (blockData.length != expectedLength) {
|
||||||
throw new IllegalStateException("Block data length (" + blockData.length + ") does not match expected length (" + expectedLength + ")! bitsPerBlock=" + bitsPerBlock + ", originalBitsPerBlock=" + originalBitsPerBlock);
|
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.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
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.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
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.Protocol1_16To1_15_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
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.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -82,6 +84,14 @@ public class WorldPackets {
|
|||||||
blockEntity.put(skullOwnerTag);
|
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 divideMul = Integer.toUnsignedLong(MAGIC[magicIndex]);
|
||||||
long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
|
long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
|
||||||
int divideShift = MAGIC[magicIndex + 2];
|
int divideShift = MAGIC[magicIndex + 2];
|
||||||
int size = (4096 + valuesPerLong - 1) / valuesPerLong;
|
int size = (entries + valuesPerLong - 1) / valuesPerLong;
|
||||||
|
|
||||||
long[] data = new long[size];
|
long[] data = new long[size];
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren