Merge pull request #2676 from kacpherek/fix/golem-shears-uncertainty
🤖 Agent: Merged by Ludovic's AI agent (Claude, contrib-gate-19) after the contribution gate. Checked against vanilla 26.3 and proven in union/cg19-r2 (all round-2 PRs together: clippy, 1722 tests, 135 harnesses, lan_e2e in-frame and on the server thread) and union/cg19-r3 (the same PRs merged with today's main: 96/96 harnesses). Thanks @kacpherek.
This commit is contained in:
@@ -3296,6 +3296,10 @@ impl Game<'_> {
|
||||
self.swing_arm();
|
||||
return Ok(true);
|
||||
}
|
||||
if self.interact_shear_mob(index, &item) {
|
||||
self.swing_arm();
|
||||
return Ok(true);
|
||||
}
|
||||
// AbstractHorse.mobInteract: feed, equip or ride.
|
||||
if self.interact_mount(index, &item) {
|
||||
self.swing_arm();
|
||||
@@ -3825,6 +3829,39 @@ impl Game<'_> {
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
/// `SnowGolem.mobInteract` and `Bogged.mobInteract` with shears: the
|
||||
/// pumpkin or the mushrooms come off (the shearing loot table), the shear
|
||||
/// game event is posted and the tool takes one damage.
|
||||
fn interact_shear_mob(&mut self, index: usize, item: &str) -> bool {
|
||||
let m = &self.mobs[index];
|
||||
if item != "minecraft:shears" || !m.alive() || m.extra.sheared {
|
||||
return false;
|
||||
}
|
||||
let (sound, table, height) = match m.species() {
|
||||
Species::SnowGolem => (
|
||||
"minecraft:entity.snow_golem.shear",
|
||||
"minecraft:shearing/snow_golem",
|
||||
m.eye_height(),
|
||||
),
|
||||
Species::Bogged => (
|
||||
"minecraft:entity.bogged.shear",
|
||||
"minecraft:shearing/bogged",
|
||||
f64::from(m.height()),
|
||||
),
|
||||
_ => return false,
|
||||
};
|
||||
let at = m.position;
|
||||
let tool = self.held().cloned();
|
||||
self.audio.play(sound, Some([at.x, at.y, at.z]), 1.0, 1.0);
|
||||
self.mobs[index].extra.sheared = true;
|
||||
for stack in self.sequence_loot(table, table, tool.as_ref()) {
|
||||
self.spawn_at_location(at, height, stack);
|
||||
}
|
||||
let ctx = self.who_context(Some(horizon_client::mobs::Who::Player), None);
|
||||
self.post_game_event("minecraft:shear", [at.x, at.y, at.z], ctx);
|
||||
self.damage_held_tool();
|
||||
true
|
||||
}
|
||||
/// `Armadillo.mobInteract`: a brush brushes a scute off an adult
|
||||
/// (`brushOffScute`) and loses 16 durability.
|
||||
fn interact_armadillo(&mut self, index: usize, item: &str) -> bool {
|
||||
|
||||
@@ -61,6 +61,8 @@ impl Game<'_> {
|
||||
) && !baby
|
||||
}
|
||||
Species::Sheep => item == "minecraft:shears" || item.ends_with("_dye"),
|
||||
// SnowGolem.mobInteract: shears take the pumpkin off.
|
||||
Species::SnowGolem => item == "minecraft:shears" && !m.extra.sheared,
|
||||
// Bucketable.bucketMobPickup.
|
||||
Species::Cod
|
||||
| Species::Salmon
|
||||
|
||||
@@ -341,12 +341,12 @@ fn snowball_attack(m: &mut Mob, who: Who, _power: f32, cx: &mut Cx) {
|
||||
let zd = t.position.z - m.position.z;
|
||||
let yo = (xd * xd + zd * zd).sqrt() * 0.2;
|
||||
let mut p = Projectile::new(ProjectileKind::Snowball, start, Some(Who::Mob(m.id)));
|
||||
// rangedAttackUncertainty: 14 - 4 * difficulty (normal: 6).
|
||||
// SnowGolem.rangedAttackUncertainty: 12 on every difficulty.
|
||||
p.shoot(
|
||||
&mut crate::projectiles::own_random(m),
|
||||
[xd, yd + yo - start.y, zd],
|
||||
1.6,
|
||||
6.0,
|
||||
12.0,
|
||||
);
|
||||
cx.events.push(MobEvent::Projectile(p));
|
||||
let pitch = 0.4 / (m.random.next_float() * 0.4 + 0.8);
|
||||
|
||||
Reference in New Issue
Block a user