From e57addcbf731d64bc1a905f9a2c03e6f5c7eb502 Mon Sep 17 00:00:00 2001 From: jglrxavpok Date: Fri, 1 May 2020 23:48:52 +0200 Subject: [PATCH] Differentiate scheduled and general updates --- .../minestom/server/instance/InstanceContainer.java | 2 +- .../minestom/server/instance/block/CustomBlock.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/instance/InstanceContainer.java b/src/main/java/net/minestom/server/instance/InstanceContainer.java index 3a31fd7e3..91ae70621 100644 --- a/src/main/java/net/minestom/server/instance/InstanceContainer.java +++ b/src/main/java/net/minestom/server/instance/InstanceContainer.java @@ -410,7 +410,7 @@ public class InstanceContainer extends Instance { if(currentBlock.getCustomBlockId() != toUpdate.getCustomBlockId()) { // block changed return; } - currentBlock.update(instance, position, getBlockData(position)); + currentBlock.scheduledUpdate(instance, position, getBlockData(position)); } }, new UpdateOption(time, unit)); } diff --git a/src/main/java/net/minestom/server/instance/block/CustomBlock.java b/src/main/java/net/minestom/server/instance/block/CustomBlock.java index 106c60b86..acaab9d61 100644 --- a/src/main/java/net/minestom/server/instance/block/CustomBlock.java +++ b/src/main/java/net/minestom/server/instance/block/CustomBlock.java @@ -104,4 +104,14 @@ public abstract class CustomBlock { update(instance, thisPosition, instance.getBlockData(thisPosition)); } } + + /** + * Called when a scheduled update on this block happens. By default, calls 'update' + * @param instance + * @param position + * @param blockData + */ + public void scheduledUpdate(Instance instance, BlockPosition position, Data blockData) { + update(instance, position, blockData); + } }