From b39bf4c87905e45966e7f65cfdd7f61381d895d0 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Fri, 9 Oct 2026 13:48:40 +0200 Subject: [PATCH] Add /place template Place a saved structure template at a position with rotation, mirroring, integrity, seed and strict mode. Templates come from the world's generated structures first, then the vanilla template files. Block entities and saved entities are placed along with the blocks, and the template ids are offered as suggestions. Co-Authored-By: Claude Sonnet 5.5 --- crates/horizon-client/src/command/args.rs | 2 + crates/horizon-client/src/command/tests.rs | 16 ++ .../horizon-client/src/command/tree_world.rs | 27 +++ crates/horizon-client/src/game/chat.rs | 25 +++ crates/horizon-client/src/game/commands.rs | 9 +- .../horizon-client/src/game/commands/place.rs | 179 ++++++++++++++++++ 6 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 crates/horizon-client/src/game/commands/place.rs diff --git a/crates/horizon-client/src/command/args.rs b/crates/horizon-client/src/command/args.rs index 2d44b4e93..c92c44a33 100644 --- a/crates/horizon-client/src/command/args.rs +++ b/crates/horizon-client/src/command/args.rs @@ -46,6 +46,7 @@ pub struct Registries { pub damage_types: Vec, pub attributes: Vec, pub loot_tables: Vec, + pub templates: Vec, pub random_sequences: Vec, pub datapacks_enabled: Vec, pub datapacks_disabled: Vec, @@ -1926,6 +1927,7 @@ impl ArgType { "damage_types" => reg.damage_types.clone(), "attributes" => reg.attributes.clone(), "loot_tables" => reg.loot_tables.clone(), + "templates" => reg.templates.clone(), "random_sequences" => reg.random_sequences.clone(), "predicates" => reg.predicates.clone(), "time_markers" => reg.time_markers.clone(), diff --git a/crates/horizon-client/src/command/tests.rs b/crates/horizon-client/src/command/tests.rs index 3c10045c7..c7fe6b1fa 100644 --- a/crates/horizon-client/src/command/tests.rs +++ b/crates/horizon-client/src/command/tests.rs @@ -458,3 +458,19 @@ fn world_command_trees() { assert!(run("spreadplayers 0 0 5 0 false @a").is_err()); assert!(run("worldborder warning distance -1").is_err()); } + +#[test] +fn place_template_tree() { + for line in [ + "place template minecraft:igloo/top", + "place template minecraft:igloo/top ~ ~ ~", + "place template minecraft:igloo/top 1 2 3 clockwise_90 left_right 0.5 12 strict", + ] { + assert_eq!( + run(line).unwrap_or_else(|e| panic!("{line}: {e:?}")).0, + "place" + ); + } + assert!(run("place template minecraft:x ~ ~ ~ sideways").is_err()); + assert!(run("place template minecraft:x ~ ~ ~ none none 2").is_err()); +} diff --git a/crates/horizon-client/src/command/tree_world.rs b/crates/horizon-client/src/command/tree_world.rs index da7915c3c..39742bcfe 100644 --- a/crates/horizon-client/src/command/tree_world.rs +++ b/crates/horizon-client/src/command/tree_world.rs @@ -52,6 +52,33 @@ pub fn register(d: &mut Dispatcher, root: usize) { let targets = d.argument(respect, "targets", ENTITIES); d.executes(targets, "spreadplayers"); + // place template