From fae4d4a1324d8e0d9e9278a9b8065ebcf7762cb4 Mon Sep 17 00:00:00 2001 From: kno10 Date: Tue, 19 Nov 2024 21:48:21 +0100 Subject: [PATCH] Adjust bones, animations slightly from b3d data. Initialize bones on spawn. --- mods/ENTITIES/mcl_mobs/effects.lua | 2 +- mods/ENTITIES/mcl_mobs/spawning.lua | 14 +++++++++++++- mods/ENTITIES/mobs_mc/blaze.lua | 2 +- mods/ENTITIES/mobs_mc/chicken.lua | 2 +- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 2 +- mods/ENTITIES/mobs_mc/llama.lua | 2 +- mods/ENTITIES/mobs_mc/ocelot.lua | 2 +- mods/ENTITIES/mobs_mc/parrot.lua | 4 ++-- mods/ENTITIES/mobs_mc/pig.lua | 2 +- mods/ENTITIES/mobs_mc/piglin.lua | 2 +- mods/ENTITIES/mobs_mc/polar_bear.lua | 2 +- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- 12 files changed, 25 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/effects.lua b/mods/ENTITIES/mcl_mobs/effects.lua index 37d63e48c..cf48551f1 100644 --- a/mods/ENTITIES/mcl_mobs/effects.lua +++ b/mods/ENTITIES/mcl_mobs/effects.lua @@ -399,7 +399,7 @@ function mob_class:check_head_swivel(dtime) end -- 0.02 is about 1.14 degrees tolerance, to update less often - if math.abs(oldr.x-newr.x) + math.abs(oldr.y-newr.y) + math.abs(oldr.z-newr.z) < 0.02 and vector.equals(oldp, vector.zero()) then return end + if math.abs(oldr.x-newr.x) + math.abs(oldr.y-newr.y) + math.abs(oldr.z-newr.z) < 0.02 then return end if self.object.get_bone_override then -- minetest >= 5.9 self.object:set_bone_override(self.head_swivel, { diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 8436540bf..8ffac16c7 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -701,7 +701,19 @@ function mcl_mobs.spawn(pos,id) local def = minetest.registered_entities[id] or minetest.registered_entities["mobs_mc:"..id] or minetest.registered_entities["extra_mobs:"..id] if not def or not def.is_mob or (def.can_spawn and not def.can_spawn(pos)) then return false end if not has_room(def, pos) then return false end - return minetest.add_entity(pos, def.name) + local ent = minetest.add_entity(pos, def.name) + -- initialize head bone + if def.head_swivel and def.head_bone_position then + if ent and ent.get_bone_override then -- minetest >= 5.9 + ent:set_bone_override(def.head_swivel, { + position = { vec = def.head_bone_position, absolute = true }, + rotation = { vec = vector.zero(), absolute = true } + }) + else -- minetest < 5.9 + self.object:set_bone_position(def.head_swivel, def.head_bone_position, vector.zero) + end + end + return ent end local function spawn_group(p,mob,spawn_on,amount_to_spawn) diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 676a22a2f..a025479f8 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -32,7 +32,7 @@ mcl_mobs.register_mob("mobs_mc:blaze", { mesh = "mobs_mc_blaze.b3d", head_swivel = "head.control", head_eye_height = 1.4, - head_bone_position = vector.new( 0, 4, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 3.9, 0 ), -- for minetest <= 5.8 curiosity = 10, head_pitch_multiplier=-1, textures = { diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 32dfff789..d75d2f165 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -22,7 +22,7 @@ mcl_mobs.register_mob("mobs_mc:chicken", { floats = 1, head_swivel = "head.control", head_eye_height = 0.5, - head_bone_position = vector.new(0, 4, -.3), -- for minetest <= 5.8 + head_bone_position = vector.new(0, 3.7, -.48), -- for minetest <= 5.8 curiosity = 10, head_yaw="z", visual_size = {x=1,y=1}, diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 8d960d9cb..307bb4d92 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -23,7 +23,7 @@ local cow_def = { }, }, head_swivel = "head.control", head_eye_height = 1.1, - head_bone_position = vector.new( 0, 10, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 9.5, -3.76 ), -- for minetest <= 5.8 curiosity = 2, head_yaw="z", makes_footstep_sound = true, diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index d8bc74f02..cb070213f 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -62,7 +62,7 @@ mcl_mobs.register_mob("mobs_mc:llama", { head_swivel = "head.control", head_eye_height = 1.5, head_yaw = "z", - head_bone_position = vector.new( 0, 11, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 10.6, 0 ), -- for minetest <= 5.8 curiosity = 60, hp_min = 15, diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index a8d75ea0f..a09079b13 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -38,7 +38,7 @@ local ocelot = { xp_max = 3, head_swivel = "head.control", head_eye_height = 0.4, - head_bone_position = vector.new( 0, 6.2, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 6.44, -0.42 ), -- for minetest <= 5.8 head_yaw="z", curiosity = 4, collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.69, 0.3}, diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index 185fcdd41..ab19d2849 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -165,8 +165,8 @@ mcl_mobs.register_mob("mobs_mc:parrot", { fly_speed = 50, stand_start = 0, stand_end = 0, - fly_start = 30, - fly_end = 45, + fly_start = 60, + fly_end = 120, walk_start = 0, walk_end = 20, -- TODO: actual walk animation diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 02668ba8e..88b8f47e6 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -21,7 +21,7 @@ mcl_mobs.register_mob("mobs_mc:pig", { }}, head_swivel = "head.control", head_eye_height = 0.7, - head_bone_position = vector.new( 0, 7.5, -1 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 7.23, -1 ), -- for minetest <= 5.8 curiosity = 3, head_yaw="z", makes_footstep_sound = true, diff --git a/mods/ENTITIES/mobs_mc/piglin.lua b/mods/ENTITIES/mobs_mc/piglin.lua index c3831c7b0..0c56a737c 100644 --- a/mods/ENTITIES/mobs_mc/piglin.lua +++ b/mods/ENTITIES/mobs_mc/piglin.lua @@ -252,7 +252,7 @@ local zombified_piglin = { damage = 9, reach = 2, head_swivel = "head.control", - head_bone_position = vector.new( 0, 2.4, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 2.417, 0 ), -- for minetest <= 5.8 head_eye_height = 1.4, curiosity = 15, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3}, -- same diff --git a/mods/ENTITIES/mobs_mc/polar_bear.lua b/mods/ENTITIES/mobs_mc/polar_bear.lua index 82f54a868..c132b1e35 100644 --- a/mods/ENTITIES/mobs_mc/polar_bear.lua +++ b/mods/ENTITIES/mobs_mc/polar_bear.lua @@ -26,7 +26,7 @@ mcl_mobs.register_mob("mobs_mc:polar_bear", { }, head_swivel = "head.control", head_eye_height = 1, - head_bone_position = vector.new( 0, 2.6, 0 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 2.396, 0 ), -- for minetest <= 5.8 curiosity = 20, head_yaw="z", visual_size = {x=3.0, y=3.0}, diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 67da51691..eb817ab8a 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -66,7 +66,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", { collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45}, head_swivel = "head.control", head_eye_height = 1.0, - head_bone_position = vector.new( 0, 3.3, -.7 ), -- for minetest <= 5.8 + head_bone_position = vector.new( 0, 3.7, -.9 ), -- for minetest <= 5.8 curiosity = 6, head_yaw="z", visual = "mesh",