Merge pull request #2239 from kacpherek/fix/breeze-shot-spread-and-aim

🤖 Agent: Read against the vanilla 26.3 sources (Make breeze shots follow the world difficulty and aim higher at riders) and proven in contrib-gate-21's union of 72 kacpherek PRs: 95 parity harnesses on playhorizon and the Mac mini, clippy, 1534 tests, lan_e2e 23 checks in-frame and with --server-thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-27 11:27:42 +01:00
committed by GitHub
7 changed files with 28 additions and 4 deletions
@@ -1061,6 +1061,7 @@ pub fn main() -> horizon_client::Result<()> {
uuid: PLAYER_UUID,
allies: Default::default(),
remote: false,
passenger: false,
}
});
let mut scratch = LegacyRandom::new(0);
@@ -210,6 +210,7 @@ impl Game<'_> {
uuid: self.level.player_uuid.unwrap_or_default(),
allies: std::sync::Arc::new(self.player_allies()),
remote: false,
passenger: self.riding.is_some(),
})
}
/// Biome facts at a position for finalizeSpawn and variant rules.
@@ -369,6 +369,7 @@ mod tests {
uuid: [0; 4],
allies: Default::default(),
remote: false,
passenger: false,
}
}
+5
View File
@@ -1320,6 +1320,8 @@ pub struct Seen {
pub active_raid: bool,
/// A copper golem's `openedChestPos` (`ContainerUser.hasContainerOpen`).
pub opened_chest: Option<[i32; 3]>,
/// `isPassenger`.
pub passenger: bool,
/// A villager's reputation of the player (`getPlayerReputation`).
pub player_rep: i32,
/// `isPushable` and pushed by others (`Entity.push(Entity)` moves it).
@@ -1411,6 +1413,7 @@ impl Mob {
hurt_by: m.ai.last_hurt_by.map(|w| (w, m.ai.last_hurt_by_time)),
active_raid: raider::has_active_raid(m),
opened_chest: m.extra.opened_chest,
passenger: m.extra.mount.is_some(),
player_rep: match (villager, player) {
(true, Some(uuid)) => villager::ext(m).map_or(0, |e| e.gossips.reputation(uuid)),
_ => 0,
@@ -1590,6 +1593,8 @@ pub struct PlayerView {
/// A LAN guest: its own client moves it, and touching mobs push it there
/// (`EntitySelector.pushableBy` on the client).
pub remote: bool,
/// `isPassenger`.
pub passenger: bool,
}
impl PlayerView {
/// `LivingEntity.hasEffect`, by id without namespace.
@@ -1137,6 +1137,7 @@ struct Quarry {
position: Vec3,
head_yaw: f32,
height: f64,
passenger: bool,
}
fn quarry(w: &MobWorld, who: Who) -> Option<Quarry> {
let t = w.target_info(who)?;
@@ -1148,6 +1149,7 @@ fn quarry(w: &MobWorld, who: Who) -> Option<Quarry> {
position: t.position,
head_yaw,
height: t.bounds.max_position().y - t.bounds.min_position().y,
passenger: t.passenger,
})
}
/// `BreezeUtil.randomPointBehindTarget`.
@@ -1233,7 +1235,8 @@ fn shoot_tick(m: &mut Mob, cx: &mut Bx) {
let firing = super::breeze::firing_y(m);
let (xd, yd, zd) = (
q.position.x - m.position.x,
q.position.y + q.height * 0.3 - firing,
// target.getY(target.isPassenger() ? 0.8 : 0.3).
q.position.y + q.height * if q.passenger { 0.8 } else { 0.3 } - firing,
q.position.z - m.position.z,
);
let start = Vec3::new(m.position.x, firing, m.position.z);
@@ -1242,14 +1245,19 @@ fn shoot_tick(m: &mut Mob, cx: &mut Bx) {
start,
Some(Who::Mob(m.id)),
);
// The new entity's own random spreads the shot (5 - difficulty * 4 at
// normal): not the breeze's.
// The new entity's own random spreads the shot (5 - difficulty id * 4):
// not the breeze's.
let mut own = LegacyRandom::new(
cx.now
.wrapping_mul(0x5DEE_CE66)
.wrapping_add(i64::from(m.id)),
);
p.shoot(&mut own, [xd, yd, zd], 0.7, -3.0);
p.shoot(
&mut own,
[xd, yd, zd],
0.7,
5.0 - f32::from(cx.w.difficulty.id) * 4.0,
);
cx.events.push(MobEvent::Projectile(p));
breeze_sound(m, cx, "entity.breeze.shoot", 1.5);
}
@@ -39,6 +39,8 @@ pub struct LocalDifficulty {
pub normal: bool,
/// The world difficulty is hard.
pub hard: bool,
/// `Difficulty.getId`: 0 peaceful to 3 hard.
pub id: u8,
}
/// `DimensionType.MOON_BRIGHTNESS_PER_PHASE`.
pub const MOON_BRIGHTNESS: [f32; 8] = [1.0, 0.75, 0.5, 0.25, 0.0, 0.25, 0.5, 0.75];
@@ -53,6 +55,7 @@ impl LocalDifficulty {
effective: 0.0,
normal,
hard,
id: base,
};
}
let global = ((total as f32 - 72000.0) / 1_440_000.0).clamp(0.0, 1.0) * 0.25;
@@ -66,6 +69,7 @@ impl LocalDifficulty {
effective: f32::from(base) * (0.75 + global + local),
normal,
hard,
id: base,
}
}
/// `getSpecialMultiplier`.
+4
View File
@@ -25,6 +25,8 @@ pub struct TargetInfo {
pub can_be_seen_as_enemy: bool,
pub is_player: bool,
pub creative: bool,
/// `isPassenger`.
pub passenger: bool,
}
impl MobWorld<'_> {
/// The biome's base temperature at a position.
@@ -249,6 +251,7 @@ impl MobWorld<'_> {
can_be_seen_as_enemy: true,
is_player: true,
creative: p.creative,
passenger: p.passenger,
}),
Who::Mob(id) => self.seen(id).map(|s| TargetInfo {
position: s.position,
@@ -258,6 +261,7 @@ impl MobWorld<'_> {
can_be_seen_as_enemy: !s.playing_dead,
is_player: false,
creative: false,
passenger: s.passenger,
}),
}
}