Merge main into feat/energy-swirl
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -177,8 +177,71 @@ pub fn body(m: &Mob) -> (String, String) {
|
||||
"frog#main".into(),
|
||||
format!("entity/frog/frog_{}", climate(m)),
|
||||
),
|
||||
S::Rabbit => (
|
||||
baby_or(m, "rabbit#main", "rabbit_baby#main"),
|
||||
// RabbitRenderer.getTextureLocation: the Toast name tag, else the
|
||||
// variant (the killer bunny's id is 99).
|
||||
S::Rabbit => {
|
||||
let name = if m.custom_name.as_deref() == Some("Toast") {
|
||||
"toast"
|
||||
} else {
|
||||
match m.extra.variant {
|
||||
1 => "white",
|
||||
2 => "black",
|
||||
3 => "white_splotched",
|
||||
4 => "gold",
|
||||
5 => "salt",
|
||||
99 => "caerbannog",
|
||||
_ => "brown",
|
||||
}
|
||||
};
|
||||
(
|
||||
baby_or(m, "rabbit#main", "rabbit_baby#main"),
|
||||
b(&format!("entity/rabbit/rabbit_{name}")),
|
||||
)
|
||||
}
|
||||
// ParrotRenderer.getVariantTexture.
|
||||
S::Parrot => {
|
||||
let name = ["red_blue", "blue", "green", "yellow_blue", "grey"]
|
||||
[usize::from(m.extra.variant).min(4)];
|
||||
(m.kind.model_key(), format!("entity/parrot/parrot_{name}"))
|
||||
}
|
||||
// AxolotlRenderer.getTextureLocation.
|
||||
S::Axolotl => {
|
||||
let name =
|
||||
["lucy", "wild", "gold", "cyan", "blue"][usize::from(m.extra.variant).min(4)];
|
||||
(
|
||||
baby_or(m, "axolotl#main", "axolotl_baby#main"),
|
||||
b(&format!("entity/axolotl/axolotl_{name}")),
|
||||
)
|
||||
}
|
||||
// SalmonRenderer.submit: the model of the salmon's size.
|
||||
S::Salmon => {
|
||||
let model = match m.extra.variant {
|
||||
0 => "salmon_small#main",
|
||||
2 => "salmon_large#main",
|
||||
_ => "salmon#main",
|
||||
};
|
||||
(model.into(), "entity/fish/salmon".into())
|
||||
}
|
||||
// The baby models and textures of AgeableMobRenderer's other
|
||||
// subclasses.
|
||||
S::Goat => (
|
||||
baby_or(m, "goat#main", "goat_baby#main"),
|
||||
b(&m.kind.texture),
|
||||
),
|
||||
S::PolarBear => (
|
||||
baby_or(m, "polar_bear#main", "polar_bear_baby#main"),
|
||||
b(&m.kind.texture),
|
||||
),
|
||||
S::Ocelot => (
|
||||
baby_or(m, "ocelot#main", "ocelot_baby#main"),
|
||||
b(&m.kind.texture),
|
||||
),
|
||||
S::Turtle => (
|
||||
baby_or(m, "turtle#main", "turtle_baby#main"),
|
||||
b(&m.kind.texture),
|
||||
),
|
||||
S::Armadillo => (
|
||||
baby_or(m, "armadillo#main", "armadillo_baby#main"),
|
||||
b(&m.kind.texture),
|
||||
),
|
||||
S::Pig => {
|
||||
@@ -241,7 +304,7 @@ pub fn body(m: &Mob) -> (String, String) {
|
||||
),
|
||||
S::ZombieVillager => (
|
||||
baby_or(m, "zombie_villager#main", "zombie_villager_baby#main"),
|
||||
"entity/zombie_villager/zombie_villager".into(),
|
||||
b("entity/zombie_villager/zombie_villager"),
|
||||
),
|
||||
S::Villager => (
|
||||
baby_or(m, "villager#main", "villager_baby#main"),
|
||||
@@ -757,7 +820,14 @@ pub fn base_transform_at(m: &Mob, alpha: f32, origin: glam::Mat4) -> glam::Mat4
|
||||
let rotation = match sleep {
|
||||
// setupRotations for Pose.SLEEPING, with the head moved toward the pillow.
|
||||
Some((angle, step)) => {
|
||||
let head = (m.eye_y() - m.position.y) as f32 - 0.1;
|
||||
// The eye height of the standing pose (LivingEntityRenderer
|
||||
// extracts `getEyeHeight(Pose.STANDING)` for a bed).
|
||||
let eye = if avatar(m) {
|
||||
m.kind.eye_height as f32
|
||||
} else {
|
||||
(m.eye_y() - m.position.y) as f32
|
||||
};
|
||||
let head = eye - 0.1;
|
||||
glam::Mat4::from_translation(glam::Vec3::new(-step[0] * head, 0.0, -step[1] * head))
|
||||
* glam::Mat4::from_rotation_y(angle.to_radians())
|
||||
* glam::Mat4::from_rotation_z(90.0_f32.to_radians())
|
||||
@@ -825,10 +895,15 @@ pub fn base_transform_at(m: &Mob, alpha: f32, origin: glam::Mat4) -> glam::Mat4
|
||||
base *= species_scale(m, alpha);
|
||||
base * glam::Mat4::from_translation(glam::Vec3::new(0.0, -1.501, 0.0))
|
||||
}
|
||||
/// `LivingEntityRenderer.isShaking`: converting zombies, piglins and
|
||||
/// hoglins, and a zombie villager being cured.
|
||||
/// `LivingEntityRenderer.isShaking`: a fully frozen mob (the skeleton's own
|
||||
/// `isShaking` is its stray conversion only), converting zombies, piglins
|
||||
/// and hoglins, a zombie villager being cured and a cold strider.
|
||||
fn shaking(m: &Mob) -> bool {
|
||||
if m.is_fully_frozen() && m.species() != Species::Skeleton {
|
||||
return true;
|
||||
}
|
||||
match m.species() {
|
||||
Species::Strider => super::strider::suffocating(m),
|
||||
Species::ZombieVillager => super::zombie_villager::is_converting(m),
|
||||
Species::Zombie | Species::Husk => m.extra.counter2 > 0,
|
||||
Species::Piglin | Species::PiglinBrute | Species::Hoglin => {
|
||||
@@ -1267,6 +1342,15 @@ fn hand_base(
|
||||
0.0
|
||||
};
|
||||
let mut t = part_matrix(model, base, poses, arm, offset)?;
|
||||
if m.species() == Species::Vex {
|
||||
// `VexModel.translateToHand`: the held item is drawn at 0.55 scale.
|
||||
t *= glam::Mat4::from_scale(glam::Vec3::splat(0.55));
|
||||
t *= glam::Mat4::from_translation(glam::Vec3::new(
|
||||
if left { -0.046_875 } else { 0.046_875 },
|
||||
-0.156_25,
|
||||
0.078_125,
|
||||
));
|
||||
}
|
||||
let (ox, oy, oz) = if m.is_baby() {
|
||||
(0.0, 1.0, -4.5)
|
||||
} else {
|
||||
@@ -1453,4 +1537,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}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user