mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Nitpicking
This commit is contained in:
parent
722b04cbce
commit
690b5bff57
@ -100,19 +100,14 @@ public class DynamicChunk extends Chunk {
|
|||||||
// Verify if the block object is present
|
// Verify if the block object is present
|
||||||
final var entry = !entries.isEmpty() ?
|
final var entry = !entries.isEmpty() ?
|
||||||
entries.get(ChunkUtils.getBlockIndex(x, y, z)) : null;
|
entries.get(ChunkUtils.getBlockIndex(x, y, z)) : null;
|
||||||
if (entry != null) {
|
if (entry != null || condition == Condition.CACHED) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
if (condition != Condition.NONE) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Retrieve the block from state id
|
// Retrieve the block from state id
|
||||||
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 blockStateId > 0 ?
|
||||||
return Block.AIR;
|
Objects.requireNonNullElse(Block.fromStateId(blockStateId), Block.AIR) : Block.AIR;
|
||||||
}
|
|
||||||
return Objects.requireNonNullElse(Block.fromStateId(blockStateId), Block.AIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,10 +24,13 @@ public interface BlockGetter {
|
|||||||
enum Condition {
|
enum Condition {
|
||||||
/**
|
/**
|
||||||
* Returns a block no matter what.
|
* Returns a block no matter what.
|
||||||
|
* {@link Block#AIR} being the default result.
|
||||||
*/
|
*/
|
||||||
NONE,
|
NONE,
|
||||||
/**
|
/**
|
||||||
* Returns a block only if it has a handler or nbt.
|
* Returns a block only if it has a handler or nbt.
|
||||||
|
* <p>
|
||||||
|
* Should be more performant than {@link #NONE}.
|
||||||
*/
|
*/
|
||||||
CACHED
|
CACHED
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user