From 487fbcb5b9520e548f77e001f5b8394e942f455b Mon Sep 17 00:00:00 2001 From: themode Date: Fri, 25 Feb 2022 22:58:55 +0100 Subject: [PATCH] Stricter resize rule --- .../minestom/server/instance/palette/AdaptivePalette.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/palette/AdaptivePalette.java b/src/main/java/net/minestom/server/instance/palette/AdaptivePalette.java index 647f63f15..90e07367b 100644 --- a/src/main/java/net/minestom/server/instance/palette/AdaptivePalette.java +++ b/src/main/java/net/minestom/server/instance/palette/AdaptivePalette.java @@ -126,11 +126,12 @@ final class AdaptivePalette implements Palette { // Find all entries and compress the palette IntSet entries = new IntOpenHashSet(flexiblePalette.paletteToValueList.size()); flexiblePalette.getAll((x, y, z, value) -> entries.add(value)); + final int currentBitsPerEntry = flexiblePalette.bitsPerEntry(); + final int bitsPerEntry; if (entries.size() == 1) { return new FilledPalette(dimension, entries.iterator().nextInt()); - } else if (flexiblePalette.bitsPerEntry() > defaultBitsPerEntry) { - final int bitsPerEntry = MathUtils.bitsToRepresent(entries.size() - 1); - assert bitsPerEntry < flexiblePalette.bitsPerEntry(); + } else if (currentBitsPerEntry > defaultBitsPerEntry && + (bitsPerEntry = MathUtils.bitsToRepresent(entries.size() - 1)) < currentBitsPerEntry) { flexiblePalette.resize(bitsPerEntry); return flexiblePalette; }