mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 03:27:56 +01:00
Fix palette resizing
This commit is contained in:
parent
9174742429
commit
cf43d2c70a
@ -19,9 +19,9 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
private final int dimension;
|
||||
private final int size;
|
||||
private final int maxBitsPerEntry;
|
||||
private final int bitsIncrement;
|
||||
|
||||
private int bitsPerEntry;
|
||||
private final int bitsIncrement;
|
||||
|
||||
private int valuesPerLong;
|
||||
private boolean hasPalette;
|
||||
@ -39,9 +39,9 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
this.dimension = dimension;
|
||||
this.size = dimension * dimension * dimension;
|
||||
this.maxBitsPerEntry = maxBitsPerEntry;
|
||||
this.bitsIncrement = bitsIncrement;
|
||||
|
||||
this.bitsPerEntry = bitsPerEntry;
|
||||
this.bitsIncrement = bitsIncrement;
|
||||
|
||||
this.valuesPerLong = Long.SIZE / bitsPerEntry;
|
||||
this.hasPalette = bitsPerEntry <= maxBitsPerEntry;
|
||||
@ -180,7 +180,7 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
|
||||
private void resize(int newBitsPerEntry) {
|
||||
newBitsPerEntry = fixBitsPerEntry(newBitsPerEntry);
|
||||
PaletteImpl palette = new PaletteImpl(size, maxBitsPerEntry, newBitsPerEntry, bitsIncrement);
|
||||
PaletteImpl palette = new PaletteImpl(dimension, maxBitsPerEntry, newBitsPerEntry, bitsIncrement);
|
||||
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
|
||||
for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
|
||||
for (int z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
@ -189,16 +189,16 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
this.paletteToValueList = palette.paletteToValueList;
|
||||
this.lastPaletteIndex = palette.lastPaletteIndex;
|
||||
|
||||
this.bitsPerEntry = palette.bitsPerEntry;
|
||||
|
||||
this.valuesPerLong = palette.valuesPerLong;
|
||||
this.hasPalette = palette.hasPalette;
|
||||
this.lastPaletteIndex = palette.lastPaletteIndex;
|
||||
this.count = palette.count;
|
||||
|
||||
this.values = palette.values;
|
||||
this.count = palette.count;
|
||||
this.paletteToValueList = palette.paletteToValueList;
|
||||
this.valueToPaletteMap = palette.valueToPaletteMap;
|
||||
}
|
||||
|
||||
private int getPaletteIndex(int value) {
|
||||
@ -209,7 +209,7 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
if (lastPaletteIndex >= maxPaletteSize(bitsPerEntry)) {
|
||||
// Palette is full, must resize
|
||||
resize(bitsPerEntry + bitsIncrement);
|
||||
if (!hasPalette) return value;
|
||||
return getPaletteIndex(value);
|
||||
}
|
||||
final int paletteIndex = lastPaletteIndex++;
|
||||
this.paletteToValueList.add(value);
|
||||
|
Loading…
Reference in New Issue
Block a user