mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Spectators make no splash when entering water
This commit is contained in:
1 parent
43062d7bbd
commit
513cd005e5
2 files changed
+34
No files matched your search
@@ -3948,6 +3948,36 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// `Player.doWaterSplashEffect`: a spectator entering water makes no splash
|
||||
/// sound, particles or game event; everyone else does.
|
||||
#[test]
|
||||
fn a_spectator_entering_water_makes_no_splash() {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../../.local/horizon-client")
|
||||
.join(horizon_core::VANILLA_VERSION);
|
||||
if !root.join("movement-properties.nbt").exists() {
|
||||
return;
|
||||
}
|
||||
let assets = Assets::load(&root).unwrap();
|
||||
let render = assets.reload(&root).unwrap();
|
||||
let binding = crate::collisions::load(&root, assets.registry).unwrap();
|
||||
let resources = MotionResources::load(&root, &assets).unwrap();
|
||||
for spectator in [false, true] {
|
||||
let mut scene = World::test_scene(&assets, &render, 2).unwrap();
|
||||
let mut player = PlayerMotion::new(&resources, Vec3::new(20.5, 20.0, 20.5)).unwrap();
|
||||
player.spectator = spectator;
|
||||
let mut w = MotionWorld {
|
||||
entities: &[],
|
||||
player: &mut player,
|
||||
scene: &mut scene,
|
||||
assets: &assets,
|
||||
collision_binding: &binding,
|
||||
resources: &resources,
|
||||
};
|
||||
horizon_world::entity_fluid_tick::EntityFluidTickWorld::water_splash(&mut w).unwrap();
|
||||
assert_eq!(w.player.events.is_empty(), spectator);
|
||||
}
|
||||
}
|
||||
/// A client's own fall (multiplayer, a LAN guest, single player on its
|
||||
/// server thread) plays its landing but never hurts it: only the server
|
||||
/// does (`Entity.hurt` on a client), so a server that cancels fall damage
|
||||
|
||||
@@ -425,6 +425,10 @@ impl EntityFluidTickWorld for MotionWorld<'_, '_, '_> {
|
||||
self.player.fluids.first_tick
|
||||
}
|
||||
fn water_splash(&mut self) -> Result<()> {
|
||||
// `Player.doWaterSplashEffect`: spectators skip the effect (and its random draws).
|
||||
if self.player.spectator {
|
||||
return Ok(());
|
||||
}
|
||||
water_splash::water_splash(self, 1_000_000).map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user