Remove reset of values from PaletteIndirect (#2590)

* Remove reset of values from PaletteIndirect

* Add test for PaletteIndirect constructor
This commit is contained in:
UltraDev 2025-01-19 14:22:25 +01:00 committed by GitHub
parent 6f107c7f88
commit c1a3ee6aca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View File

@ -49,8 +49,6 @@ final class PaletteIndirect implements SpecializedPalette, Cloneable {
this.paletteToValueList.add(palette[i]);
this.valueToPaletteMap.put(palette[i], i);
}
this.values = new long[arrayLength(dimension(), bitsPerEntry)];
}
PaletteIndirect(int dimension, int maxBitsPerEntry, byte bitsPerEntry) {

View File

@ -0,0 +1,17 @@
package net.minestom.server.instance.palette;
import org.junit.jupiter.api.Test;
public class PaletteIndirectTest {
@Test
public void constructor() {
var palette = new PaletteIndirect(16, 8, (byte) 4);
palette.set(0, 0, 1, 1);
var otherPalette = new PaletteIndirect(palette.dimension(), palette.maxBitsPerEntry(), (byte) palette.bitsPerEntry(), palette.count(), palette.paletteToValueList.toIntArray(), palette.values);
palette.getAll((x, y, z, value) -> {
assert value == otherPalette.get(x, y, z);
});
}
}