Axes on copper: a shield in the off hand comes first, and sculk hears it

Scraping and waxing off copper already swing the arm, show the scrape and
wax-off particles and play the axe sound on main (#59, #104). Two gaps were
left in BlockTransformer.transformBlock:

- playerHasBlockingItemUseIntent: with a shield in the off hand, right-clicking
  with an axe raises the shield instead of scraping, unless sneaking.
- The block_change game event, which sculk sensors pick up.

Fixes #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-15 11:47:02 +02:00
parent 4abf648a85
commit e162f9cdb7
+11
View File
@@ -6543,6 +6543,16 @@ impl Game<'_> {
else {
return Ok(false);
};
// playerHasBlockingItemUseIntent: a shield in the off hand is raised
// instead, unless sneaking.
let shield = self
.offhand
.as_ref()
.and_then(|s| self.res.items.get(&s.item))
.is_some_and(|i| i.blocks_attacks.is_some());
if shield && !self.keys.contains(&KeyCode::ShiftLeft) {
return Ok(false);
}
let face_name = match face {
[0, -1, 0] => "down",
[0, 1, 0] => "up",
@@ -6601,6 +6611,7 @@ impl Game<'_> {
1.0,
);
self.damage_held(damage);
self.post_block_game_event("minecraft:block_change", pos, self.sculk_actor(), Some(new));
Ok(true)
}
fn set_state_named(&mut self, pos: [i32; 3], name: &str, keep: &[&str]) -> Result<bool> {