From ac852309388e1f9a7dec294440975c7dc89e498c Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 20:08:45 -0400 Subject: [PATCH] Add in chicken head code with additional pitch modifier --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + .../mcl_mobs/api/mob_functions/head_logic.lua | 4 ++++ mods/ENTITIES/mobs_mc/chicken.lua | 19 +++++++++++++++++-- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 1 + mods/ENTITIES/mobs_mc/creeper.lua | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 219fbed3f..251c6328a 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -393,6 +393,7 @@ function mobs:register_mob(name, def) --this part controls the visual of the head head_bone_pos_y = def.head_bone_pos_y or 3.6, head_bone_pos_z = def.head_bone_pos_z or -0.6, + head_pitch_modifier = def.head_pitch_modifier or 0, --these variables are switches in case the model --moves the wrong way diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua index 88d3c19ba..dc0d8dc56 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -97,6 +97,10 @@ mobs.do_head_logic = function(self,dtime) head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2) end + if self.head_pitch_modifier then + head_pitch = head_pitch + self.head_pitch_modifier + end + if self.swap_y_with_x then self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),degrees(head_yaw),0)) else diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 094ebb0de..bf02f8767 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -108,8 +108,23 @@ mobs:register_mob("mobs_mc:chicken", { gain = 1.0, max_hear_distance = 16, }, true) - end, - + end, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 1.675, + head_bone_pos_z = 0, + + head_height_offset = 0.55, + head_direction_offset = 0.0925, + + head_pitch_modifier = -math.pi/2, + --end head code }) --spawn diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index f6abe6298..98aa8e3f3 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -97,6 +97,7 @@ local cow_def = { head_height_offset = 1.0525, head_direction_offset = 0.5, + head_pitch_modifier = 0, --end head code } diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index fa2337cf6..8ccb4689d 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -65,6 +65,7 @@ mobs:register_mob("mobs_mc:creeper", { head_height_offset = 1.1, head_direction_offset = 0, + head_pitch_modifier = 0, --end head code -- Force-ignite creeper with flint and steel and explode after 1.5 seconds.