diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/ChunkSectionType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/ChunkSectionType1_18.java index 900a6190f..4952b37d3 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/ChunkSectionType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/ChunkSectionType1_18.java @@ -101,13 +101,18 @@ public class ChunkSectionType1_18 extends Type { } private void writePalette(final ByteBuf buffer, final DataPalette palette) { - int bitsPerValue = 0; - while (palette.size() > 1 << bitsPerValue) { - bitsPerValue += 1; - } + int bitsPerValue; + if (palette.size() > 1) { + bitsPerValue = palette.type() == PaletteType.BLOCKS ? 4 : 2; //TODO implement linear palette + while (palette.size() > 1 << bitsPerValue) { + bitsPerValue += 1; + } - if (bitsPerValue > palette.type().highestBitsPerValue()) { - bitsPerValue = GLOBAL_PALETTE; + if (bitsPerValue > palette.type().highestBitsPerValue()) { + bitsPerValue = GLOBAL_PALETTE; + } + } else { + bitsPerValue = 0; } buffer.writeByte(bitsPerValue); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java index 1a18e04c8..513c009b7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java @@ -105,14 +105,6 @@ public final class WorldPackets { handler(wrapper -> { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); final Chunk oldChunk = wrapper.read(new Chunk1_17Type(tracker.currentWorldSectionHeight())); - /*for (int s = 0; s < chunk.getSections().length; s++) { - ChunkSection section = chunk.getSections()[s]; - if (section == null) continue; - for (int i = 0; i < section.getPaletteSize(); i++) { - int old = section.getPaletteEntry(i); - section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old)); - } - }*/ final List blockEntities = new ArrayList<>(oldChunk.getBlockEntities().size()); for (final CompoundTag tag : oldChunk.getBlockEntities()) { @@ -143,6 +135,12 @@ public final class WorldPackets { final DataPaletteImpl blockPalette = new DataPaletteImpl(PaletteType.BLOCKS); blockPalette.addEntry(0); section.addPalette(blockPalette); + } else { + /*final DataPalette blockpalette = section.palette(PaletteType.BLOCKS); + for (int j = 0; j < blockpalette.size(); j++) { + final int old = blockpalette.entry(j); + blockpalette.setEntry(j, protocol.getMappingData().getNewBlockStateId(old)); + }*/ } // Fill biome palette