mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
More style
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
b5062ab4d6
commit
42f4678db0
@ -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
|
||||||
|
@ -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()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user