From 87d577e5665b72ae2c54d9044ad0dfa37f45b1fa Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 00:20:08 +0100 Subject: [PATCH] Check rain at the player's and arrow's position Arrows now ask whether it rains at their spot (biome precipitation and blocks above, Level.isRainingAt) instead of just the sky light, and a Riptide trident needs rain at the player's position. Rain also puts out a burning player (Entity.baseTick), in the window and for guests on the server thread. --- crates/horizon-client/src/game.rs | 9 +++++ .../src/game/block_entity_anims.rs | 2 +- crates/horizon-client/src/game/creatures.rs | 6 +-- crates/horizon-client/src/game/lan_actions.rs | 2 + crates/horizon-client/src/game/powder_snow.rs | 38 ++++++++++++++++++- crates/horizon-client/src/game/trident.rs | 6 +-- 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index db49087b2..87d87f8a3 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4669,6 +4669,7 @@ impl Game<'_> { } } self.powder_snow_fire()?; + self.rain_extinguish_in_frame(); self.tick_totem(); let Some(player) = self.player.as_mut() else { return Ok(()); @@ -9903,6 +9904,14 @@ impl Game<'_> { }; Some(t < 0.15) } + /// `Level.isRainingAt`: it rains, the sky light is 15, nothing that stops + /// motion is above, and the biome's precipitation there is rain. + fn raining_at(&self, p: BlockPos) -> bool { + self.world.weather.levels(1.0).0 > 0.2 + && self.world.light(p.x, p.y, p.z) >> 4 == 15 + && self.rain_height(p.x, p.z) <= p.y + && self.precipitation(p.x, p.y, p.z) == Some(false) + } /// `getHeight(Heightmap.Types.MOTION_BLOCKING, x, z)`: one above the /// highest block in `blocks_motion_in_heightmap` or holding a fluid. fn rain_height(&self, x: i32, z: i32) -> i32 { diff --git a/crates/horizon-client/src/game/block_entity_anims.rs b/crates/horizon-client/src/game/block_entity_anims.rs index 6f92d7f55..7790a48f3 100644 --- a/crates/horizon-client/src/game/block_entity_anims.rs +++ b/crates/horizon-client/src/game/block_entity_anims.rs @@ -547,7 +547,7 @@ impl Game<'_> { }); } /// `Entity.isInRain`: rain at the block position or at the top of the box. - fn in_rain(&mut self, at: Vec3, top: f64) -> bool { + pub(super) fn in_rain(&mut self, at: Vec3, top: f64) -> bool { let p = BlockPos::new( at.x.floor() as i32, at.y.floor() as i32, diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index e895cb7f7..632fae3e7 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2118,11 +2118,9 @@ impl Game<'_> { ArrowEvent::ShootEvent | ArrowEvent::Drop => {} } } - /// `Level.isRainingAt` for arrows: raining, open to the sky (the biome's - /// precipitation is not checked here). + /// `Level.isRainingAt` for arrows. fn arrow_rain(&self) -> impl Fn(BlockPos) -> bool + '_ { - let raining = self.world.weather.levels(1.0).0 > 0.2; - move |p: BlockPos| raining && self.world.light(p.x, p.y, p.z) >> 4 == 15 + move |p: BlockPos| self.raining_at(p) } /// The level as arrows see it. fn arrow_scene<'s>( diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index dc1e74f0b..8928f634a 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -2267,6 +2267,8 @@ impl Game<'_> { game.cauldron_extinguish(*pos); } } + // Entity.baseTick: rain puts out a burning player. + game.rain_extinguish_player(); // WitherRoseBlock.entityInside along those moves. for event in &events { if matches!(event, MotionEvent::InsideWitherRose) { diff --git a/crates/horizon-client/src/game/powder_snow.rs b/crates/horizon-client/src/game/powder_snow.rs index 6a904706f..5b3692df3 100644 --- a/crates/horizon-client/src/game/powder_snow.rs +++ b/crates/horizon-client/src/game/powder_snow.rs @@ -53,7 +53,11 @@ impl Game<'_> { if let Some(player) = self.player.as_mut() { player.fire_ticks = 0; } - // Entity.playEntityOnFireExtinguishedSound + self.extinguish_sound(at); + Ok(()) + } + /// Entity.playEntityOnFireExtinguishedSound + fn extinguish_sound(&mut self, at: [f64; 3]) { let r = self.particles.random(); let pitch = 1.6 + (r.next_float() - r.next_float()) * 0.4; self.audio.play( @@ -62,7 +66,37 @@ impl Game<'_> { 0.7, pitch, ); - Ok(()) + } + /// `Entity.baseTick`: a burning player in the rain (`isInRain`) has the + /// fire put out (`clearFire`). Returns whether it did. + pub(super) fn rain_extinguish_player(&mut self) -> bool { + let Some(player) = self.player.as_ref() else { + return false; + }; + let (at, top) = (player.position, player.bounds().max_position().y); + if player.fire_ticks <= 0 || !self.in_rain(at, top) { + return false; + } + if let Some(player) = self.player.as_mut() { + player.fire_ticks = 0; + } + true + } + /// The in-window player's rain extinguish, with its sound (a server's + /// fire is the server's). + pub(super) fn rain_extinguish_in_frame(&mut self) { + if self.remote.is_some() { + return; + } + let at = self + .player + .as_ref() + .map(|p| [p.position.x, p.position.y, p.position.z]); + if self.rain_extinguish_player() + && let Some(at) = at + { + self.extinguish_sound(at); + } } /// Whether the block at `pos` is powder snow. pub(super) fn is_powder_snow(&self, pos: [i32; 3]) -> bool { diff --git a/crates/horizon-client/src/game/trident.rs b/crates/horizon-client/src/game/trident.rs index d934e85aa..01bc6af5f 100644 --- a/crates/horizon-client/src/game/trident.rs +++ b/crates/horizon-client/src/game/trident.rs @@ -112,7 +112,7 @@ impl Game<'_> { } true } - fn in_water_or_rain(&self) -> bool { + fn in_water_or_rain(&mut self) -> bool { let Some(p) = &self.player else { return false }; let (x, y, z) = ( p.position.x.floor() as i32, @@ -121,8 +121,8 @@ impl Game<'_> { ); let water = self.res.facts().get(self.world.block(x, y, z)).fluid == horizon_client::blocks::Fluid::Water; - let sky = self.world.light(x, y + 1, z) >> 4 == 15; - water || (self.world.weather.raining && sky) + let (at, top) = (p.position, p.bounds().max_position().y); + water || self.in_rain(at, top) } /// The living entities a spinning player can touch this tick, for /// `LivingEntity.checkAutoSpinAttack` (none when not spinning).