Test the vex's small held item

`VexModel.translateToHand` draws the held item at 0.55 scale, so the
vex's sword is the tiny one vanilla shows. The test checks the scale of
the item's transform; it fails without the cull-scale (it was 1).

Co-Authored-By: minimax-m3.1-flash (Claude Code) <noreply@users.noreply.github.com>
This commit is contained in:
levzzz
2026-10-27 11:01:50 +05:00
parent d966b1e59b
commit e3f6f9d4dc
+36
View File
@@ -1430,4 +1430,40 @@ mod tests {
assert!(vertices.iter().all(|v| v.uv[0] >= 0.5));
}
}
/// `VexModel.translateToHand`: the held item is drawn at 0.55 scale and
/// moved by the vex's own offset, so the vex's sword is the tiny one
/// vanilla shows. It was drawn at the full size, like a zombie's.
#[test]
fn the_vex_holds_its_item_at_the_small_scale() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3");
if !root.join("entity-models.json").exists() {
return;
}
let types = super::super::MobTypes::load(&root).unwrap();
let kind = std::sync::Arc::new(types.types["minecraft:vex"].clone());
let mob = Mob::new(1, kind, horizon_core::geometry::Vec3::ZERO, 0.0);
let data = MobData {
states: Vec::new(),
placements: Default::default(),
heightmaps: Default::default(),
animations: Default::default(),
biome_tags: Default::default(),
entity_tags: Default::default(),
villager_hats: Default::default(),
pois: Default::default(),
};
for left in [false, true] {
let t = held_item_transform(&mob, 0.5, glam::DVec3::ZERO, &data, left).unwrap();
// The model's own part scale is 1, so the item's scale is the
// renderer's: `poseStack.scale(0.55F, 0.55F, 0.55F)`.
for axis in [t.x_axis, t.y_axis, t.z_axis] {
let scale = axis.truncate().length();
assert!(
(scale - 0.55).abs() < 1.0e-5,
"the vex's item is drawn at 0.55 scale, got {scale}"
);
}
}
}
}