mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Palette cleanup
This commit is contained in:
parent
ddae239e30
commit
b978eba0fd
@ -111,6 +111,9 @@ public class DynamicChunk extends Chunk {
|
|||||||
public @NotNull Block getBlock(int x, int y, int z) {
|
public @NotNull Block getBlock(int x, int y, int z) {
|
||||||
final Section section = retrieveSection(y);
|
final Section section = retrieveSection(y);
|
||||||
final short blockStateId = section.getBlockAt(x, y, z);
|
final short blockStateId = section.getBlockAt(x, y, z);
|
||||||
|
if (blockStateId == -1) {
|
||||||
|
return Block.AIR;
|
||||||
|
}
|
||||||
Block block = Block.fromStateId(blockStateId);
|
Block block = Block.fromStateId(blockStateId);
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return Block.AIR;
|
return Block.AIR;
|
||||||
|
@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.shorts.Short2ShortLinkedOpenHashMap;
|
|||||||
import it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap;
|
import it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.instance.Chunk;
|
import net.minestom.server.instance.Chunk;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
import net.minestom.server.utils.MathUtils;
|
import net.minestom.server.utils.MathUtils;
|
||||||
import net.minestom.server.utils.clone.PublicCloneable;
|
import net.minestom.server.utils.clone.PublicCloneable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -76,8 +77,7 @@ public class Palette implements PublicCloneable<Palette> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the new block is air, used for counting none air blocks.
|
// Check if the new block is air, used for counting none air blocks.
|
||||||
// FIXME: once block data is working
|
final boolean isAir = Block.fromStateId(blockId).isAir();
|
||||||
final boolean isAir = blockId == 0;//Block.fromStateId(blockId).isAir();
|
|
||||||
|
|
||||||
// Change to palette value
|
// Change to palette value
|
||||||
blockId = getPaletteIndex(blockId);
|
blockId = getPaletteIndex(blockId);
|
||||||
@ -94,9 +94,7 @@ public class Palette implements PublicCloneable<Palette> {
|
|||||||
|
|
||||||
final long value = block >> bitIndex & clear;
|
final long value = block >> bitIndex & clear;
|
||||||
|
|
||||||
// FIXME: once block data is working
|
final boolean isCurrentAir = Block.fromStateId(hasPalette ? paletteBlockMap.get((short) value) : (short) value).isAir();
|
||||||
final boolean isCurrentAir = (hasPalette ? paletteBlockMap.get((short) value) : (short) value) == 0;
|
|
||||||
//Block.fromStateId(hasPalette ? paletteBlockMap.get((short) value) : (short) value).isAir();
|
|
||||||
|
|
||||||
block |= clear << bitIndex;
|
block |= clear << bitIndex;
|
||||||
block ^= clear << bitIndex;
|
block ^= clear << bitIndex;
|
||||||
@ -115,7 +113,7 @@ public class Palette implements PublicCloneable<Palette> {
|
|||||||
public short getBlockAt(int x, int y, int z) {
|
public short getBlockAt(int x, int y, int z) {
|
||||||
if (blocks.length == 0) {
|
if (blocks.length == 0) {
|
||||||
// Section is not loaded, can only be air
|
// Section is not loaded, can only be air
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int sectionIdentifier = getSectionIndex(x, y, z);
|
final int sectionIdentifier = getSectionIndex(x, y, z);
|
||||||
|
Loading…
Reference in New Issue
Block a user