From ffd1c0b7979e62e89bd09ba32db8f9013482d693 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Fri, 6 Dec 2024 19:19:07 +0100 Subject: [PATCH] added chunks per tick argument for paste command --- .../blockedit/BlockEditCommands.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java b/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java index 9f08b40..e9a0519 100644 --- a/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java +++ b/src/main/java/me/youhavetrouble/blockedit/BlockEditCommands.java @@ -216,6 +216,29 @@ public class BlockEditCommands { return Command.SINGLE_SUCCESS; }) + .then( + Commands.argument("chunks_per_tick", IntegerArgumentType.integer(1)) + .executes(ctx -> { + Player player = (Player) ctx.getSource().getSender(); + BEPlayer bePlayer = BEPlayer.getByPlayer(player); + Vector playerLocationVector = player.getLocation().toBlockLocation().toVector(); + + HashMap absoluteBlocks = new HashMap<>(bePlayer.getClipboard().getBlocks().size()); + + int chunksPerTick = ctx.getArgument("chunks_per_tick", Integer.class); + + bePlayer.getClipboard().getBlocks().forEach((vector, blockState) -> { + Vector absolutePosition = vector.clone().add(playerLocationVector); + absoluteBlocks.put(absolutePosition, blockState); + }); + + Selection selection = Selection.fromClipboard(absoluteBlocks.keySet(), player.getWorld()); + BlockEditAPI.runOperation(selection, chunksPerTick, new PasteOperation(absoluteBlocks)); + player.sendMessage(Component.text(BELocale.getLocale(player.locale()).pastingClipboard, NamedTextColor.GRAY)); + + return Command.SINGLE_SUCCESS; + }) + ) .build(); }