From 2143e38d27e5a156b3ac2f7d930c1785226cb8c7 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 8 Dec 2021 21:31:53 +0100 Subject: [PATCH] Don't make the client resize palettes on >8 bits --- .../viaversion/api/type/types/version/PaletteType1_18.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/PaletteType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/PaletteType1_18.java index fa809b7c0..9239b69d0 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/PaletteType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/PaletteType1_18.java @@ -89,7 +89,6 @@ public final class PaletteType1_18 extends Type { @Override public void write(final ByteBuf buffer, final DataPalette palette) throws Exception { - final int bitsPerValue; if (palette.size() == 1) { // Single value palette buffer.writeByte(0); // 0 bit storage @@ -102,7 +101,11 @@ public final class PaletteType1_18 extends Type { // 1, 2, and 3 bit linear block palettes can't be read by the client final int min = type == PaletteType.BLOCKS ? 4 : 1; - bitsPerValue = MathUtil.clamp(MathUtil.ceilLog2(palette.size()), min, type.highestBitsPerValue()); + int bitsPerValue = Math.max(min, MathUtil.ceilLog2(palette.size())); + if (bitsPerValue > type.highestBitsPerValue()) { + bitsPerValue = globalPaletteBits; + } + buffer.writeByte(bitsPerValue); if (bitsPerValue != globalPaletteBits) {