Merge pull request #2197 from kacpherek/fix/chest-blocked-above

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `ChestBlock.isChestBlockedAt`: a block above that is a redstone conductor, or a sitting cat on top. Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-26 20:12:53 +01:00
committed by GitHub
2 changed files with 53 additions and 0 deletions
+4
View File
@@ -3140,6 +3140,10 @@ impl Game<'_> {
.name
.clone();
let key = (pos[0], pos[1], pos[2]);
if self.chest_menu_blocked(key, &name) {
// The use still succeeds, but no menu, stat or piglin anger.
return;
}
if &*name == "minecraft:lectern" {
self.open_lectern(pos);
return;
+49
View File
@@ -33,6 +33,55 @@ impl Game<'_> {
self.container = Some(key);
self.ender_open = Some(key);
}
/// The block above `key` is a redstone conductor.
fn conductor_above(&self, key: (i32, i32, i32)) -> bool {
let above = self.world.block(key.0, key.1 + 1, key.2);
self.res.behaviours().facts(above).flags
& horizon_world::level::data::state_flags::CONDUCTOR
!= 0
}
/// `ChestBlock.isChestBlockedAt`: a redstone conductor above the chest or
/// a cat sitting on it.
fn chest_blocked_at(&self, key: (i32, i32, i32)) -> bool {
if self.conductor_above(key) {
return true;
}
// isCatSittingOnChest: a cat whose box meets the block above.
let area = horizon_core::geometry::Aabb::new(
horizon_core::geometry::Vec3::new(
f64::from(key.0),
f64::from(key.1 + 1),
f64::from(key.2),
),
horizon_core::geometry::Vec3::new(
f64::from(key.0 + 1),
f64::from(key.1 + 2),
f64::from(key.2 + 1),
),
);
self.mobs.iter().any(|m| {
m.species() == horizon_client::mobs::Species::Cat
&& m.alive()
&& horizon_client::mobs::tame::cat_sitting(m)
&& m.bounds().intersects(area)
})
}
/// `ChestBlock.getMenuProvider` (`combine(.., false)`) and
/// `EnderChestBlock.useWithoutItem`: a blocked chest, or a double chest
/// with either half blocked, opens no menu.
pub(super) fn chest_menu_blocked(&self, key: (i32, i32, i32), name: &str) -> bool {
match name {
"minecraft:chest" | "minecraft:trapped_chest" => {
self.chest_blocked_at(key)
|| self
.chest_partner(key)
.is_some_and(|(other, _)| self.chest_blocked_at(other))
}
// The ender chest only looks at the block above (no cat check).
"minecraft:ender_chest" => self.conductor_above(key),
_ => false,
}
}
/// Closing it copies the items back and leaves no block-entity contents.
pub(super) fn close_ender_chest(&mut self) {
let Some(key) = self.ender_open.take() else {