Merge pull request #1915 from vlesmentie/fix/big-dripleaf-tilt

🤖 Agent: Thanks vlesmentie! Matches BigDripleafBlock.entityInside and canEntityTilt (the 0.6875 height check): a big dripleaf tilts under a player standing on it. Tested with the wave 2 batch: fmt, clippy and the horizon-client and horizon-world tests pass, and all 127 affected harnesses pass. The chunk_generation and decorated_region reruns took 8 minutes with no chunk differing. lan_e2e contacts and the rest of wave 2's checks pass with the host in-frame and on its server thread.
This commit is contained in:
Ludovic Marie
2026-10-26 04:39:41 +01:00
committed by GitHub
5 changed files with 121 additions and 0 deletions
+31
View File
@@ -2600,10 +2600,41 @@ impl Game<'_> {
}
}
}
// BigDripleafBlock.entityInside also asks whether the player stands on
// the ground and how high its feet are: the leaves its box's feet
// layer is inside (the host and the LAN guests).
let mut standing = Vec::new();
let feet = self
.player
.iter()
.filter(|_| !self.spectator())
.map(|p| {
(
[p.position.x, p.position.y, p.position.z],
p.ground.on_ground,
f64::from(p.dimensions.width) / 2.0,
)
})
.chain(
self.lan_guest_feet()
.into_iter()
.map(|(at, on_ground)| (at, on_ground, 0.3)),
);
for (at, on_ground, w) in feet {
let y = (at[1] + 1e-7).floor() as i32;
for x in (at[0] - w + 1e-7).floor() as i32..=(at[0] + w - 1e-7).floor() as i32 {
for z in (at[2] - w + 1e-7).floor() as i32..=(at[2] + w - 1e-7).floor() as i32 {
standing.push((BlockPos::new(x, y, z), on_ground, at[1]));
}
}
}
self.with_level(|b, level, ticks| {
for pos in inside {
b.entity_inside(level, ticks, pos);
}
for (pos, on_ground, feet_y) in standing {
b.entity_on_big_dripleaf(level, ticks, pos, on_ground, feet_y);
}
});
self.process_level_events()?;
self.tick_scheduled()?;
@@ -171,6 +171,19 @@ impl Game<'_> {
})
.collect()
}
/// The same guests' feet and whether they stand on the ground, for the
/// blocks that also ask that (`BigDripleafBlock.canEntityTilt`).
pub(super) fn lan_guest_feet(&self) -> Vec<([f64; 3], bool)> {
let Some(host) = self.lan.as_ref() else {
return Vec::new();
};
host.hub
.guests
.iter()
.filter(|g| host.hub.here(g) && g.loaded && !g.dead && !g.spectator())
.map(|g| (g.position, g.on_ground))
.collect()
}
/// The guests a projectile can hit, under their entity ids.
pub(super) fn lan_projectile_targets(&self) -> Vec<(Who, Aabb)> {
+23
View File
@@ -573,6 +573,29 @@ impl<L: LevelAccess + ?Sized> Sim<'_, L> {
self.game_event_state(pos, "minecraft:block_destroy", state);
}
}
/// `BigDripleafBlock.entityInside` on a server level: an entity standing on
/// a flat leaf (`canEntityTilt`: on the ground, its feet above the leaf's
/// lowest top, 11/16, less 4/16: 0.6875) tilts it UNSTABLE unless the leaf
/// is powered; `setTiltAndScheduleTick` with no sound (UNSTABLE causes no
/// vibration) and the next state in 10 ticks.
pub(crate) fn big_dripleaf_entity_inside(
&mut self,
pos: BlockPos,
on_ground: bool,
feet_y: f64,
) {
let b = self.b;
let state = self.state(pos);
if !b.data(state).is(Class::BigDripleaf)
|| b.table.text(state, b.props.tilt) != "none"
|| !(on_ground && feet_y > f64::from(pos.y) + f64::from(0.6875_f32))
|| self.has_neighbor_signal(pos)
{
return;
}
self.set_block(pos, b.table.set_text(state, b.props.tilt, "unstable"), 2);
self.schedule_tick(pos, b.block(state), 10);
}
/// `BigDripleafBlock.resetTilt`.
pub(crate) fn big_dripleaf_reset_tilt(&mut self, pos: BlockPos, state: BlockStateId) {
let b = self.b;
+13
View File
@@ -749,6 +749,19 @@ impl Behaviours {
) {
self.sim(level, ticks).entity_inside(pos);
}
/// `BigDripleafBlock.entityInside` for an entity whose box is inside
/// `pos`: whether it is on the ground and its feet's y (`canEntityTilt`).
pub fn entity_on_big_dripleaf<L: LevelAccess + ?Sized>(
&self,
level: &mut L,
ticks: &mut Ticks,
pos: BlockPos,
on_ground: bool,
feet_y: f64,
) {
self.sim(level, ticks)
.big_dripleaf_entity_inside(pos, on_ground, feet_y);
}
/// Redstone signal queries (`SignalGetter`).
pub fn has_neighbor_signal<L: LevelAccess + ?Sized>(
&self,
+41
View File
@@ -1283,3 +1283,44 @@ fn player_breaks_fire_with_extinguish_not_generic_break_event() {
assert_eq!(w.get(pos), w.b().air());
}
}
#[test]
fn big_dripleaf_tilts_under_an_entity_standing_on_it() {
let mut w = world!();
w.floor(0, 2, "clay");
let pos = BlockPos::new(0, 1, 0);
let leaf = w.id("big_dripleaf", &[("facing", "north")]);
w.put(pos, leaf);
let stand = |w: &mut World, on_ground: bool, feet: f64| {
w.f.behaviours
.entity_on_big_dripleaf(&mut w.level, &mut w.ticks, pos, on_ground, feet);
};
// canEntityTilt: in the air, or with its feet at or under 0.6875, nothing.
stand(&mut w, false, 1.9375);
stand(&mut w, true, 1.6875);
assert_eq!(w.prop(pos, "tilt"), "none");
// Standing on the leaf's top (15/16): UNSTABLE, then PARTIAL and FULL
// 10 ticks apart, and back to NONE 100 ticks later.
stand(&mut w, true, 1.9375);
assert_eq!(w.prop(pos, "tilt"), "unstable");
for _ in 0..10 {
w.tick();
}
assert_eq!(w.prop(pos, "tilt"), "partial");
for _ in 0..10 {
w.tick();
}
assert_eq!(w.prop(pos, "tilt"), "full");
// A tilted leaf doesn't restart under the entity.
stand(&mut w, true, 1.9375);
assert_eq!(w.prop(pos, "tilt"), "full");
for _ in 0..100 {
w.tick();
}
assert_eq!(w.prop(pos, "tilt"), "none");
// A powered leaf doesn't tilt.
let power = w.id("redstone_block", &[]);
w.put(BlockPos::new(1, 1, 0), power);
stand(&mut w, true, 1.9375);
assert_eq!(w.prop(pos, "tilt"), "none");
}