Compare sniffer animation states, happy ghast layers and the llama decor model

The entity model harness now drives the sniffer's five keyframe animation
states and its search walk, the happy ghast body item, riding and leash
holder on its body, harness and ropes layers, and LlamaDecorLayer's model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-12 15:51:58 +02:00
parent fd79addba4
commit 95015b7828
3 changed files with 48 additions and 2 deletions
@@ -8,7 +8,7 @@ use horizon_client::mobs::{
anim::{self, Poses, State},
aquatic, body_anim as b_anim, equine, guardian,
keyframes::AnimationState,
shulker, species, tame,
shulker, sniffer, species, tame,
};
use horizon_core::geometry::Vec3;
use serde_json::{Value, json};
@@ -173,6 +173,30 @@ fn entity_state(mob: &mut Mob, species: Species, case: &Value) {
mob.anim.states[i].started = case[k].as_f64().map(|v| v as f32);
}
}
Species::Sniffer => {
if flag("isSearching") {
mob.extra.variant = sniffer::SEARCHING;
}
// Sniffer's animation states, in `sniffer::anim`'s order.
for (i, k) in [
"feelingHappyAnimationState",
"scentingAnimationState",
"sniffingAnimationState",
"diggingAnimationState",
"risingAnimationState",
]
.into_iter()
.enumerate()
{
mob.anim.states[i].started = case[k].as_f64().map(|v| v as f32);
}
}
Species::HappyGhast => {
mob.extra.head = case["bodyItem"].as_str().map(Into::into);
if flag("isRidden") {
mob.rider = Some(Default::default());
}
}
Species::Witch if flag("isHoldingItem") => {
mob.extra.main_hand = Some("minecraft:potion".into());
}
@@ -214,7 +238,10 @@ fn main() -> horizon_client::Result<()> {
for cut in cuts {
base = base.replace(cut, "");
}
let base = base.replace("undead_horse#", "zombie_horse#");
// LlamaDecorLayer's model animates like the llama.
let base = base
.replace("undead_horse#", "zombie_horse#")
.replace("#decor", "#main");
let base = base.trim_start_matches("cold_").trim_start_matches("warm_");
let Some(def) = species::ALL.iter().find(|d| {
d.model == layer
@@ -115,6 +115,16 @@ public final class VanillaEntityAnimOracle {
else if (t == boolean.class) f.setBoolean(state, value.getAsBoolean());
else if (t.isEnum()) {
for (Object c : t.getEnumConstants()) if (((Enum<?>) c).name().equals(value.getAsString())) f.set(state, c);
} else if (t == net.minecraft.world.item.ItemStack.class) {
// value = an item id. The item components are not bound outside a level, so the stack
// carries none: models only test that it is not empty.
var item = net.minecraft.core.registries.BuiltInRegistries.ITEM.wrapAsHolder(net.minecraft.core.registries.BuiltInRegistries.ITEM.getValue(
net.minecraft.resources.Identifier.parse(value.getAsString())));
var ctor = net.minecraft.world.item.ItemStack.class.getDeclaredConstructor(net.minecraft.core.Holder.class, int.class,
net.minecraft.core.component.PatchedDataComponentMap.class);
ctor.setAccessible(true);
f.set(state, ctor.newInstance(item, 1, new net.minecraft.core.component.PatchedDataComponentMap(
net.minecraft.core.component.DataComponentMap.EMPTY)));
} else if (t.getSimpleName().equals("AnimationState")) {
// value = age in ticks since start (negative = stopped)
var a = (net.minecraft.world.entity.AnimationState) f.get(state);
+9
View File
@@ -48,6 +48,8 @@ EXTRAS = [
('minecraft:pillager#main', 'IllagerModel'), ('minecraft:vindicator#main', 'IllagerModel'),
('minecraft:llama#main', 'LlamaModel'), ('minecraft:trader_llama#main', 'LlamaModel'),
('minecraft:llama_baby#main', 'BabyLlamaModel'), ('minecraft:trader_llama_baby#main', 'BabyLlamaModel'),
# LlamaDecorLayer: the carpet and the trader's blanket.
('minecraft:llama#decor', 'LlamaModel'), ('minecraft:llama_baby#decor', 'BabyLlamaModel'),
('minecraft:donkey#main', 'DonkeyModel'), ('minecraft:mule#main', 'DonkeyModel'),
('minecraft:donkey_baby#main', 'BabyDonkeyModel'), ('minecraft:mule_baby#main', 'BabyDonkeyModel'),
('minecraft:skeleton_horse#main', 'HorseModel'), ('minecraft:zombie_horse#main', 'HorseModel'),
@@ -134,6 +136,8 @@ PIGLIN = [{'armPose': pose, 'maxCrossbowChageDuration': 25.0, 'ticksUsingItem':
EQUINE = [{'eatAnimation': 0.6}, {'standAnimation': 0.5}, {'eatAnimation': 0.3, 'standAnimation': 0.4, 'feedingAnimation': 0.7},
{'isInWater': T}, {'standAnimation': 1.0, 'eatAnimation': 1.0}]
WATER = [{'isInWater': T}, {'isInWater': F}]
GHAST_BODY = [{'bodyItem': 'minecraft:white_harness'}, {'isRidden': T}, {'bodyItem': 'minecraft:red_harness', 'isRidden': T},
{'isLeashHolder': T, 'bodyItem': 'minecraft:blue_harness'}]
SPECIES = {
'horse': EQUINE, 'donkey': EQUINE + [{'hasChest': T}], 'mule': EQUINE + [{'hasChest': T}], 'zombie_horse': EQUINE, 'skeleton_horse': EQUINE,
'iron_golem': [{'attackTicksRemaining': 7.0}, {'offerFlowerTick': 30}, {'attackTicksRemaining': 0.0, 'offerFlowerTick': 0}],
@@ -170,6 +174,11 @@ SPECIES = {
{'sitAmount': 0.6, 'isEating': T}, {'sitAmount': 1.0, 'isScared': T}, {'sitAmount': 0.3},
{'lieOnBackAmount': 0.5}, {'rollAmount': 0.7}],
'llama': [{'hasChest': T}, {'hasChest': F}],
'sniffer': [{'isSearching': T}, {'diggingAnimationState': 2}, {'sniffingAnimationState': 5}, {'risingAnimationState': 1},
{'feelingHappyAnimationState': 3}, {'scentingAnimationState': 0}, {'diggingAnimationState': 50, 'isSearching': T},
{'feelingHappyAnimationState': 30, 'scentingAnimationState': 20}],
'happy_ghast': GHAST_BODY, 'happy_ghast_ropes': GHAST_BODY, 'happy_ghast_baby_ropes': GHAST_BODY,
'happy_ghast_harness': GHAST_BODY, 'happy_ghast_baby_harness': GHAST_BODY,
'trader_llama': [{'hasChest': T}, {'hasChest': F}],
'turtle': [{'isOnLand': T}, {'isOnLand': T, 'isLayingEgg': T}, {'isOnLand': F, 'hasEgg': T}, {'isOnLand': T, 'hasEgg': T}],
'strider': [{'isRidden': T}, {'isRidden': F}],