From e3a1cdce51d093b15160ea9fcfb963c81969c78c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 11 Oct 2026 14:26:47 +0200 Subject: [PATCH] WIP: hud parity work, paused while the harness tooling is sped up Uncommitted changes the agent had in progress when it was stopped; may not build or pass its harnesses yet. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 3 + crates/horizon-client/src/game/commands.rs | 34 ++ .../horizon-client/src/game/commands/data.rs | 10 +- .../src/game/commands/execute.rs | 5 + crates/horizon-client/src/game/persist.rs | 78 +++ crates/horizon-client/src/game/scoreboard.rs | 11 +- .../parity/VanillaCommandExecOracle.java | 6 +- tools/command_exec_corpus.py | 488 ++++++++++++++++++ 8 files changed, 631 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index c10d7ebcf..49db6bdc0 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -678,6 +678,8 @@ struct Game<'a> { map_frame_model: frames::FrameModel, glow_map_frame_model: frames::FrameModel, armor_stands: Vec, + /// Entities of types Horizon does not simulate. + others: Vec, armor_stand_assets: armor_stands::ArmorStandAssets, boats: Vec, boat_models: boats::BoatModels, @@ -8078,6 +8080,7 @@ pub fn run() -> Result<()> { map_frame_model: frames::bake_frame(&root, "item_frame_map"), glow_map_frame_model: frames::bake_frame(&root, "glow_item_frame_map"), armor_stands: Vec::new(), + others: Vec::new(), armor_stand_assets: armor_stands::ArmorStandAssets::load(&root), boats: Vec::new(), boat_models: boats::BoatModels::load(&root), diff --git a/crates/horizon-client/src/game/commands.rs b/crates/horizon-client/src/game/commands.rs index 0d91e0984..e61a2ad00 100644 --- a/crates/horizon-client/src/game/commands.rs +++ b/crates/horizon-client/src/game/commands.rs @@ -41,6 +41,19 @@ pub(super) enum Target { Painting(u32), Boat(u32), Cart(u32), + /// An entity of a type Horizon does not simulate (markers, displays, + /// interactions...): kept as its saved data at a position. + Other(u32), +} +/// An entity of a type Horizon does not simulate: its compound lives in the +/// entity memory (`persist.raw`), its position and rotation here. +#[derive(Clone, Debug)] +pub(in crate::game) struct OtherEntity { + pub id: u32, + pub kind: String, + pub position: Vec3, + pub yaw: f32, + pub pitch: f32, } pub(super) fn err(key: &str, args: &[&dyn std::fmt::Display]) -> CommandError { CommandError::tr(key, args) @@ -243,6 +256,11 @@ impl Game<'_> { .iter() .find(|c| c.id == id) .map(|c| [c.position.x, c.position.y, c.position.z]), + Target::Other(id) => self + .others + .iter() + .find(|o| o.id == id) + .map(|o| [o.position.x, o.position.y, o.position.z]), } } pub(super) fn target_type(&self, t: Target) -> String { @@ -279,6 +297,11 @@ impl Game<'_> { .iter() .find(|c| c.id == id) .map_or_else(|| "minecraft:minecart".into(), |c| c.kind.id().into()), + Target::Other(id) => self + .others + .iter() + .find(|o| o.id == id) + .map_or_else(String::new, |o| o.kind.clone()), } } /// Entity.getDisplayName. @@ -356,6 +379,7 @@ impl Game<'_> { candidates.extend(self.paintings.iter().map(|p| Target::Painting(p.id))); candidates.extend(self.boats.iter().map(|b| Target::Boat(b.id))); candidates.extend(self.carts.iter().map(|c| Target::Cart(c.id))); + candidates.extend(self.others.iter().map(|o| Target::Other(o.id))); } let level = self.experience.level; let creative = self.creative; @@ -885,6 +909,15 @@ impl Game<'_> { } } } + Target::Other(id) => { + if let Some(o) = self.others.iter_mut().find(|o| o.id == id) { + o.position = v; + if let Some([yaw, pitch]) = rotation { + o.yaw = yaw; + o.pitch = pitch; + } + } + } // Wall-mounted entities do not move. Target::Frame(_) | Target::Painting(_) => {} } @@ -1188,6 +1221,7 @@ impl Game<'_> { Target::Painting(id) => self.paintings.retain(|p| p.id != id), Target::Boat(id) => self.boats.retain(|b| b.id != id), Target::Cart(id) => self.carts.retain(|c| c.id != id), + Target::Other(id) => self.others.retain(|o| o.id != id), } } fn cmd_kill(&mut self, ctx: &Context) -> R { diff --git a/crates/horizon-client/src/game/commands/data.rs b/crates/horizon-client/src/game/commands/data.rs index d7436a628..ce3869428 100644 --- a/crates/horizon-client/src/game/commands/data.rs +++ b/crates/horizon-client/src/game/commands/data.rs @@ -86,6 +86,11 @@ impl Game<'_> { let c = self.carts.iter().find(|c| c.id == id)?; c.to_nbt(uuid, self.persist.raw.get(&id)) } + Target::Other(id) => { + let uuid = self.uuid_for(id); + let o = self.others.iter().find(|o| o.id == id)?.clone(); + self.other_to_nbt(&o, uuid) + } Target::Orb(i) => entity_nbt::orb_to_nbt(self.orbs.get(i)?, random_uuid()), Target::Arrow(i) => { let a = self.arrows.get(i)?; @@ -165,7 +170,8 @@ impl Game<'_> { | Target::Frame(id) | Target::Painting(id) | Target::Boat(id) - | Target::Cart(id) => Some(self.persist.raw.entry(id).or_insert_with(empty)), + | Target::Cart(id) + | Target::Other(id) => Some(self.persist.raw.entry(id).or_insert_with(empty)), _ => None, } } @@ -643,6 +649,8 @@ impl Game<'_> { Some(Target::Boat(id)) } else if self.carts.iter().any(|c| c.id == id) { Some(Target::Cart(id)) + } else if self.others.iter().any(|o| o.id == id) { + Some(Target::Other(id)) } else { None } diff --git a/crates/horizon-client/src/game/commands/execute.rs b/crates/horizon-client/src/game/commands/execute.rs index fd715fd5d..60394d429 100644 --- a/crates/horizon-client/src/game/commands/execute.rs +++ b/crates/horizon-client/src/game/commands/execute.rs @@ -106,6 +106,11 @@ impl Game<'_> { .iter() .find(|c| c.id == id) .map_or([0.0; 2], |c| [c.yaw, 0.0]), + Target::Other(id) => self + .others + .iter() + .find(|o| o.id == id) + .map_or([0.0; 2], |o| [o.yaw, o.pitch]), _ => [0.0; 2], } } diff --git a/crates/horizon-client/src/game/persist.rs b/crates/horizon-client/src/game/persist.rs index 2aa368383..5d51e5e34 100644 --- a/crates/horizon-client/src/game/persist.rs +++ b/crates/horizon-client/src/game/persist.rs @@ -275,6 +275,9 @@ impl Game<'_> { _ if self.res.mob_types.contains_key(&kind) => { self.load_mob(tag, None); } + _ if !kind.is_empty() && entity_nbt::position(&tag).is_some() => { + self.load_other(tag, &kind); + } _ => self.persist.unknown.entry(key).or_default().push(tag), } } @@ -347,6 +350,62 @@ impl Game<'_> { } Some(id) } + /// An entity of a type Horizon does not simulate, kept as its compound. + fn load_other(&mut self, tag: Tag, kind: &str) -> Option { + let position = entity_nbt::position(&tag)?; + let rotation = match tag.get("Rotation") { + Some(Tag::List(l)) => { + let f = |i: usize| match l.get(i) { + Some(Tag::Float(v)) => f32::from_bits(*v), + _ => 0.0, + }; + [f(0), f(1)] + } + _ => [0.0, 0.0], + }; + self.next_entity += 1; + let id = self.next_entity; + let uuid = entity_nbt::uuid(&tag); + self.remember(id, uuid, tag); + self.others.push(super::commands::OtherEntity { + id, + kind: kind.to_owned(), + position, + yaw: rotation[0], + pitch: rotation[1], + }); + Some(id) + } + /// The compound of an entity Horizon does not simulate, with its current + /// position, rotation and UUID. + pub(super) fn other_to_nbt(&self, o: &super::commands::OtherEntity, uuid: [i32; 4]) -> Tag { + let mut tag = self + .persist + .raw + .get(&o.id) + .cloned() + .unwrap_or_else(|| Tag::Compound(Default::default())); + if let Tag::Compound(c) = &mut tag { + c.insert("id".into(), Tag::String(o.kind.as_str().into())); + c.insert( + "Pos".into(), + Tag::List( + [o.position.x, o.position.y, o.position.z] + .map(|v| Tag::Double(v.to_bits())) + .to_vec(), + ), + ); + c.insert( + "Rotation".into(), + Tag::List(vec![ + Tag::Float(o.yaw.to_bits()), + Tag::Float(o.pitch.to_bits()), + ]), + ); + c.insert("UUID".into(), Tag::IntArray(uuid.to_vec())); + } + tag + } /// The root of a stack of riders (`Entity.getRootVehicle`). fn mob_root(&self, mut i: usize) -> usize { for _ in 0..8 { @@ -617,6 +676,18 @@ impl Game<'_> { out.entry(chunk_of(at)).or_default().push(tag); } } + for o in &self.others { + if keys.contains(&chunk_of(o.position)) { + let uuid = self + .persist + .uuids + .get(&o.id) + .copied() + .unwrap_or_else(random_uuid); + let tag = self.other_to_nbt(o, uuid); + out.entry(chunk_of(o.position)).or_default().push(tag); + } + } for key in keys { let unknown = if remove { self.persist.unknown.remove(key) @@ -649,6 +720,13 @@ impl Game<'_> { } keep }); + self.others.retain(|o| { + let keep = !gone(o.position); + if !keep { + removed.push(o.id); + } + keep + }); self.armor_stands.retain(|a| { let keep = !gone(a.position); if !keep { diff --git a/crates/horizon-client/src/game/scoreboard.rs b/crates/horizon-client/src/game/scoreboard.rs index d6962d674..38cdc07fc 100644 --- a/crates/horizon-client/src/game/scoreboard.rs +++ b/crates/horizon-client/src/game/scoreboard.rs @@ -166,9 +166,16 @@ impl Game<'_> { /// `Entity.getTags` (the `Tags` list of the saved entity). pub(super) fn tags_of(&self, t: Target) -> Vec { let raw = match t { - Target::Mob(id) | Target::Item(id) => self.persist.raw.get(&id), + Target::Mob(id) + | Target::Item(id) + | Target::Stand(id) + | Target::Frame(id) + | Target::Painting(id) + | Target::Boat(id) + | Target::Cart(id) + | Target::Other(id) => self.persist.raw.get(&id), Target::Player => self.level.player_extra.as_ref(), - _ => None, + Target::Orb(_) | Target::Arrow(_) => None, }; match raw.and_then(|r| r.get("Tags")) { Some(Tag::List(l)) => l diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCommandExecOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCommandExecOracle.java index 78a5bcef3..de6ee1fa1 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCommandExecOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCommandExecOracle.java @@ -267,7 +267,11 @@ public final class VanillaCommandExecOracle { int cx = player.chunkPosition().x(), cz = player.chunkPosition().z(); for (int dz = -2; dz <= 2; dz++) { for (int dx = -2; dx <= 2; dx++) { - level.setChunkForced(cx + dx, cz + dz, true); + // An entity-ticking ticket that, unlike setChunkForced, + // is not a force-load /forceload would report. + level.getChunkSource().addTicket( + new net.minecraft.server.level.Ticket(net.minecraft.server.level.TicketType.DRAGON, net.minecraft.server.level.ChunkMap.FORCED_TICKET_LEVEL), + new net.minecraft.world.level.ChunkPos(cx + dx, cz + dz)); level.getChunk(cx + dx, cz + dz); } } diff --git a/tools/command_exec_corpus.py b/tools/command_exec_corpus.py index d17f60626..6c17c9e5c 100644 --- a/tools/command_exec_corpus.py +++ b/tools/command_exec_corpus.py @@ -327,6 +327,485 @@ def scores(): ] +def execute(): + return [ + *setup('/scoreboard objectives add exec dummy', '/scoreboard players set @s exec 4', '/scoreboard players set fake exec 9'), + cmd('/execute as @s run say hi'), + cmd('/execute as @s at @s run tp @s ~ ~ ~'), + cmd('/execute positioned 4 210 4 run setblock ~ ~ ~ minecraft:stone'), + cmd('/execute positioned 4 210 4 if block ~ ~ ~ minecraft:stone'), + cmd('/execute positioned as @s run tp @s ~ ~ ~'), + cmd('/execute align xyz run summon minecraft:armor_stand ~ ~-20 ~ {NoGravity:1b,Tags:["ex"]}'), + cmd('/execute if entity @e[tag=ex]'), + cmd('/execute as @e[tag=ex] run data get entity @s Pos'), + cmd('/execute anchored eyes run tp @s ^ ^ ^'), + cmd('/execute rotated 90 0 run tp @s ~ ~ ~ ~ ~'), + cmd('/execute rotated as @e[tag=ex,limit=1] run tp @s ~ ~ ~ ~ ~'), + cmd('/execute facing 0 230 0 run tp @s ~ ~ ~ ~ ~'), + cmd('/execute facing entity @e[tag=ex,limit=1] feet run tp @s ~ ~ ~ ~ ~'), + cmd('/execute in minecraft:the_nether run setblock 0 200 0 minecraft:stone'), + cmd('/execute in minecraft:overworld run setblock 5 210 5 minecraft:dirt'), + cmd('/execute if dimension minecraft:overworld'), + cmd('/execute if dimension minecraft:the_end'), + cmd('/execute if loaded 8 230 8'), + cmd('/execute if loaded 100000 230 100000'), + cmd('/execute if score @s exec matches 4'), + cmd('/execute if score @s exec < fake exec'), + cmd('/execute if score @s exec = fake exec'), + cmd('/execute unless score @s exec matches 1..3'), + cmd('/execute if score nobody exec matches 1'), + cmd('/execute if data entity @s Inventory'), + cmd('/execute if data entity @e[tag=ex,limit=1] Tags[0]'), + cmd('/execute if data block 4 210 4 Items'), + cmd('/execute if data storage harness:s value'), + cmd('/execute if predicate minecraft:tool/can_shear'), + cmd('/execute if predicate {condition:"minecraft:random_chance",chance:1.0}'), + cmd('/execute if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{type:"minecraft:player"}}'), + cmd('/execute if items entity @s weapon.mainhand minecraft:air'), + cmd('/execute if items entity @s container.* *'), + cmd('/execute store result score @s exec run data get entity @s SelectedItemSlot'), + cmd('/execute store success score @s exec run setblock 4 210 4 minecraft:stone'), + cmd('/scoreboard players get @s exec'), + cmd('/execute store result storage harness:s value int 2 run scoreboard players get fake exec'), + cmd('/data get storage harness:s value'), + cmd('/execute store result entity @e[tag=ex,limit=1] Rotation[0] float 1 run scoreboard players get fake exec'), + cmd('/data get entity @e[tag=ex,limit=1] Rotation'), + cmd('/execute store result block 4 210 4 x int 1 run scoreboard players get fake exec'), + cmd('/execute summon minecraft:armor_stand run tag @s add summoned'), + cmd('/execute if entity @e[tag=summoned]'), + cmd('/execute as @e[tag=ex] on passengers run say passenger'), + cmd('/execute on vehicle run say vehicle'), + cmd('/execute as @e[tag=ex] run return 3'), + cmd('/execute if entity @s run return fail'), + cmd('/return 7'), + cmd('/return fail'), + cmd('/return run scoreboard players get fake exec'), + cmd('/execute if biome 8 230 8 #minecraft:is_overworld'), + cmd('/execute if block 8 0 8 #minecraft:base_stone_overworld'), + cmd('/execute as @a run tellraw @s "each"'), + *setup('/kill @e[type=minecraft:armor_stand]', '/setblock 4 210 4 minecraft:air', '/setblock 5 210 5 minecraft:air', + '/scoreboard objectives remove exec', '/tp @s 8.5 230 8.5 0 0'), + {'op': 'tick', 'n': 25}, + ] + + +def items_and_loot(): + return [ + *setup('/clear @s', '/gamemode survival'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_count",count:3}'), + cmd('/item replace entity @s weapon.mainhand with minecraft:stone 10'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_count",count:3}'), + cmd('/clear @s minecraft:stone 0'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_count",count:5,add:true}'), + cmd('/clear @s minecraft:stone 0'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:limit_count",limit:{max:4}}'), + cmd('/clear @s minecraft:stone 0'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_name",name:"Rock"}'), + cmd('/data get entity @s SelectedItem'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_name",name:{text:"Item",color:"red"},target:"item_name"}'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_lore",lore:["one","two"],mode:"replace_all"}'), + cmd('/item modify entity @s weapon.mainhand [{function:"minecraft:set_count",count:2},{function:"minecraft:set_custom_data",tag:{a:1b}}]'), + cmd('/data get entity @s SelectedItem'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_components",components:{"minecraft:max_stack_size":16}}'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:filtered",item_filter:{items:"minecraft:dirt"},on_pass:{function:"minecraft:set_count",count:1}}'), + cmd('/clear @s minecraft:stone 0'), + cmd('/item replace entity @s weapon.mainhand with minecraft:diamond_sword'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_damage",damage:0.5}'), + cmd('/data get entity @s SelectedItem.components'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_enchantments",enchantments:{"minecraft:sharpness":3}}'), + cmd('/data get entity @s SelectedItem.components."minecraft:enchantments"'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:set_enchantments",enchantments:{"minecraft:sharpness":1},add:true}'), + cmd('/data get entity @s SelectedItem.components."minecraft:enchantments"'), + cmd('/item modify entity @s weapon.mainhand {function:"minecraft:toggle_tooltips",toggles:{"minecraft:enchantments":false}}'), + cmd('/item modify entity @s armor.head {function:"minecraft:set_count",count:1}'), + cmd('/item modify entity @s weapon.offhand {function:"minecraft:set_count",count:1}'), + cmd('/item modify entity @s hotbar.* {function:"minecraft:set_count",count:1}'), + cmd('/item modify entity @s weapon.mainhand minecraft:nonexistent'), + cmd('/item replace entity @s hotbar.1 from entity @s weapon.mainhand'), + cmd('/item replace entity @s hotbar.2 from entity @s weapon.mainhand {function:"minecraft:set_count",count:1}'), + cmd('/clear @s minecraft:diamond_sword 0'), + cmd('/setblock 3 206 3 minecraft:barrel'), + cmd('/item replace block 3 206 3 container.4 with minecraft:emerald 7'), + cmd('/item modify block 3 206 3 container.4 {function:"minecraft:set_count",count:2}'), + cmd('/item modify block 3 206 3 container.5 {function:"minecraft:set_count",count:2}'), + cmd('/item modify block 3 206 3 container.99 {function:"minecraft:set_count",count:2}'), + cmd('/item modify block 3 207 3 container.0 {function:"minecraft:set_count",count:2}'), + cmd('/data get block 3 206 3 Items'), + cmd('/item replace entity @s hotbar.3 from block 3 206 3 container.4'), + cmd('/item replace block 3 206 3 container.0 from entity @s hotbar.3'), + cmd('/data get block 3 206 3 Items'), + cmd('/loot give @s loot minecraft:blocks/stone'), + cmd('/loot give @s loot minecraft:blocks/dirt'), + cmd('/loot insert 3 206 3 loot minecraft:blocks/oak_planks'), + cmd('/loot replace block 3 206 3 container.8 loot minecraft:blocks/cobblestone'), + cmd('/loot replace entity @s hotbar.5 loot minecraft:blocks/glass'), + cmd('/loot spawn 3 210 3 loot minecraft:blocks/stone'), + cmd('/loot give @s loot {pools:[{rolls:1,entries:[{type:"minecraft:item",name:"minecraft:apple",functions:[{function:"minecraft:set_count",count:4}]}]}]}'), + cmd('/setblock 2 205 2 minecraft:stone'), + cmd('/loot give @s mine 2 205 2'), + cmd('/loot give @s mine 2 205 2 mainhand'), + cmd('/loot give @s mine 2 205 2 minecraft:diamond_pickaxe[minecraft:enchantments={"minecraft:silk_touch":1}]'), + cmd('/data get block 3 206 3 Items'), + cmd('/clear @s minecraft:cobblestone 0'), + cmd('/clear @s minecraft:apple 0'), + cmd('/give @s minecraft:written_book[minecraft:written_book_content={title:"T",author:"A",pages:["p"]}]'), + cmd('/give @s minecraft:potion[minecraft:potion_contents={potion:"minecraft:swiftness"}] 2'), + cmd('/give @s minecraft:air'), + cmd('/give @s minecraft:stone 6401'), + cmd('/clear @s #minecraft:logs'), + cmd('/clear @s *[minecraft:custom_data]'), + cmd('/clear @s'), + *setup('/setblock 3 206 3 minecraft:air', '/setblock 2 205 2 minecraft:air', '/kill @e[type=minecraft:item]', '/gamemode creative'), + ] + + +def world_misc(): + return [ + cmd('/setblock 1 210 1 minecraft:stone keep'), + cmd('/setblock 1 210 1 minecraft:dirt keep'), + cmd('/setblock 1 210 1 minecraft:dirt destroy'), + cmd('/setblock 1 210 1 minecraft:sand strict'), + cmd('/setblock 1 210 1 minecraft:air replace'), + cmd('/fill 0 210 0 2 212 2 minecraft:stone outline'), + cmd('/fill 0 210 0 2 212 2 minecraft:glass keep'), + cmd('/fill 0 210 0 2 212 2 minecraft:dirt replace #minecraft:base_stone_overworld'), + cmd('/fill 0 210 0 2 212 2 minecraft:air strict'), + cmd('/fill 0 210 0 100 300 100 minecraft:stone'), + cmd('/setblock 0 211 0 minecraft:oak_sign{front_text:{messages:["a","b","c","d"]}}'), + cmd('/data get block 0 211 0 front_text.messages'), + cmd('/clone 0 211 0 0 211 0 1 211 1 replace move'), + cmd('/clone 1 211 1 1 211 1 0 211 0 filtered minecraft:oak_sign'), + cmd('/clone 0 211 0 0 211 0 0 211 0'), + cmd('/clone 0 211 0 0 211 0 0 212 0 replace force'), + cmd('/clone from minecraft:overworld 0 211 0 0 211 0 to minecraft:overworld 2 211 2'), + cmd('/fill 0 210 0 2 212 2 minecraft:air'), + cmd('/fillbiome 0 200 0 15 215 15 minecraft:desert'), + cmd('/execute if biome 4 205 4 minecraft:desert'), + cmd('/fillbiome 0 200 0 15 215 15 minecraft:plains replace minecraft:desert'), + cmd('/fillbiome 0 200 0 15 215 15 minecraft:plains replace minecraft:desert'), + cmd('/fillbiome 0 0 0 1000 300 1000 minecraft:plains'), + cmd('/forceload query'), + cmd('/forceload add 0 0'), + cmd('/forceload add 0 0'), + cmd('/forceload query 0 0'), + cmd('/forceload query 40 40'), + cmd('/forceload add 32 32 47 47'), + cmd('/forceload query'), + cmd('/forceload remove 32 32'), + cmd('/forceload remove all'), + cmd('/forceload query'), + cmd('/forceload add 0 0 1000 1000'), + cmd('/particle minecraft:flame 4 210 4'), + cmd('/particle minecraft:dust{color:[1.0,0.0,0.0],scale:1.0} 4 210 4 0 0 0 0 5 force @s'), + cmd('/particle minecraft:block{block_state:"minecraft:stone"} 4 210 4 1 1 1 0.1 10 normal @a'), + cmd('/playsound minecraft:block.note_block.harp master @s'), + cmd('/playsound minecraft:block.note_block.harp record @s 4 210 4 1 2 0'), + cmd('/playsound minecraft:block.note_block.harp master @a 1000 210 1000'), + cmd('/stopsound @s'), + cmd('/stopsound @s master'), + cmd('/stopsound @s * minecraft:block.note_block.harp'), + cmd('/stopsound @s music minecraft:music.game'), + cmd('/swing @s'), + cmd('/swing @s offhand'), + cmd('/swing @e[type=minecraft:pig]'), + cmd('/summon minecraft:armor_stand 4.5 210 4.5 {NoGravity:1b,Tags:["w"],CustomName:{text:"Stand",color:"blue"}}'), + cmd('/swing @e[tag=w]'), + cmd('/summon minecraft:lightning_bolt 4.5 300 4.5'), + cmd('/summon minecraft:pig 4.5 210 4.5 {NoAI:1b,Invulnerable:1b,Tags:["w"],Passengers:[{id:"minecraft:chicken",NoAI:1b,Tags:["w"]}]}'), + cmd('/summon minecraft:pig 4.5 400 4.5'), + cmd('/summon minecraft:pig 30000000 210 4.5'), + cmd('/summon minecraft:player'), + cmd('/summon minecraft:marker 4.5 210 4.5 {Tags:["w","mk"]}'), + cmd('/gamemode spectator'), + cmd('/spectate @e[tag=mk,limit=1]'), + cmd('/spectate @e[type=minecraft:armor_stand,tag=w,limit=1]'), + cmd('/spectate @e[type=minecraft:pig,tag=w,limit=1] @s'), + cmd('/spectate @e[type=minecraft:chicken,tag=w,limit=1] Player'), + cmd('/spectate'), + cmd('/spectate @e[tag=nothing,limit=1]'), + cmd('/gamemode creative'), + cmd('/attribute @e[type=minecraft:pig,tag=w,limit=1] minecraft:waypoint_transmit_range base set 100'), + cmd('/waypoint list'), + cmd('/waypoint modify @e[type=minecraft:pig,tag=w,limit=1] color gold'), + cmd('/waypoint modify @e[tag=mk,limit=1] color gold'), + cmd('/waypoint list'), + cmd('/waypoint modify @e[tag=w] color gold'), + cmd('/attribute @s minecraft:waypoint_transmit_range base set 0'), + cmd('/waypoint list'), + cmd('/attribute @e[type=minecraft:pig,tag=w,limit=1] minecraft:waypoint_transmit_range base set 0'), + cmd('/waypoint list'), + cmd('/attribute @s minecraft:waypoint_transmit_range base reset'), + cmd('/waypoint list'), + cmd('/dialog show @s minecraft:custom_options'), + cmd('/dialog show @s minecraft:nonexistent'), + cmd('/dialog show @s {type:"minecraft:confirmation",title:"Sure?",yes:{label:"Yes"},no:{label:"No"}}'), + cmd('/dialog show @s {type:"minecraft:notice"}'), + cmd('/dialog show @e[tag=w] minecraft:server_links'), + cmd('/dialog clear @e[tag=w]'), + cmd('/dialog clear @s'), + cmd('/spreadplayers 8 8 0 1 false @s'), + cmd('/spreadplayers 8 8 5 1 false @s'), + cmd('/spreadplayers 8 8 0 1 under 100 false @s'), + cmd('/kill @e[tag=w]'), + cmd('/tp @s 8.5 230 8.5 0 0'), + cmd('/teleport @s 8.5 230 8.5 facing 0 230 0'), + cmd('/teleport @s 8.5 230 8.5 facing entity @s'), + cmd('/tp @s 30000000 230 0'), + cmd('/tp 8.5 230 8.5'), + cmd('/rotate @s facing 0 230 0'), + cmd('/rotate @s ~10 ~'), + cmd('/tp @s 8.5 230 8.5 0 0'), + cmd('/locate biome minecraft:plains'), + cmd('/locate biome #minecraft:is_ocean'), + cmd('/locate structure minecraft:village_plains'), + cmd('/locate structure #minecraft:village'), + cmd('/locate structure minecraft:end_city'), + cmd('/locate poi minecraft:meeting'), + cmd('/place template minecraft:nonexistent 4 210 4'), + cmd('/place feature minecraft:oak 4 210 4'), + cmd('/place jigsaw minecraft:village/plains/town_centers minecraft:bottom 1 4 210 4'), + cmd('/place structure minecraft:nonexistent'), + *setup('/kill @e[type=!minecraft:player]', '/fill 0 200 0 15 228 15 air', '/forceload remove all', '/tp @s 8.5 230 8.5 0 0'), + {'op': 'tick', 'n': 25}, + ] + + +def progression(): + return [ + *setup('/gamemode survival', '/experience set @s 0 levels', '/experience set @s 0 points'), + cmd('/advancement grant @s only minecraft:story/mine_stone'), + cmd('/advancement grant @s only minecraft:story/mine_stone'), + cmd('/advancement revoke @s only minecraft:story/mine_stone'), + cmd('/advancement revoke @s only minecraft:story/mine_stone'), + cmd('/advancement grant @s only minecraft:story/upgrade_tools minecraft:stone_pickaxe'), + cmd('/advancement grant @s only minecraft:story/upgrade_tools minecraft:stone_pickaxe'), + cmd('/advancement grant @s only minecraft:story/upgrade_tools minecraft:nonexistent'), + cmd('/advancement revoke @s only minecraft:story/upgrade_tools minecraft:stone_pickaxe'), + cmd('/advancement grant @s until minecraft:story/smelt_iron'), + cmd('/advancement grant @s from minecraft:story/root'), + cmd('/advancement revoke @s through minecraft:story/iron_tools'), + cmd('/advancement grant @s everything'), + cmd('/advancement grant @s everything'), + cmd('/experience query @s levels'), + cmd('/experience query @s points'), + cmd('/advancement revoke @s everything'), + cmd('/advancement revoke @s everything'), + cmd('/advancement grant @s only minecraft:nonexistent'), + cmd('/recipe give @s minecraft:oak_planks'), + cmd('/recipe give @s minecraft:oak_planks'), + cmd('/recipe take @s minecraft:oak_planks'), + cmd('/recipe take @s minecraft:oak_planks'), + cmd('/recipe give @s *'), + cmd('/recipe give @s *'), + cmd('/recipe take @s *'), + cmd('/recipe take @s *'), + cmd('/experience add @s -5 levels'), + cmd('/experience add @s 1000'), + cmd('/experience query @s levels'), + cmd('/experience set @s 100 points'), + cmd('/experience set @s 1000 points'), + cmd('/experience add @e[type=!minecraft:player] 1'), + *setup('/gamemode creative'), + ] + + +def functions_and_packs(): + return [ + cmd('/function minecraft:nonexistent'), + cmd('/function #minecraft:load'), + cmd('/function #minecraft:tick'), + cmd('/debug function minecraft:nonexistent'), + cmd('/schedule function minecraft:nonexistent 10'), + cmd('/schedule clear minecraft:nonexistent'), + cmd('/datapack list'), + cmd('/datapack list available'), + cmd('/datapack list enabled'), + cmd('/datapack enable vanilla'), + cmd('/datapack disable vanilla'), + cmd('/datapack enable "file/missing"'), + cmd('/datapack enable trade_rebalance'), + cmd('/datapack disable trade_rebalance'), + cmd('/reload'), + {'op': 'tick', 'n': 5, 'record': True}, + ] + + +def ticking(): + return [ + cmd('/tick query'), + cmd('/tick rate 40'), + cmd('/tick query'), + cmd('/tick rate 20'), + cmd('/tick freeze'), + cmd('/tick query'), + cmd('/tick freeze'), + cmd('/tick step'), + cmd('/tick step 5'), + cmd('/tick step stop'), + cmd('/tick step stop'), + cmd('/tick unfreeze'), + cmd('/tick unfreeze'), + cmd('/tick step'), + cmd('/tick sprint stop'), + cmd('/tick rate 1'), + cmd('/tick rate 20'), + cmd('/stopwatch create harness:t'), + cmd('/stopwatch restart harness:t'), + cmd('/stopwatch restart harness:missing'), + cmd('/stopwatch remove harness:t'), + cmd('/stopwatch remove harness:t'), + cmd('/stopwatch remove harness:a'), + cmd('/random value 1..100 harness:seq'), + cmd('/random value 1..100 harness:seq'), + cmd('/random roll 1..6 harness:dice'), + cmd('/random reset harness:seq'), + cmd('/random value 1..100 harness:seq'), + cmd('/random reset harness:seq 42'), + cmd('/random value 1..100 harness:seq'), + cmd('/random reset harness:seq 42 false false'), + cmd('/random value 1..100 harness:seq'), + cmd('/random reset *'), + cmd('/random value 1..100 harness:seq'), + cmd('/random value 1..2147483647'), + cmd('/random value -2147483648..2147483647'), + cmd('/time query gametime'), + cmd('/time query day'), + cmd('/time set 0'), + cmd('/time set day'), + cmd('/time set midnight'), + cmd('/time set sunset'), + cmd('/time add -500'), + cmd('/time set 1000'), + ] + + +def compute(): + return [ + cmd('/compute default integer 5'), + cmd('/compute default integer {type:"minecraft:add",left:2,right:3}'), + cmd('/compute default integer {type:"minecraft:div",left:7,right:2}'), + cmd('/compute default integer {type:"minecraft:div",left:7,right:0}'), + cmd('/compute default integer {type:"minecraft:mod",left:-7,right:3}'), + cmd('/compute default integer {type:"minecraft:floor_mod",left:-7,right:3}'), + cmd('/compute default integer {type:"minecraft:floor_div",left:-7,right:2}'), + cmd('/compute default integer {type:"minecraft:pow",left:2,right:10}'), + cmd('/compute default integer {type:"minecraft:max",values:[1,9,4]}'), + cmd('/compute default integer {type:"minecraft:min",values:[1,9,4]}'), + cmd('/compute default integer {type:"minecraft:abs",value:-4}'), + cmd('/compute default integer {type:"minecraft:negate",value:4}'), + cmd('/compute default integer {type:"minecraft:from_float",value:2.7}'), + cmd('/compute default integer minecraft:brewing/uses_default'), + cmd('/compute default integer minecraft:cooking/time_coal'), + cmd('/compute default integer minecraft:cooking/fast_burn_time_reduction_factor'), + cmd('/compute default integer minecraft:nonexistent'), + cmd('/compute default float 2.5'), + cmd('/compute default float 2.5 2'), + cmd('/compute default float 3'), + cmd('/compute default float {type:"minecraft:div",left:1,right:0}'), + cmd('/compute default float {type:"minecraft:sqrt",value:2}'), + cmd('/compute default float {type:"minecraft:sqrt",value:-1}'), + cmd('/compute default float {type:"minecraft:mul",left:1.5,right:4}'), + cmd('/compute default float {type:"minecraft:sub",left:1.5,right:4}'), + cmd('/compute default float {type:"minecraft:floor",value:-1.5}'), + cmd('/compute default float {type:"minecraft:ceil",value:-1.5}'), + cmd('/compute default float {type:"minecraft:round",value:2.5}'), + cmd('/compute default float {type:"minecraft:from_int",value:3}'), + cmd('/compute default float {type:"minecraft:avg",values:[1,2]}'), + cmd('/compute default float minecraft:brewing/speed_default'), + cmd('/compute default float minecraft:cooking/speed_default 100'), + cmd('/compute block 8 229 8 float minecraft:cooking/speed_default'), + cmd('/compute entity @s integer {type:"minecraft:add",left:1,right:1}'), + cmd('/compute entity @e[type=minecraft:pig,limit=1] integer 1'), + cmd('/compute block 8 400 8 integer 1'), + ] + + +def social(): + return [ + *setup('/scoreboard objectives add trig trigger', '/scoreboard objectives add plain dummy'), + cmd('/trigger trig'), + cmd('/scoreboard players enable @s trig'), + cmd('/scoreboard players enable @s trig'), + cmd('/scoreboard players enable @s plain'), + cmd('/trigger trig'), + cmd('/trigger trig'), + cmd('/scoreboard players enable @s trig'), + cmd('/trigger trig add 5'), + cmd('/scoreboard players enable @s trig'), + cmd('/trigger trig set 3'), + cmd('/scoreboard players get @s trig'), + cmd('/trigger plain'), + cmd('/scoreboard players display name @s trig "Shown"'), + cmd('/scoreboard players display numberformat @s trig styled {color:"red"}'), + cmd('/scoreboard players display numberformat @s trig fixed "X"'), + cmd('/scoreboard players display numberformat @s trig blank'), + cmd('/scoreboard players display numberformat @s trig'), + cmd('/scoreboard objectives modify trig numberformat fixed "Y"'), + cmd('/scoreboard objectives modify trig displayautoupdate true'), + cmd('/scoreboard objectives setdisplay sidebar'), + cmd('/scoreboard objectives setdisplay sidebar.team.red trig'), + cmd('/scoreboard players operation @s trig = @s trig'), + cmd('/scoreboard players operation @s trig /= @s plain'), + cmd('/scoreboard players operation @s trig >< @s plain'), + cmd('/scoreboard players list'), + cmd('/scoreboard players reset @s'), + cmd('/scoreboard players list @s'), + cmd('/teammsg hello'), + cmd('/team add blue "Blue Team"'), + cmd('/team join blue'), + cmd('/teammsg hello team'), + cmd('/tm short'), + cmd('/team modify blue friendlyFire false'), + cmd('/team modify blue friendlyFire false'), + cmd('/team modify blue seeFriendlyInvisibles false'), + cmd('/team modify blue nametagVisibility hideForOtherTeams'), + cmd('/team modify blue deathMessageVisibility never'), + cmd('/team modify blue collisionRule pushOwnTeam'), + cmd('/team modify blue suffix " [B]"'), + cmd('/team modify blue displayName "Blues"'), + cmd('/team modify blue color reset'), + cmd('/team list blue'), + cmd('/team empty blue'), + cmd('/team empty blue'), + cmd('/team join blue fake1 fake2'), + cmd('/team list blue'), + cmd('/team leave fake1'), + cmd('/team remove blue'), + cmd('/team list'), + cmd('/msg @s'), + cmd('/tell Player hi'), + cmd('/w @a hi all'), + cmd('/me'), + cmd('/say @s says'), + cmd('/tellraw @s {"selector":"@s"}'), + cmd('/tellraw @s {"score":{"name":"@s","objective":"trig"}}'), + cmd('/tellraw @s {"nbt":"SelectedItemSlot","entity":"@s"}'), + cmd('/tellraw @s {"keybind":"key.jump"}'), + cmd('/tellraw @s {"text":"click","click_event":{"action":"run_command","command":"/say x"},"underlined":true}'), + cmd('/title @s title {"selector":"@s"}'), + cmd('/list uuids'), + cmd('/help'), + cmd('/help execute'), + cmd('/help scoreboard players'), + cmd('/help nonexistent'), + *setup('/scoreboard objectives remove trig', '/scoreboard objectives remove plain'), + ] + + +def test_command(): + return [ + cmd('/test clearall'), + cmd('/test stop'), + cmd('/test pos'), + cmd('/test locate minecraft:always_pass'), + cmd('/test runclosest'), + cmd('/test resetclosest'), + cmd('/test runfailed'), + cmd('/test clearthese'), + cmd('/test verify minecraft:always_pass'), + ] + + def groups(): return [ ('setup', group_setup()), @@ -336,4 +815,13 @@ def groups(): ('blocks and border', world_blocks()), ('entities', entities()), ('scores, teams and bossbars', scores()), + ('execute', execute()), + ('items and loot', items_and_loot()), + ('world', world_misc()), + ('progression', progression()), + ('functions and packs', functions_and_packs()), + ('ticking and random', ticking()), + ('compute', compute()), + ('social and scoreboard', social()), + ('test', test_command()), ]