Merge pull request #1834 from vlesmentie/fix/lava-cauldron-player

🤖 Agent: merged after contribution gate 14 (integration run of main + this PR, harnesses for the touched areas) and verify on the resolved head. Thank you!
This commit is contained in:
Ludovic Marie
2026-10-25 22:55:16 +01:00
committed by GitHub
+80 -15
View File
@@ -1277,21 +1277,22 @@ impl MotionWorld<'_, '_, '_> {
continue;
}
let powder_snow = name == "minecraft:powder_snow";
let lava_cauldron = name == "minecraft:lava_cauldron";
// getEntityInsideCollisionShape is the whole block but for powder
// snow (its collision shape, the whole block when it is empty),
// filled cauldrons, end portals and tripwires; Horizon doesn't
// follow the player into those last three.
// follow the player into the water and powder snow cauldrons, end
// portals or tripwires yet.
if matches!(
name,
"minecraft:water_cauldron"
| "minecraft:lava_cauldron"
| "minecraft:powder_snow_cauldron"
| "minecraft:end_portal"
| "minecraft:tripwire"
) {
continue;
}
let inside = !powder_snow || {
let inside = !(powder_snow || lava_cauldron) || {
let context = self.context();
let binding = self.collision_binding;
let shape = binding.collision_shape_with_context(
@@ -1300,22 +1301,30 @@ impl MotionWorld<'_, '_, '_> {
p,
&context,
)?;
shape.is_empty() || shape.boxes() == VoxelShape::block().boxes() || {
let boxes: Vec<_> = shape
.moved(Vec3::new(f64::from(p.x), f64::from(p.y), f64::from(p.z)))
.boxes()
.to_vec();
self.player
.dimensions
.bounds(from)
.collided_along_vector(to.subtract(from), &boxes)
}
powder_snow && (shape.is_empty() || shape.boxes() == VoxelShape::block().boxes())
|| {
let offset = Vec3::new(f64::from(p.x), f64::from(p.y), f64::from(p.z));
let mut boxes: Vec<_> = shape.moved(offset).boxes().to_vec();
if lava_cauldron {
// LavaCauldronBlock.FILLED_SHAPE: the cauldron's
// shape or its lava, Block.column(12, 4, 15).
boxes.push(Aabb::new(
Vec3::new(2.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0).add_vector(offset),
Vec3::new(14.0 / 16.0, 15.0 / 16.0, 14.0 / 16.0).add_vector(offset),
));
}
self.player
.dimensions
.bounds(from)
.collided_along_vector(to.subtract(from), &boxes)
}
};
if inside && visited.insert(p.pack()) {
// CactusBlock and CampfireBlock.entityInside (`entity.hurt`),
// and WitherRoseBlock's server-side effect.
// CactusBlock, CampfireBlock and LavaCauldronBlock.entityInside
// (`entity.hurt`), and WitherRoseBlock's server-side effect.
match name {
"minecraft:cactus" => self.environment_hurt("minecraft:cactus", 1.0)?,
"minecraft:lava_cauldron" => self.lava_cauldron_inside()?,
"minecraft:wither_rose" => {
self.player.events.push(MotionEvent::InsideWitherRose);
}
@@ -1378,6 +1387,14 @@ impl MotionWorld<'_, '_, '_> {
}
self.player.impulse.try_reset();
}
/// `LavaCauldronBlock.entityInside`: CLEAR_FREEZE, LAVA_IGNITE
/// (`Entity.lavaIgnite`, 15 seconds) and then `Entity.lavaHurt` (lava,
/// 4), as ordinary lava does to the player.
fn lava_cauldron_inside(&mut self) -> Result<()> {
self.player.ticks_frozen = 0;
self.player.ignite_for_ticks(300)?;
self.environment_hurt("minecraft:lava", 4.0)
}
/// `WebBlock.entityInside`: stuck at a quarter of the speed, half with
/// the Weaving effect.
fn web_inside(&mut self) {
@@ -2392,6 +2409,54 @@ mod tests {
assert_eq!(player.position.y, 4.0);
}
#[test]
fn a_lava_cauldron_burns_the_player_inside_it() {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
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();
let mut scene = World::test_scene(&assets, &render, 1).unwrap();
let cauldron = assets
.registry
.default_state("minecraft:lava_cauldron")
.unwrap();
scene.set(20, 4, 20, cauldron).unwrap();
let mut tick = |player: &mut PlayerMotion| {
MotionWorld {
entities: &[],
player,
scene: &mut scene,
assets: &assets,
collision_binding: &binding,
resources: &resources,
}
.controlled_simulation_tick(Default::default())
.unwrap();
};
// Standing on the cauldron's floor, in its lava.
let mut player = PlayerMotion::new(&resources, Vec3::new(20.5, 4.25, 20.5)).unwrap();
player.ticks_frozen = 40;
tick(&mut player);
assert!(player.health.health() < 20.0, "the lava must hurt");
assert!(player.fire_ticks > 0, "the lava must ignite");
assert_eq!(player.ticks_frozen, 0);
// Beside it, nothing.
let mut away = PlayerMotion::new(&resources, Vec3::new(22.5, 4.0, 20.5)).unwrap();
tick(&mut away);
assert_eq!(away.health.health(), 20.0);
assert!(away.fire_ticks <= 0);
}
#[test]
fn standing_in_a_wither_rose_asks_for_its_effect() {
let root = std::env::var_os("HORIZON_TEST_RESOURCES")