3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 17:10:13 +01:00

Merge pull request #1742 from Gerrygames/abstraction

convert height maps, fix 1.16 chunk reading
Dieser Commit ist enthalten in:
Myles 2020-04-22 20:44:47 +01:00 committet von GitHub
Commit f7b841faf3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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]));
}
});
}
});

Datei anzeigen

@ -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];