mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-07 19:31:37 +01:00
Remove valuesPerLong
This commit is contained in:
parent
7af813ea72
commit
b4b6c333bf
@ -8,12 +8,18 @@ import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
final class PaletteImpl implements Palette, Cloneable {
|
||||
// Magic values generated with "Integer.MAX_VALUE >> (31 - bitsPerIndex)" for bitsPerIndex between 1 and 16
|
||||
private static final int[] MAGIC_MASKS =
|
||||
{0, 1, 3, 7,
|
||||
15, 31, 63, 127, 255,
|
||||
511, 1023, 2047, 4095,
|
||||
8191, 16383, 32767};
|
||||
private static final int[] MAGIC_MASKS;
|
||||
private static final int[] VALUES_PER_LONG;
|
||||
|
||||
static {
|
||||
final int entries = 16;
|
||||
MAGIC_MASKS = new int[entries];
|
||||
VALUES_PER_LONG = new int[entries];
|
||||
for (int i = 1; i < entries; i++) {
|
||||
MAGIC_MASKS[i] = Integer.MAX_VALUE >> (31 - i);
|
||||
VALUES_PER_LONG[i] = Long.SIZE / i;
|
||||
}
|
||||
}
|
||||
|
||||
// Specific to this palette type
|
||||
private final int dimension;
|
||||
@ -23,7 +29,6 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
|
||||
private int bitsPerEntry;
|
||||
|
||||
private int valuesPerLong;
|
||||
private boolean hasPalette;
|
||||
private int lastPaletteIndex = 1; // First index is air
|
||||
|
||||
@ -46,7 +51,6 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
|
||||
this.bitsPerEntry = bitsPerEntry;
|
||||
|
||||
this.valuesPerLong = Long.SIZE / bitsPerEntry;
|
||||
this.hasPalette = bitsPerEntry <= maxBitsPerEntry;
|
||||
|
||||
this.paletteToValueList = new IntArrayList(1);
|
||||
@ -67,6 +71,8 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
x %= dimension;
|
||||
y %= dimension;
|
||||
z %= dimension;
|
||||
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
||||
|
||||
final int sectionIdentifier = getSectionIndex(x, y, z);
|
||||
final int index = sectionIdentifier / valuesPerLong;
|
||||
final int bitIndex = sectionIdentifier % valuesPerLong * bitsPerEntry;
|
||||
@ -87,6 +93,7 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
return;
|
||||
}
|
||||
// Initialize the section
|
||||
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
||||
this.values = new long[(size + valuesPerLong - 1) / valuesPerLong];
|
||||
}
|
||||
x %= dimension;
|
||||
@ -94,6 +101,7 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
z %= dimension;
|
||||
// Change to palette value
|
||||
value = getPaletteIndex(value);
|
||||
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
||||
final int sectionIndex = getSectionIndex(x, y, z);
|
||||
final int index = sectionIndex / valuesPerLong;
|
||||
final int bitIndex = (sectionIndex % valuesPerLong) * bitsPerEntry;
|
||||
@ -194,7 +202,6 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
|
||||
this.bitsPerEntry = palette.bitsPerEntry;
|
||||
|
||||
this.valuesPerLong = palette.valuesPerLong;
|
||||
this.hasPalette = palette.hasPalette;
|
||||
this.lastPaletteIndex = palette.lastPaletteIndex;
|
||||
this.count = palette.count;
|
||||
|
Loading…
Reference in New Issue
Block a user