From 2c894783aa34187aa421280d092827e9f3485373 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 23:37:14 +0100 Subject: [PATCH] Bubble columns lift and drag mobs, items and ender pearls --- crates/horizon-client/src/game.rs | 9 +++ crates/horizon-client/src/game/creatures.rs | 15 +++++ crates/horizon-client/src/mobs/living.rs | 11 ++++ crates/horizon-client/src/motion.rs | 2 +- crates/horizon-client/src/motion/fluids.rs | 61 +++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index db49087b2..387ec592f 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -2366,6 +2366,15 @@ impl Game<'_> { no_physics, &self.res.motion().fluids, ); + // Entity.applyEffectsFromBlocks: bubble columns lift or drag the item. + horizon_client::motion::bubble_column_push( + &self.world, + self.pack.assets.registry, + self.res.facts(), + self.collision, + item.bounds(), + &mut item.velocity, + ); cells.moved(i, item.previous, item.position); // ItemEntity.tick: merge every 2 ticks while moving between // blocks, every 40 otherwise, before the lifetime check. diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index f6961ab13..cfac5f8e4 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -1941,6 +1941,21 @@ impl Game<'_> { if shooter.is_some() { p.owner = Some(Who::Player); } + // ThrownEnderpearl.onAboveBubbleColumn / onInsideBubbleColumn. + if keep && hit == Hit::None && matches!(p.kind, ProjectileKind::EnderPearl) { + let (at, h) = (p.position, 0.125); + horizon_client::motion::bubble_column_push( + w.world, + w.registry, + w.facts, + w.collision, + Aabb::new( + Vec3::new(at.x - h, at.y, at.z - h), + Vec3::new(at.x + h, at.y + 2.0 * h, at.z + h), + ), + &mut p.velocity, + ); + } if let Some(a) = p.arrow.as_mut() { arrow_events.extend(a.events.drain(..).map(|e| (p.position, e))); } diff --git a/crates/horizon-client/src/mobs/living.rs b/crates/horizon-client/src/mobs/living.rs index 394821ace..6d30cf231 100644 --- a/crates/horizon-client/src/mobs/living.rs +++ b/crates/horizon-client/src/mobs/living.rs @@ -428,6 +428,17 @@ impl Mob { // Entity.checkSupportingBlock self.supporting = self.supporting_block(w, moved); self.movement_emission(w, moved, events); + // Entity.applyEffectsFromBlocks: bubble columns push the mob. + if crate::motion::bubble_column_push( + w.world, + w.registry, + w.facts, + w.collision, + self.bounds(), + &mut self.velocity, + ) { + self.fall_distance = 0.0; + } } /// LivingEntity.checkFallDamage: the fluid state refreshed out of water /// (touching water resets the fall), then Entity.checkFallDamage. diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index dfdc3f168..7b88d9af8 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -44,7 +44,7 @@ use std::{ pub(crate) mod environment; mod fluids; -pub use fluids::{FluidResources, FluidTags, LAVA, PlayerFluids, WATER}; +pub use fluids::{FluidResources, FluidTags, LAVA, PlayerFluids, WATER, bubble_column_push}; pub struct MotionResources { pub attributes: Arc, diff --git a/crates/horizon-client/src/motion/fluids.rs b/crates/horizon-client/src/motion/fluids.rs index 894e6d907..e3751f0c6 100644 --- a/crates/horizon-client/src/motion/fluids.rs +++ b/crates/horizon-client/src/motion/fluids.rs @@ -119,6 +119,67 @@ impl PlayerMotion { !self.fluids.first_tick && self.fluids.interaction.is_in_fluid(&FluidTags, LAVA) } } +/// `BubbleColumnBlock.entityInside` for an entity that is not the player (a mob, +/// a dropped item, an ender pearl): the bubble columns its box touches push it +/// up or drag it down, harder at the surface (`Entity.handleOnAboveBubbleColumn` +/// and `handleOnInsideBubbleColumn`). Returns whether it was inside a column +/// below the surface, which resets its fall distance. +pub fn bubble_column_push( + world: &World, + registry: &horizon_world::registry::BlockRegistry, + facts: &crate::blocks::BlockFacts, + collision: &horizon_world::block_collision::BlockCollisionRegistry<'_>, + bounds: Aabb, + velocity: &mut Vec3, +) -> bool { + let b = bounds.deflate(Vec3::new( + f64::from(1.0e-5f32), + f64::from(1.0e-5f32), + f64::from(1.0e-5f32), + )); + let (lo, hi) = (b.min_position(), b.max_position()); + let mut reset_fall = false; + for x in lo.x.floor() as i32..=(hi.x.ceil() as i32 - 1) { + for y in lo.y.floor() as i32..=(hi.y.ceil() as i32 - 1) { + for z in lo.z.floor() as i32..=(hi.z.ceil() as i32 - 1) { + let state = world.block(x, y, z); + if &*facts.get(state).name != "minecraft:bubble_column" { + continue; + } + let drag = registry + .state(state) + .and_then(|s| s.properties.get("drag")) + .is_some_and(|d| d == "true"); + let above = world.block(x, y + 1, z); + // stateAbove.getCollisionShape(level, pos): the shape is asked + // at the column's own position. + let mut scene = SceneCollisions { + world, + binding: collision, + subject: None, + }; + let context = horizon_world::collision_context::CollisionContext::empty(false); + let nothing_above = collision + .collision_shape_with_context( + &mut scene, + above, + BlockPos::new(x, y, z), + &context, + ) + .is_ok_and(|shape| shape.is_empty()) + && facts.get(above).fluid == crate::blocks::Fluid::None; + velocity.y = match (nothing_above, drag) { + (true, true) => (-0.9_f64).max(velocity.y - 0.03), + (true, false) => 1.8_f64.min(velocity.y + 0.1), + (false, true) => (-0.3_f64).max(velocity.y - 0.03), + (false, false) => 0.7_f64.min(velocity.y + 0.06), + }; + reset_fall |= !nothing_above; + } + } + } + reset_fall +} /// Which fluids `FluidTags.WATER` and `FluidTags.LAVA` hold. pub struct FluidTags; impl FluidMembership for FluidTags {