From aa2f60b7bd78179f1e7723c866212fd4e1ec548e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:43:03 +0100 Subject: [PATCH] Copper golem statues turn to their next pose when right-clicked CopperGolemStatueBlock.useItemOn: anything but an axe, an empty hand too, cycles copper_golem_pose with its sound and block_change game event; honeycomb on a weathering statue passes on to waxing. Axe scraping, unwaxing and stripping and honeycomb waxing now count the item as used, and waxing sends its block_change game event, as vanilla's useOn does. The use_item_on harness gains statue cases. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 10 ++++++ crates/horizon-world/src/level/interact.rs | 31 ++++++++++++++++++ tools/test_use_item_on_parity.py | 37 ++++++++++++++++++++-- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 7fcb3be89..ee6df4c38 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -8332,6 +8332,8 @@ impl Game<'_> { 1.0, 1.0, ); + // ItemStack.useOn: a use that acted counts as one of the item. + self.stats.add("used", &stack.item, 1); self.damage_held(damage); self.post_block_game_event("minecraft:block_change", pos, self.sculk_actor(), Some(new)); Ok(true) @@ -8536,6 +8538,14 @@ impl Game<'_> { 1.0, 1.0, ); + // HoneycombItem.useOn's game event, and ItemStack.useOn's used statistic. + self.post_block_game_event( + "minecraft:block_change", + hit.pos, + self.sculk_actor(), + Some(state), + ); + self.stats.add("used", &stack.item, 1); if !self.creative { self.consume_held(); } diff --git a/crates/horizon-world/src/level/interact.rs b/crates/horizon-world/src/level/interact.rs index b8251ba46..7b2195c34 100644 --- a/crates/horizon-world/src/level/interact.rs +++ b/crates/horizon-world/src/level/interact.rs @@ -592,6 +592,37 @@ impl Behaviours { { return InteractionResult::Pass; } + if self.data(state).chain.contains(&Class::CopperGolemStatue) { + return self.turn_statue(level, ticks, pos, state, item); + } self.use_without_item(level, ticks, pos, face, hit, player) } + + /// `CopperGolemStatueBlock.useItemOn` (and its weathering subclass's): anything but an axe + /// (`#minecraft:axes`, every one named `*_axe`), even an empty hand, turns the statue to its + /// next pose; honeycomb waxes a statue that still weathers instead. + fn turn_statue( + &self, + level: &mut L, + ticks: &mut Ticks, + pos: BlockPos, + state: BlockStateId, + item: Option<&str>, + ) -> InteractionResult { + let item = item.unwrap_or("minecraft:air"); + let waxed = self.table.name(state).starts_with("minecraft:waxed_"); + if item.ends_with("_axe") || (item == "minecraft:honeycomb" && !waxed) { + return InteractionResult::Pass; + } + let mut sim = self.sim(level, ticks); + sim.sound( + pos, + &"minecraft:entity.copper_golem_become_statue".into(), + 1.0, + 1.0, + ); + sim.set_block_and_update(pos, self.table.cycle(state, self.props.copper_golem_pose)); + sim.game_event(pos, "minecraft:block_change"); + InteractionResult::Success + } } diff --git a/tools/test_use_item_on_parity.py b/tools/test_use_item_on_parity.py index 89b463116..eabdd04eb 100644 --- a/tools/test_use_item_on_parity.py +++ b/tools/test_use_item_on_parity.py @@ -2,8 +2,9 @@ """Compare a player's right click on a block with vanilla's, for items that are both food and blocks (sweet and glow berries, carrots, potatoes), for sweet berry bushes, for spawn eggs used on a monster spawner, for shears carving -pumpkins, for blocks placed where mobs and armor stands stand, for respawn -anchors and for beds in the Nether and the End. +pumpkins, for copper golem statues turned to their next pose, for blocks +placed where mobs and armor stands stand, for respawn anchors and for beds in +the Nether and the End. Every case has a block at the origin, something above it, and a player three blocks south, survival or creative, hungry or full, sneaking or not, who @@ -228,6 +229,32 @@ def pumpkin_case(rng, states, case): case['cells'] = cells +STATUES = [f'{wax}{age}copper_golem_statue' for wax in ('', 'waxed_') + for age in ('', 'exposed_', 'weathered_', 'oxidized_')] + + +def statue_case(rng, states, case): + """A copper golem statue right-clicked (`CopperGolemStatueBlock.useItemOn`, the weathering + one's): anything but an axe, an empty hand too, turns it to its next pose; honeycomb waxes a + statue that still weathers instead (`HoneycombItem.useOn`), and an axe scrapes or unwaxes it.""" + statue = rng.choice(STATUES) + case['cells'] = [[0, 0, 0, states.any(rng, statue)]] + items = ['-', '-', 'stick', 'honeycomb', 'honeycomb', 'stone', 'copper_ingot', 'diamond_pickaxe', + 'copper_golem_statue'] + if statue != 'copper_golem_statue': + # An axe scrapes or unwaxes the others; on the unaffected one it brings the golem back + # (`CopperGolemStatueBlockEntity.removeStatue`), which Horizon does not do yet. + items.append('iron_axe') + item = rng.choice(items) + use = {'item': '-' if item == '-' else d_plain(item, rng.choice([1, 16])), 'creative': rng.random() < 0.2, + 'sneaking': rng.random() < 0.15, 'food': 20, + 'face': rng.choice(['up', 'up', 'north', 'south', 'west', 'east'])} + if rng.random() < 0.2: + # The item in the off hand, nothing in the main hand. + use.update(offhand=use['item'], item='-') + case['use_item'] = use + + # Entities a block may be placed into (`Entity.blocksBuilding`), and blocks to place. BLOCKERS = ['skeleton', 'zombie', 'pig', 'chicken', 'cow', 'armor_stand', 'slime', 'bat'] PLACED = ['obsidian', 'stone', 'oak_slab', 'oak_fence', 'white_carpet', 'torch', 'glass', 'oak_trapdoor', 'snow'] @@ -290,6 +317,12 @@ def cases(facts, count, seed): case['mode'] = 'dispense' yield case continue + if rng.random() < 0.08: + statue_case(rng, states, case) + case['items'] = [] + case['mode'] = 'dispense' + yield case + continue if rng.random() < 0.12: pumpkin_case(rng, states, case) case['items'] = []