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
|
@Override
|
||||||
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 int index = ChunkUtils.getBlockIndex(x, y, z);
|
|
||||||
final short blockStateId = section.getBlockAt(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);
|
Block block = Block.fromStateId(blockStateId);
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return Block.AIR;
|
return Block.AIR;
|
||||||
}
|
}
|
||||||
return block
|
final int index = ChunkUtils.getBlockIndex(x, y, z);
|
||||||
.withHandler(handler)
|
final BlockHandler handler = handlerMap.get(index);
|
||||||
.withNbt(nbt);
|
final NBTCompound nbt = nbtMap.get(index);
|
||||||
|
if (handler != null) {
|
||||||
|
block = block.withHandler(handler);
|
||||||
|
}
|
||||||
|
if (nbt != null) {
|
||||||
|
block = block.withNbt(nbt);
|
||||||
|
}
|
||||||
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
Loading…
Reference in New Issue
Block a user