diff --git a/src/main/java/com/ldtteam/structurize/management/Manager.java b/src/main/java/com/ldtteam/structurize/management/Manager.java index 691070270..60cbfebe8 100644 --- a/src/main/java/com/ldtteam/structurize/management/Manager.java +++ b/src/main/java/com/ldtteam/structurize/management/Manager.java @@ -56,15 +56,19 @@ private Manager() */ public static void onWorldTick(final ServerLevel world) { + int count = 0; if (!scanToolOperationPool.isEmpty()) { - final ITickedWorldOperation operation = scanToolOperationPool.peek(); - if (operation != null && operation.apply(world)) + while (count++ <= Structurize.getConfig().getServer().maxOperationsPerTick.get()) { - scanToolOperationPool.pop(); - if (!(operation instanceof UndoOperation || operation instanceof RedoOperation)) + final ITickedWorldOperation operation = scanToolOperationPool.peek(); + if (operation != null && operation.apply(world)) { - addToUndoRedoCache(operation.getChangeStorage()); + scanToolOperationPool.pop(); + if (!(operation instanceof UndoOperation || operation instanceof RedoOperation)) + { + addToUndoRedoCache(operation.getChangeStorage()); + } } } } diff --git a/src/main/java/com/ldtteam/structurize/network/messages/ReplaceBlockMessage.java b/src/main/java/com/ldtteam/structurize/network/messages/ReplaceBlockMessage.java index c3e056a90..f9a7808b7 100644 --- a/src/main/java/com/ldtteam/structurize/network/messages/ReplaceBlockMessage.java +++ b/src/main/java/com/ldtteam/structurize/network/messages/ReplaceBlockMessage.java @@ -51,8 +51,8 @@ protected ReplaceBlockMessage(final RegistryFriendlyByteBuf buf, final PlayMessa super(buf, type); this.from = buf.readBlockPos(); this.to = buf.readBlockPos(); - this.blockTo = ItemStack.STREAM_CODEC.decode(buf); - this.blockFrom = ItemStack.STREAM_CODEC.decode(buf); + this.blockTo = ItemStack.OPTIONAL_STREAM_CODEC.decode(buf); + this.blockFrom = ItemStack.OPTIONAL_STREAM_CODEC.decode(buf); this.pct = buf.readInt(); }