More style

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-11 06:13:48 +02:00
parent b5062ab4d6
commit 42f4678db0
2 changed files with 7 additions and 9 deletions

View File

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

View File

@ -129,16 +129,15 @@ public abstract class ThreadProvider {
final ReentrantLock lock = thread.getLock(); final ReentrantLock lock = thread.getLock();
lock.lock(); lock.lock();
for (var chunkEntry : chunkEntries) { for (ChunkEntry chunkEntry : chunkEntries) {
final Chunk chunk = chunkEntry.chunk; final Chunk chunk = chunkEntry.chunk;
if (!ChunkUtils.isLoaded(chunk)) if (!ChunkUtils.isLoaded(chunk)) return;
return;
try { try {
chunk.tick(time); chunk.tick(time);
} catch (Throwable e) { } catch (Throwable e) {
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(e);
} }
final var entities = chunkEntry.entities; final List<Entity> entities = chunkEntry.entities;
if (!entities.isEmpty()) { if (!entities.isEmpty()) {
for (Entity entity : entities) { for (Entity entity : entities) {
if (lock.hasQueuedThreads()) { if (lock.hasQueuedThreads()) {