Fix Palette#resize not actually resizing the palette (#503)

This commit is contained in:
56738 2021-10-24 16:04:34 +02:00 committed by GitHub
parent c5f4ce8515
commit afdc67fc26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,9 +145,6 @@ public final class Palette implements PublicCloneable<Palette> {
newBitsPerEntry = fixBitsPerEntry(newBitsPerEntry);
Palette palette = new Palette(newBitsPerEntry, bitsIncrement);
palette.paletteBlockArray = paletteBlockArray;
palette.blockPaletteMap = blockPaletteMap;
palette.lastPaletteIndex = lastPaletteIndex;
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
@ -251,6 +248,7 @@ public final class Palette implements PublicCloneable<Palette> {
if (lastPaletteIndex >= paletteBlockArray.length) {
// Palette is full, must resize
resize(bitsPerEntry + bitsIncrement);
if (!hasPalette) return blockId;
}
final short paletteIndex = (short) lastPaletteIndex++;
this.paletteBlockArray[paletteIndex] = blockId;