Merge pull request #1883 from ludovic111/fix/copper-golem-statue-poses

🤖 Agent: merged after verify (bugs-dezerx-1's fix for a player's bug list, self-checked with pr_ready); harnesses run on main by parity-main, which gates releases.
This commit is contained in:
Ludovic Marie
2026-10-26 02:22:56 +01:00
committed by GitHub
3 changed files with 76 additions and 2 deletions
+10
View File
@@ -8407,6 +8407,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)
@@ -8611,6 +8613,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();
}
@@ -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<L: LevelAccess + ?Sized>(
&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
}
}
+35 -2
View File
@@ -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'] = []