Crossbow mobs: draw the attack delay before the loading sound's pitch

Keeps the mob random stream's order from before this branch, so a
pillager's or piglin's attack delays don't change for the same seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
levzzzandClaude Opus 5.5 committed 2026-11-02 23:58:19 +05:00
1 parent 8c579c0ef1
commit fa876269f3
1 file changed
+9 -7
+9 -7
View File
@@ -564,19 +564,21 @@ impl Goal for CrossbowAttack {
m.extra.using_item = 0;
m.extra.flag = false;
self.state = Crossbow::Charged;
let weapon = m
.extra
.main_hand_stack()
.cloned()
.unwrap_or_else(|| ItemStack::new("minecraft:crossbow", 1));
set_crossbow_charged(m, true);
// The attack delay is drawn before the sound's pitch, as before.
self.attack_delay = 20 + m.random.next_int_bound(20).unwrap_or(0);
let pitch = 1.0 / (m.random.next_float() * 0.5 + 1.0) + 0.2;
cx.events.push(MobEvent::CrossbowLoad {
mob: m.id,
at: m.center(),
pitch,
weapon: m
.extra
.main_hand_stack()
.cloned()
.unwrap_or_else(|| ItemStack::new("minecraft:crossbow", 1)),
weapon,
});
set_crossbow_charged(m, true);
self.attack_delay = 20 + m.random.next_int_bound(20).unwrap_or(0);
}
}
Crossbow::Charged => {