Saved max_health bases stay attribute bases

/attribute ... max_health base get now reads finalize's base, which
loading recorded only for horses: a summoned cow with a saved base of
40 answered its type's 10 (command_exec's attr case).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Ludovic MarieandClaude Opus 5.5 committed 2026-11-02 19:27:08 +01:00
1 parent 69bee308c2
commit 27d3d3ffdb
1 file changed
+14
+14
View File
@@ -1418,6 +1418,20 @@ pub fn mob_from_nbt(
crate::mobs::finalize::Attr::MovementSpeed,
v,
),
// A saved base other than the type's default is the
// attribute's base, which `/attribute ... base get` reads.
"minecraft:max_health"
if crate::mobs::finalize::default_value(
&m,
crate::mobs::finalize::Attr::MaxHealth,
) != Some(v) =>
{
crate::mobs::finalize::set_base(
&mut m,
crate::mobs::finalize::Attr::MaxHealth,
v,
)
}
"minecraft:max_health" => m.attrs.max_health = v as f32,
"minecraft:movement_speed" => m.attrs.speed = v,
"minecraft:attack_damage" => m.attrs.attack_damage = v as f32,