From 294601a6b591bdbbbda701cfc61c4912675f7ce2 Mon Sep 17 00:00:00 2001 From: KermanIsPretty <46640204+KermanIsPretty@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:53:33 -0600 Subject: [PATCH] Fixed tickable warning message to be outside of assertions. --- src/main/java/net/minestom/server/instance/DynamicChunk.java | 5 ++++- .../net/minestom/server/instance/block/BlockHandler.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/DynamicChunk.java b/src/main/java/net/minestom/server/instance/DynamicChunk.java index 2fbcb29ac..9b91c8369 100644 --- a/src/main/java/net/minestom/server/instance/DynamicChunk.java +++ b/src/main/java/net/minestom/server/instance/DynamicChunk.java @@ -186,7 +186,10 @@ public class DynamicChunk extends Chunk { final Block block = entry.getValue(); final BlockHandler handler = block.handler(); if (handler == null) return; - assert handler.tickable(): String.format("You cannot change the tickable state of %s during runtime!", handler.getNamespaceId()); + // We cannot throw an exception as that could cause other blocks to not get properly ticked. + if (!handler.tickable()) { + LOGGER.warn("Ticking a block {} using the handler {}, but it is no longer considered tickable. Previously, it was tickable, but this is unsupported since tickable is immutable.", block, handler); + } final Point blockPosition = CoordConversion.chunkBlockIndexGetGlobal(index, chunkX, chunkZ); handler.tick(new BlockHandler.Tick(block, instance, blockPosition)); }); diff --git a/src/main/java/net/minestom/server/instance/block/BlockHandler.java b/src/main/java/net/minestom/server/instance/block/BlockHandler.java index 628cf93d7..fff85389f 100644 --- a/src/main/java/net/minestom/server/instance/block/BlockHandler.java +++ b/src/main/java/net/minestom/server/instance/block/BlockHandler.java @@ -75,9 +75,9 @@ public interface BlockHandler { } /** - * Specifies if this block should be ticked. + * Specifies if this block should be ticked, this is immutable after the block is set. *
- * This method is only called when the block is set. + * This method is only called during the block set and later to check immutability. * * @return true if this block should be ticked */