diff --git a/crates/horizon-client/src/game/item_draw.rs b/crates/horizon-client/src/game/item_draw.rs index 99d67493b..be0ca56fb 100644 --- a/crates/horizon-client/src/game/item_draw.rs +++ b/crates/horizon-client/src/game/item_draw.rs @@ -165,13 +165,16 @@ pub(super) fn owner_at(position: [f64; 3], yaw: f32, entity_type: &str) -> Owner ..Default::default() } } -/// `UseDuration` of a stack: 72000 for drawn items, the consume time for food. +/// `UseDuration` of a stack (`Item.getUseDuration`): 72000 for drawn items +/// and for `blocks_attacks` items (shields), the consume time for food. fn use_duration(components: &Components) -> i32 { if let Some(c) = components.get("minecraft:consumable") { let seconds = c["consume_seconds"].as_f64().unwrap_or(1.6); return (seconds * 20.0) as i32; } - if components.get("minecraft:kinetic_weapon").is_some() { + if components.get("minecraft:blocks_attacks").is_some() + || components.get("minecraft:kinetic_weapon").is_some() + { return 72_000; } let item_model = components diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index ac5f8a13a..01ae6ca0c 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -2043,6 +2043,18 @@ impl Game<'_> { let using = host.play.get(&g.conn).and_then(|p| p.using()); m.extra.using_item = using.map_or(0, |(_, ticks)| ticks as i32 + 1); m.extra.using_off_hand = using.is_some_and(|(slot, _)| slot == OFFHAND_SLOT); + // AvatarRenderer.getArmPose: the used item's BLOCK animation (an + // item with `blocks_attacks`) raises the arm. + m.extra.blocking = using + .and_then(|(slot, _)| { + if slot == OFFHAND_SLOT { + m.extra.off_hand.as_ref() + } else { + m.extra.main_hand.as_ref() + } + }) + .and_then(|i| self.res.items().get(i)) + .is_some_and(|i| i.blocks_attacks.is_some()); } } diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 636c648f9..5fbe457a0 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -4021,6 +4021,20 @@ impl Game<'_> { // LivingEntity.updatingUsingItem: the ticks the item has been // used before this one. Another player's use particles; a mob's // drawn bow only needs the count (its pull follows it). + if player { + // AvatarRenderer.getArmPose: the used item's BLOCK animation + // (an item with `blocks_attacks`) raises the arm. + let used = if m.extra.using_off_hand { + &m.extra.off_hand + } else { + &m.extra.main_hand + }; + m.extra.blocking = m.extra.using_item > 0 + && used + .as_ref() + .and_then(|i| self.res.items().get(i)) + .is_some_and(|i| i.blocks_attacks.is_some()); + } if m.extra.using_item > 0 { if player { let item = if m.extra.using_off_hand {