mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-08 11:50:36 +01:00
Optimize block getter
This commit is contained in:
parent
235100e87b
commit
0bdc84558f
@ -110,17 +110,21 @@ public class DynamicChunk extends Chunk {
|
||||
@Override
|
||||
public @NotNull Block getBlock(int x, int y, int z) {
|
||||
final Section section = retrieveSection(y);
|
||||
final int index = ChunkUtils.getBlockIndex(x, y, z);
|
||||
final short blockStateId = section.getBlockAt(x, y, z);
|
||||
BlockHandler handler = handlerMap.get(index);
|
||||
NBTCompound nbt = nbtMap.get(index);
|
||||
Block block = Block.fromStateId(blockStateId);
|
||||
if (block == null) {
|
||||
return Block.AIR;
|
||||
}
|
||||
return block
|
||||
.withHandler(handler)
|
||||
.withNbt(nbt);
|
||||
final int index = ChunkUtils.getBlockIndex(x, y, z);
|
||||
final BlockHandler handler = handlerMap.get(index);
|
||||
final NBTCompound nbt = nbtMap.get(index);
|
||||
if (handler != null) {
|
||||
block = block.withHandler(handler);
|
||||
}
|
||||
if (nbt != null) {
|
||||
block = block.withNbt(nbt);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
Loading…
Reference in New Issue
Block a user