From 6a38198e97fd0b573b3b9e590177977d900d5b14 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 18:24:10 -0400 Subject: [PATCH] Add in swap_y_with_x and reverse_head_yaw to flesh out head code api element --- mods/ENTITIES/mcl_mobs/api/api.lua | 6 ++++++ .../mcl_mobs/api/mob_functions/head_logic.lua | 14 +++++++++----- mods/ENTITIES/mobs_mc/creeper.lua | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 017756ee2..8de361c3e 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -371,6 +371,12 @@ function mobs:register_mob(name, def) has_head = def.has_head or false, head_bone = def.head_bone, + --you must use these to adjust the mob's head positions + head_bone_pos_y = def.head_bone_pos_y or 3.6, + head_bone_pos_z = def.head_bone_pos_z or -0.6, + swap_y_with_x = def.swap_y_with_x or false, + reverse_head_yaw = def.reverse_head_yaw or false, + --end j4i stuff -- MCL2 extensions 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 612ef1d98..40d1f22c8 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -54,13 +54,11 @@ mobs.do_head_logic = function(self,dtime) --needs to be INTERNAL (API) --(horizontal) - self.head_bone_pos_y = 3.6 bone_pos.y = self.head_bone_pos_y --needs to be INTERNAL (API) --(vertical) - self.head_bone_pos_z = -0.6 bone_pos.z = self.head_bone_pos_z --print(yaw) @@ -70,10 +68,13 @@ mobs.do_head_logic = function(self,dtime) --bone_rot.x = bone_rot.x + (dtime * 10) --bone_rot.z = bone_rot.z + (dtime * 10) - local head_yaw + local head_yaw head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw + if self.reverse_head_yaw then + head_yaw = head_yaw * -1 + end --over rotation protection --stops radians from going out of spec @@ -105,8 +106,11 @@ 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 - self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw))) - + 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 + self.object:set_bone_position("head", bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw))) + end --set_bone_position([bone, position, rotation]) diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index b94a61dea..19c079d98 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -53,6 +53,10 @@ mobs:register_mob("mobs_mc:creeper", { allow_fuse_reset = true, stop_to_explode = true, + --head code + swap_y_with_x = true, + reverse_head_yaw = true, + -- Force-ignite creeper with flint and steel and explode after 1.5 seconds. -- TODO: Make creeper flash after doing this as well. -- TODO: Test and debug this code.