Lava cauldrons burn the player inside them

The player's inside-block sweep skipped lava cauldrons, so standing in
one did nothing. It now tests the player against LavaCauldronBlock's
entity-inside shape (the cauldron's shape or its lava, Block.column(12,
4, 15)) the way Entity.checkInsideBlocks does, and applies
LavaCauldronBlock.entityInside: CLEAR_FREEZE, LAVA_IGNITE (15 seconds)
and Entity.lavaHurt (lava, 4), for the game's own player and a server's.

Fixes #1320.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vlesmentie
2026-10-25 11:47:21 -03:00
parent 6c4d1d6cbb
commit 4bfa496173
+80 -14
View File
@@ -1259,21 +1259,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(
@@ -1282,21 +1283,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`).
// CactusBlock, CampfireBlock and LavaCauldronBlock.entityInside
// (`entity.hurt`).
match name {
"minecraft:cactus" => self.environment_hurt("minecraft:cactus", 1.0)?,
"minecraft:lava_cauldron" => self.lava_cauldron_inside()?,
"minecraft:campfire" | "minecraft:soul_campfire" => {
let lit = self
.assets
@@ -1354,6 +1364,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) {
@@ -2368,6 +2386,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 server_travel_moves_only_the_velocity() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"))