From a8152760b96ca3a9f142b006d2d888da0ebeff6a Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 19:44:15 -0400 Subject: [PATCH] Integrate more switches into internal api elements of head code --- mods/ENTITIES/mcl_mobs/api/api.lua | 24 +++++++++++++++++++ .../mcl_mobs/api/mob_functions/ai.lua | 14 +++++------ .../mcl_mobs/api/mob_functions/head_logic.lua | 9 ------- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 10 ++++++++ mods/ENTITIES/mobs_mc/creeper.lua | 6 +++++ 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 8de361c3e..219fbed3f 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -368,15 +368,39 @@ function mobs:register_mob(name, def) --head code variables + --defaults are for the cow's default + --because I don't know what else to set them + --to :P + has_head = def.has_head or false, head_bone = def.head_bone, --you must use these to adjust the mob's head positions + + --has_head is used as a logic gate (quick easy check) + has_head = def.has_head or false, + --head_bone is the actual bone in the model which the head + --is attached to for animation + head_bone = def.head_bone or "head", + + --this part controls the base position of the head calculations + --localized to the mob's visual yaw when gotten (self.object:get_yaw()) + --you can enable the debug in /mob_functions/head_logic.lua by uncommenting the + --particle spawner code + head_height_offset = def.head_height_offset or 1.0525, + head_direction_offset = def.head_direction_offset or 0.5, + + --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, + + --these variables are switches in case the model + --moves the wrong way swap_y_with_x = def.swap_y_with_x or false, reverse_head_yaw = def.reverse_head_yaw or false, + --END HEAD CODE VARIABLES + --end j4i stuff -- MCL2 extensions diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 5ecb7c4fb..10f4c261d 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -832,8 +832,11 @@ mobs.mob_step = function(self, dtime) --DEBUG TIME! + --REMEMBER TO MOVE THIS AFTER DEATH CHECK - mobs.do_head_logic(self,dtime) + if self.has_head then + mobs.do_head_logic(self,dtime) + end @@ -855,9 +858,6 @@ mobs.mob_step = function(self, dtime) end end - --make it so mobs do not glitch out when walking around/jumping - mobs.swap_auto_step_height_adjust(self) - --color modifier which coincides with the pause_timer if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") @@ -895,9 +895,6 @@ mobs.mob_step = function(self, dtime) mobs.random_sound_handling(self,dtime) - - - --mobs drowning mechanic if not self.breathes_in_water then @@ -1112,6 +1109,9 @@ mobs.mob_step = function(self, dtime) return false end + --make it so mobs do not glitch out when walking around/jumping + mobs.swap_auto_step_height_adjust(self) + -- can mob be pushed, if so calculate direction -- do this last (overrides everything) if self.pushable then 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 40d1f22c8..88d3c19ba 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -24,14 +24,8 @@ mobs.do_head_logic = function(self,dtime) local body_dir = minetest.yaw_to_dir(body_yaw) - --needs to be INTERNAL(API) - self.head_height_offset = 1.0525 - pos.y = pos.y + self.head_height_offset - --needs to be INTERNAL (API) - self.head_direction_offset = 0.5 - local head_offset = vector.multiply(body_dir, self.head_direction_offset) pos = vector.add(pos, head_offset) @@ -52,12 +46,9 @@ mobs.do_head_logic = function(self,dtime) local bone_pos = vector_new(0,0,0) - --needs to be INTERNAL (API) --(horizontal) bone_pos.y = self.head_bone_pos_y - - --needs to be INTERNAL (API) --(vertical) bone_pos.z = self.head_bone_pos_z diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index e71270668..c346b1037 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -84,6 +84,16 @@ local cow_def = { follow = mobs_mc.items.wheat, view_range = 10, fear_height = 4, + + --head code + has_head = true, + head_bone = "head", + swap_y_with_x = false, + reverse_head_yaw = false, + head_bone_pos_y = 3.6, + head_bone_pos_z = -0.6, + head_height_offset = 1.0525, + head_direction_offset = 0.5, } mobs:register_mob("mobs_mc:cow", cow_def) diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 19c079d98..9f083620d 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -54,8 +54,14 @@ mobs:register_mob("mobs_mc:creeper", { stop_to_explode = true, --head code + has_head = true, + head_bone = "head", swap_y_with_x = true, reverse_head_yaw = true, + head_bone_pos_y = 3.6, + head_bone_pos_z = -0.6, + head_height_offset = 1.0525, + head_direction_offset = 0.5, -- Force-ignite creeper with flint and steel and explode after 1.5 seconds. -- TODO: Make creeper flash after doing this as well.