mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Reuse palette code
This commit is contained in:
parent
7032645c63
commit
d7fd079288
@ -94,7 +94,7 @@ public class Palette implements PublicCloneable<Palette> {
|
||||
|
||||
final long value = block >> bitIndex & clear;
|
||||
|
||||
final boolean isCurrentAir = Block.fromStateId(hasPalette ? paletteBlockMap.get((short) value) : (short) value).isAir();
|
||||
final boolean isCurrentAir = Block.fromStateId(fromPalette((short) value)).isAir();
|
||||
|
||||
block |= clear << bitIndex;
|
||||
block ^= clear << bitIndex;
|
||||
@ -124,9 +124,7 @@ public class Palette implements PublicCloneable<Palette> {
|
||||
final long value = blocks[index] >> bitIndex & MAGIC_MASKS[bitsPerEntry];
|
||||
|
||||
// Change to palette value and return
|
||||
return hasPalette ?
|
||||
paletteBlockMap.get((short) value) :
|
||||
(short) value;
|
||||
return fromPalette((short) value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,6 +250,10 @@ public class Palette implements PublicCloneable<Palette> {
|
||||
return 1 << bitsPerEntry;
|
||||
}
|
||||
|
||||
private short fromPalette(short value) {
|
||||
return hasPalette ? paletteBlockMap.get(value) : value;
|
||||
}
|
||||
|
||||
private static Short2ShortLinkedOpenHashMap createPaletteBlockMap() {
|
||||
Short2ShortLinkedOpenHashMap map = new Short2ShortLinkedOpenHashMap(CHUNK_SECTION_SIZE);
|
||||
map.put((short) 0, (short) 0);
|
||||
|
Loading…
Reference in New Issue
Block a user