mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 11:07:53 +01:00
Stricter resize rule
This commit is contained in:
parent
8839503767
commit
487fbcb5b9
@ -126,11 +126,12 @@ final class AdaptivePalette implements Palette {
|
|||||||
// Find all entries and compress the palette
|
// Find all entries and compress the palette
|
||||||
IntSet entries = new IntOpenHashSet(flexiblePalette.paletteToValueList.size());
|
IntSet entries = new IntOpenHashSet(flexiblePalette.paletteToValueList.size());
|
||||||
flexiblePalette.getAll((x, y, z, value) -> entries.add(value));
|
flexiblePalette.getAll((x, y, z, value) -> entries.add(value));
|
||||||
|
final int currentBitsPerEntry = flexiblePalette.bitsPerEntry();
|
||||||
|
final int bitsPerEntry;
|
||||||
if (entries.size() == 1) {
|
if (entries.size() == 1) {
|
||||||
return new FilledPalette(dimension, entries.iterator().nextInt());
|
return new FilledPalette(dimension, entries.iterator().nextInt());
|
||||||
} else if (flexiblePalette.bitsPerEntry() > defaultBitsPerEntry) {
|
} else if (currentBitsPerEntry > defaultBitsPerEntry &&
|
||||||
final int bitsPerEntry = MathUtils.bitsToRepresent(entries.size() - 1);
|
(bitsPerEntry = MathUtils.bitsToRepresent(entries.size() - 1)) < currentBitsPerEntry) {
|
||||||
assert bitsPerEntry < flexiblePalette.bitsPerEntry();
|
|
||||||
flexiblePalette.resize(bitsPerEntry);
|
flexiblePalette.resize(bitsPerEntry);
|
||||||
return flexiblePalette;
|
return flexiblePalette;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user