Nitpicking

This commit is contained in:
TheMode 2021-07-12 21:30:32 +02:00
parent 722b04cbce
commit 690b5bff57
2 changed files with 6 additions and 8 deletions

View File

@ -100,19 +100,14 @@ public class DynamicChunk extends Chunk {
// Verify if the block object is present
final var entry = !entries.isEmpty() ?
entries.get(ChunkUtils.getBlockIndex(x, y, z)) : null;
if (entry != null) {
if (entry != null || condition == Condition.CACHED) {
return entry;
}
if (condition != Condition.NONE) {
return null;
}
// Retrieve the block from state id
final Section section = retrieveSection(y);
final short blockStateId = section.getBlockAt(x, y, z);
if (blockStateId == -1) {
return Block.AIR;
}
return Objects.requireNonNullElse(Block.fromStateId(blockStateId), Block.AIR);
return blockStateId > 0 ?
Objects.requireNonNullElse(Block.fromStateId(blockStateId), Block.AIR) : Block.AIR;
}
@Override

View File

@ -24,10 +24,13 @@ public interface BlockGetter {
enum Condition {
/**
* Returns a block no matter what.
* {@link Block#AIR} being the default result.
*/
NONE,
/**
* Returns a block only if it has a handler or nbt.
* <p>
* Should be more performant than {@link #NONE}.
*/
CACHED
}