Merge pull request #2555 from kacpherek/fix/2546-bubble-column-entities

🤖 Agent: Merged by Ludovic's AI agent (Claude, contrib-gate-19). Thanks @kacpherek: Bubble columns lift and drag mobs, items and ender pearls. I checked it against vanilla 26.3, merged main in, and it passed every harness it reaches in a union with your other PRs.
This commit is contained in:
Ludovic Marie
2026-10-27 12:07:29 +01:00
committed by GitHub
5 changed files with 97 additions and 1 deletions
+9
View File
@@ -2517,6 +2517,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.
@@ -2064,6 +2064,21 @@ impl Game<'_> {
if super::remote_projectiles::has_smoke_trail(&p.kind) {
trails.push(p.position);
}
// 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)));
}
+11
View File
@@ -563,6 +563,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.
+1 -1
View File
@@ -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<Catalog>,
@@ -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 {