From 7032645c63d40acf9cc0a9a1823e3fd1b7b832d9 Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 18 Jun 2021 14:43:14 +0200 Subject: [PATCH] Cleanup --- .../net/minestom/server/instance/DynamicChunk.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java index 45e8239ec..2f7e7e63d 100644 --- a/src/main/java/net/minestom/server/instance/DynamicChunk.java +++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java @@ -86,8 +86,7 @@ public class DynamicChunk extends Chunk { this.nbtMap.remove(index); } // Tickable - final boolean tickable = handler != null && handler.isTickable(); - if (tickable) { + if (handler != null && handler.isTickable()) { this.tickableMap.put(index, handler); } else { this.tickableMap.remove(index); @@ -106,15 +105,19 @@ public class DynamicChunk extends Chunk { @Override public void tick(long time) { - this.tickableMap.forEach((index, handler) -> { + if (tickableMap.isEmpty()) + return; + for (var entry : tickableMap.int2ObjectEntrySet()) { + final int index = entry.getIntKey(); + final byte x = ChunkUtils.blockIndexToChunkPositionX(index); final short y = ChunkUtils.blockIndexToChunkPositionY(index); final byte z = ChunkUtils.blockIndexToChunkPositionZ(index); final BlockPosition blockPosition = new BlockPosition(x, y, z); final Block block = getBlock(blockPosition); - handler.tick(BlockHandler.Tick.from(block, instance, blockPosition)); - }); + entry.getValue().tick(BlockHandler.Tick.from(block, instance, blockPosition)); + } } @Override