Merge pull request #2483 from kacpherek/fix/held-item-outline
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: the block outline uses the shape for the held item (light, scaffolding) and the shulker box's lid, as here. Gate: this wave's 50 PRs merged on main in one tree (union 9033a9c3b): fmt and clippy `-D warnings` clean, the horizon-client (1136 lib plus the integration tests), horizon-client-core (37), horizon-world (165) and horizon-protocol (100) tests pass, the fast build links, and the 140 harnesses `parity.py` picks for the tree's changed files pass on playhorizon (remote_fireworks, a known load flake there, passed on a rerun on a quiet Mac mini). `lan_e2e.py` passes 14 checks with the host on its server thread and in-frame (chest, xp, damage, kills, projectiles, mobs, drops, body, stopsound, digging, instant_digging, books, knockback, barter); `hurt` fails on main too when run after `damage` (check-order dependency, not this wave). Thanks @kacpherek!
This commit is contained in:
@@ -90,7 +90,7 @@ pub const MAP_COLORS: [u32; 62] = [
|
||||
14200723, 8365974,
|
||||
];
|
||||
/// The 12 edges of the unit cube (outline data predating the export).
|
||||
fn cube_edges() -> Vec<[f64; 6]> {
|
||||
pub fn cube_edges() -> Vec<[f64; 6]> {
|
||||
let mut edges = Vec::new();
|
||||
for a in 0..3 {
|
||||
for (u, v) in [(0., 0.), (1., 0.), (0., 1.), (1., 1.)] {
|
||||
|
||||
@@ -1828,9 +1828,46 @@ impl Game<'_> {
|
||||
fn reach(&self) -> f64 {
|
||||
if self.creative { 5.0 } else { 4.5 }
|
||||
}
|
||||
/// Outline shapes that depend on more than the block state, as one box
|
||||
/// in block space: `LightBlock` and `ScaffoldingBlock.getShape` are a full
|
||||
/// block while the main hand holds the block's own item
|
||||
/// (`CollisionContext.isHoldingItem`), and `ShulkerBoxBlock.getShape`
|
||||
/// grows with the lid (`ShulkerBoxBlockEntity.getBoundingBox`).
|
||||
fn context_outline(&self, pos: [i32; 3], state: BlockStateId) -> Option<[f64; 6]> {
|
||||
let name = &self.res.facts().get(state).name;
|
||||
if matches!(&**name, "minecraft:light" | "minecraft:scaffolding") {
|
||||
return self
|
||||
.held()
|
||||
.is_some_and(|s| *s.item == **name)
|
||||
.then_some([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]);
|
||||
}
|
||||
if !name.ends_with("shulker_box") {
|
||||
return None;
|
||||
}
|
||||
let progress = self.be_anims.shulkers.get(&pos).map_or(0.0, |s| s.progress);
|
||||
let facing = self
|
||||
.pack
|
||||
.assets
|
||||
.registry
|
||||
.state(state)
|
||||
.and_then(|s| s.properties.get("facing").cloned());
|
||||
let d = facing_offset(facing.as_deref().unwrap_or("up"));
|
||||
let mut b = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0];
|
||||
for a in 0..3 {
|
||||
match d[a] {
|
||||
1 => b[a + 3] += 0.5 * f64::from(progress),
|
||||
-1 => b[a] -= 0.5 * f64::from(progress),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Some(b)
|
||||
}
|
||||
/// A block's outline boxes in world space (`getShape` plus the random offset).
|
||||
fn outline_boxes(&self, pos: [i32; 3]) -> Vec<[f64; 6]> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if let Some(b) = self.context_outline(pos, state) {
|
||||
return vec![std::array::from_fn(|i| f64::from(pos[i % 3]) + b[i])];
|
||||
}
|
||||
let f = self.res.facts().get(state);
|
||||
let o = if f.outline_offset {
|
||||
self.pack
|
||||
@@ -10936,6 +10973,17 @@ impl Game<'_> {
|
||||
[0.0; 3]
|
||||
};
|
||||
let p = h.pos.map(f64::from);
|
||||
if let Some(b) = self.context_outline(h.pos, state) {
|
||||
return horizon_client::blocks::cube_edges()
|
||||
.iter()
|
||||
.map(|e| {
|
||||
std::array::from_fn(|i| {
|
||||
let k = i % 3;
|
||||
p[k] + b[k] + e[i] * (b[k + 3] - b[k])
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
f.outline_edges
|
||||
.iter()
|
||||
.map(|e| std::array::from_fn(|i| p[i % 3] + o[i % 3] + e[i]))
|
||||
|
||||
Reference in New Issue
Block a user