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 // 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

View File

@ -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
} }