diff --git a/README.md b/README.md index c73ae90a..fcbece2d 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ These are the commands that are currently implemented: | `//replace` | None | Replace all blocks in a selection with another | | `//copy` | `//c` | Copy the selection to the clipboard | | `//cut` | `//x` | Cut the selection to the clipboard | -| `//paste` | `//v` | Paste the clipboard's contents (`-a` to copy air, `-u` to also update) | +| `//paste` | `//v` | Paste the clipboard's contents (`-a` to ignore air, `-u` to also update) | | `//undo` | None | Undoes the last action (from history) | | `//redo` | None | Redoes the last action (from history) | | `//rstack` | `//rs` | Stack with more options, Refer to [RedstoneTools](https://github.com/paulikauro/RedstoneTools) | @@ -136,7 +136,7 @@ These are the commands that are currently implemented: | `//shift` | None | Shift the selection area | | `//flip` | `//f` | Flip the contents of the clipboard across the origin | | `//rotate` | `//r` | Rotate the contents of the clipboard | -| `//update` | None | Updates all blocks in the selection or entire plot | +| `//update` | None | Updates all blocks in the selection (`-p` to update the entire plot) | | `//help` | None | Displays help for WorldEdit commands | ## Acknowledgments diff --git a/crates/core/src/plot/worldedit/execute.rs b/crates/core/src/plot/worldedit/execute.rs index 44cc9b48..4eaa28d1 100644 --- a/crates/core/src/plot/worldedit/execute.rs +++ b/crates/core/src/plot/worldedit/execute.rs @@ -992,21 +992,26 @@ pub(super) fn execute_rstack(ctx: CommandExecuteContext<'_>) { pub(super) fn execute_update(ctx: CommandExecuteContext<'_>) { let start_time = Instant::now(); - let pos = match (ctx.player.first_position, ctx.player.second_position) { - (None, None) => Some(ctx.plot.get_corners()), - (Some(first_pos), Some(second_pos)) => Some((first_pos, second_pos)), - _ => None, + let (first_pos, second_pos) = if ctx.has_flag('p') { + ctx.plot.get_corners() + } else { + if let (Some(first_pos), Some(second_pos)) = + (ctx.player.first_position, ctx.player.second_position) + { + (first_pos, second_pos) + } else { + ctx.player + .send_error_message("Your selection is incomplete."); + return; + } }; - if let Some((first_pos, second_pos)) = pos { - update(ctx.plot, first_pos, second_pos); - ctx.player.send_worldedit_message(&format!( - "Your selection was updated sucessfully. ({:?})", - start_time.elapsed() - )); - } else { - ctx.player.send_error_message("Your selection is incomplete."); - } + update(ctx.plot, first_pos, second_pos); + + ctx.player.send_worldedit_message(&format!( + "Your selection was updated sucessfully. ({:?})", + start_time.elapsed() + )); } pub(super) fn execute_replace_container(ctx: CommandExecuteContext<'_>) { diff --git a/crates/core/src/plot/worldedit/mod.rs b/crates/core/src/plot/worldedit/mod.rs index 8da36d2d..68a9c127 100644 --- a/crates/core/src/plot/worldedit/mod.rs +++ b/crates/core/src/plot/worldedit/mod.rs @@ -7,7 +7,7 @@ use super::{Plot, PlotWorld}; use crate::player::{PacketSender, Player, PlayerPos}; use crate::redstone; use crate::world::storage::PalettedBitBuffer; -use crate::world::{World, for_each_block_mut_optimized}; +use crate::world::{for_each_block_mut_optimized, World}; use execute::*; use mchprs_blocks::block_entities::{BlockEntity, ContainerType}; use mchprs_blocks::blocks::Block; @@ -697,6 +697,9 @@ static COMMANDS: Lazy> = Lazy::new(|| { description: "Updates all blocks in the selection", permission_node: "mchprs.we.update", requires_positions: false, + flags: &[ + flag!('p', None, "Update the entire plot"), + ], ..Default::default() }, "/help" => WorldeditCommand { diff --git a/crates/core/src/redpiler/mod.rs b/crates/core/src/redpiler/mod.rs index 9605c221..999d8cd5 100644 --- a/crates/core/src/redpiler/mod.rs +++ b/crates/core/src/redpiler/mod.rs @@ -5,7 +5,7 @@ mod passes; use crate::redpiler::passes::make_default_pass_manager; use crate::redstone; -use crate::world::{World, for_each_block_mut_optimized}; +use crate::world::{for_each_block_mut_optimized, World}; use backend::JITBackend; use mchprs_blocks::blocks::Block; use mchprs_blocks::BlockPos; diff --git a/crates/core/src/redpiler/passes/identify_nodes.rs b/crates/core/src/redpiler/passes/identify_nodes.rs index 75bc8458..2d0251d7 100644 --- a/crates/core/src/redpiler/passes/identify_nodes.rs +++ b/crates/core/src/redpiler/passes/identify_nodes.rs @@ -30,10 +30,7 @@ impl Pass for IdentifyNodes { let (first_pos, second_pos) = input.bounds; - let start_pos = first_pos.min(second_pos); - let end_pos = first_pos.max(second_pos); - - for_each_block_optimized(plot, start_pos, end_pos, |pos| { + for_each_block_optimized(plot, first_pos, second_pos, |pos| { for_pos(ignore_wires, plot, graph, pos) }); }