Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.
Rust differential-testinggame-enginegamedevlinuxminecraftminecraft-javareimplementationrustvoxelvulkanwgpu
Push a boat by the current it sits in
MSedgeMC75d84aaacddf
diff --git a/crates/horizon-client/src/entities.rs b/crates/horizon-client/src/entities.rsindex 398149827..9ed952900 100644--- a/crates/horizon-client/src/entities.rs+++ b/crates/horizon-client/src/entities.rs@@ -62,6 +62,7 @@ fn slime_at(world: &World, facts: &BlockFacts, x: i32, y: i32, z: i32) -> bool {}mod fluids;+pub use fluids::update_entity_fluids;#[derive(Clone, Debug)]pub struct ItemEntity {diff --git a/crates/horizon-client/src/entities/fluids.rs b/crates/horizon-client/src/entities/fluids.rsindex 89caf1a37..9b7684611 100644--- a/crates/horizon-client/src/entities/fluids.rs+++ b/crates/horizon-client/src/entities/fluids.rs@@ -26,7 +26,12 @@ struct EntityFluidWorld<'a> {world: &'a World,fluids: &'a FluidResources,}-fn update_entity_fluids(+/// `Entity.baseTick`'s fluid step for an entity that is pushed by fluid: its+/// immersion heights, then the current of each fluid it sits in, added to+/// `velocity` with vanilla's scales (water 0.014, lava 0.007 fast or+/// 0.0023333 slow). Items and armour stands call it for themselves; a boat+/// calls it from its own tick, before `floatBoat` scales the velocity.+pub fn update_entity_fluids(bounds: Aabb,position: Vec3,eye_y: f64,@@ -286,6 +291,54 @@ mod tests {assert!(carried.position.x > at.x + 0.5);}+ /// `Entity.baseTick` pushes a boat by the current it sits in: a boat box+ /// in water[level=1..7] gains velocity along the flow, and the same box in+ /// still source water does not. Vanilla's boat tick runs this before+ /// `floatBoat` scales the velocity, which is what `game::boats` does.+ #[test]+ fn a_boat_box_is_pushed_by_the_current_it_sits_in() {+ let root = std::path::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 = crate::assets::Assets::load(&root).unwrap();+ let render = assets.reload(&root).unwrap();+ let facts = crate::blocks::BlockFacts::load(&root, assets.registry).unwrap();+ let fluids = FluidResources::new(&assets, &facts).unwrap();+ let mut world = World::test_scene(&assets, &render, 3).unwrap();+ let stone = assets.registry.default_state("minecraft:stone").unwrap();+ let water = assets.registry.default_state("minecraft:water").unwrap();+ let mut state = assets.registry.state(water).unwrap().clone();+ state.properties.insert("level".into(), "1".into());+ let flowing = assets.registry.resolve(&state).unwrap();+ for x in 19..=21 {+ for z in 19..=21 {+ world.set(x, 3, z, stone).unwrap();+ world.set(x, 4, z, water).unwrap();+ }+ }+ // Boat dimensions: 1.375 wide, 0.5625 tall, eye at its top.+ let at = Vec3::new(20.5, 4.0, 20.5);+ let half = 1.375 / 2.0;+ let bounds = Aabb::new(+ Vec3::new(at.x - half, at.y, at.z - half),+ Vec3::new(at.x + half, at.y + 0.5625, at.z + half),+ );+ let mut still = Vec3::ZERO;+ update_entity_fluids(bounds, at, at.y + 0.5625, &mut still, &world, &fluids);+ assert_eq!(still.x, 0.0, "source water has no current");+ world.set(21, 4, 20, flowing).unwrap();+ let mut carried = Vec3::ZERO;+ update_entity_fluids(bounds, at, at.y + 0.5625, &mut carried, &world, &fluids);+ assert!(+ carried.x > 0.0,+ "the flow pushes the boat along +x, got {}",+ carried.x+ );+ }+#[test]fn armor_stands_follow_flowing_water_but_markers_and_still_water_stay_in_place() {let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))diff --git a/crates/horizon-client/src/game/boats.rs b/crates/horizon-client/src/game/boats.rsindex 342a31b62..0dd6bb400 100644--- a/crates/horizon-client/src/game/boats.rs+++ b/crates/horizon-client/src/game/boats.rs@@ -577,6 +577,16 @@ impl Game<'_> {b.paddling = [false; 2];b.input = [false; 4];}+ // `Entity.baseTick`: the boat is immersed and pushed by the current it+ // sits in (`isPushedByFluid`), before `floatBoat` scales the velocity.+ let _ = horizon_client::entities::update_entity_fluids(+ b.bounds(),+ b.position,+ b.position.y + f64::from(HEIGHT),+ &mut b.velocity,+ &self.world,+ &self.res.motion().fluids,+ );// floatBoatlet mut vspeed = -0.04;let mut buoyancy = 0.0;