From 5a2773ea1abb6c8706c477802aae2fa60704714c Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 17:48:41 -0400 Subject: [PATCH 1/9] Add in basics of head code yaw --- .../mcl_mobs/api/mob_functions/ai.lua | 8 +- .../mcl_mobs/api/mob_functions/head_logic.lua | 86 ++++++++++++++++++- 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index bb54f5b95..5ecb7c4fb 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -833,13 +833,13 @@ mobs.mob_step = function(self, dtime) --DEBUG TIME! - --mobs.do_head_logic(self,dtime) + mobs.do_head_logic(self,dtime) - --if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - -- return - --end + if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + return + end --despawn mechanism --don't despawned tamed or bred mobs 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 a294f5528..f4fc5e56d 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -1,12 +1,67 @@ local vector_new = vector.new + +--converts yaw to degrees +local degrees = function(yaw) + return(yaw*180.0/math.pi) +end + + mobs.do_head_logic = function(self,dtime) - --local yaw = self.object:get_yaw() + local player = minetest.get_player_by_name("singleplayer") + + local look_at = player:get_pos() + look_at.y = look_at.y + player:get_properties().eye_height - --local bone_pos = vector_new(0,5,0) + + local pos = self.object:get_pos() + + local body_yaw = self.object:get_yaw() + + 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) + + + + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.2, + size = 1, + texture = "default_dirt.png", + }) + + + local bone_pos = vector_new(0,0,0) + + + --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) @@ -15,7 +70,32 @@ mobs.do_head_logic = function(self,dtime) --bone_rot.x = bone_rot.x + (dtime * 10) --bone_rot.z = bone_rot.z + (dtime * 10) - --self.object:set_bone_position("head", bone_pos, bone_rot) + local head_yaw + + head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw + + + --over rotation protection + --stops radians from going out of spec + if head_yaw > math.pi then + head_yaw = head_yaw - (math.pi * 2) + elseif head_yaw < -math.pi then + head_yaw = head_yaw + (math.pi * 2) + end + + + --upper check + if head_yaw > math.pi - (math.pi/2) then + head_yaw = 0 + --lower check + elseif head_yaw < -math.pi + (math.pi/2) then + head_yaw = 0 + end + + + + + self.object:set_bone_position("head", bone_pos, vector_new(0,0,degrees(head_yaw))) From d28e81bc9fc1f11b10da524d6874e8e1ee4a956d Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 17:54:14 -0400 Subject: [PATCH 2/9] Add in mobs look pitch --- .../mcl_mobs/api/mob_functions/head_logic.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 f4fc5e56d..612ef1d98 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -84,18 +84,28 @@ mobs.do_head_logic = function(self,dtime) end - --upper check + local check_failed = false + --upper check + 90 degrees or upper math.radians (3.14/2) if head_yaw > math.pi - (math.pi/2) then head_yaw = 0 - --lower check + check_failed = true + --lower check - 90 degrees or lower negative math.radians (-3.14/2) elseif head_yaw < -math.pi + (math.pi/2) then head_yaw = 0 + check_failed = true end - + local head_pitch = 0 + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + --head_yaw = 0 + --DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - self.object:set_bone_position("head", bone_pos, vector_new(0,0,degrees(head_yaw))) + if not check_failed then + 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))) From 6a38198e97fd0b573b3b9e590177977d900d5b14 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 18:24:10 -0400 Subject: [PATCH 3/9] 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. From a8152760b96ca3a9f142b006d2d888da0ebeff6a Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 19:44:15 -0400 Subject: [PATCH 4/9] 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. From b6c9a1c423a9831cb3684e6a7e1b57163d6d4ab4 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 19:51:11 -0400 Subject: [PATCH 5/9] Fix creeper head --- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 4 ++++ mods/ENTITIES/mobs_mc/creeper.lua | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index c346b1037..f6abe6298 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -88,12 +88,16 @@ local cow_def = { --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, + --end head code } 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 9f083620d..fa2337cf6 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -56,12 +56,16 @@ mobs:register_mob("mobs_mc:creeper", { --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, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + --end head code -- Force-ignite creeper with flint and steel and explode after 1.5 seconds. -- TODO: Make creeper flash after doing this as well. From f57c4709ac74d1e2b0b683bebc706a1a3e59db73 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 19:54:11 -0400 Subject: [PATCH 6/9] Comment out code that causes mobs to glitch push players in mcl_playerplus --- mods/PLAYER/mcl_playerplus/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 13d136ecf..c346dca3c 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -168,11 +168,13 @@ minetest.register_globalstep(function(dtime) local c_x, c_y = unpack(player_collision(player)) + --[[ if player_velocity.x + player_velocity.y < .5 and c_x + c_y > 0 then local add_velocity = player.add_player_velocity or player.add_velocity add_velocity(player, {x = c_x, y = 0, z = c_y}) player_velocity = player:get_velocity() or player:get_player_velocity() end + ]]-- -- control head bone local pitch = - degrees(player:get_look_vertical()) From ac852309388e1f9a7dec294440975c7dc89e498c Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 20:08:45 -0400 Subject: [PATCH 7/9] 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. From e52aab45c07c22605993126c4a8ba39c8318d904 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 20:23:46 -0400 Subject: [PATCH 8/9] Implement no-op head operations for enderman --- .../mcl_mobs/api/mob_functions/head_logic.lua | 4 ++-- mods/ENTITIES/mobs_mc/enderman.lua | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) 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 dc0d8dc56..0fc94ffe6 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/head_logic.lua @@ -102,9 +102,9 @@ mobs.do_head_logic = function(self,dtime) 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)) + self.object:set_bone_position(self.head_bone, 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))) + self.object:set_bone_position(self.head_bone, bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw))) end diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 506ae0474..c96faaa1e 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -224,6 +224,22 @@ mobs:register_mob("mobs_mc:enderman", { max = 1, looting = "common"}, }, + + --head code + has_head = false, + head_bone = "head.low", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + animation = select_enderman_animation("normal"), _taken_node = "", do_custom = function(self, dtime) From ddb33acf0d85f29dddb8bdab7a3a7030f9f595be Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 20:46:45 -0400 Subject: [PATCH 9/9] Add in unused head code elements --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 12 ++++++------ mods/ENTITIES/mobs_mc/pig.lua | 16 ++++++++++++++++ mods/ENTITIES/mobs_mc/sheep.lua | 16 ++++++++++++++++ mods/ENTITIES/mobs_mc/skeleton+stray.lua | 16 ++++++++++++++++ mods/ENTITIES/mobs_mc/wolf.lua | 16 ++++++++++++++++ mods/ENTITIES/mobs_mc/zombie.lua | 16 ++++++++++++++++ mods/ENTITIES/mobs_mc/zombiepig.lua | 16 ++++++++++++++++ 7 files changed, 102 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 10f4c261d..eda7e8871 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -834,15 +834,15 @@ mobs.mob_step = function(self, dtime) --DEBUG TIME! --REMEMBER TO MOVE THIS AFTER DEATH CHECK - if self.has_head then - mobs.do_head_logic(self,dtime) - end + --if self.has_head then + -- mobs.do_head_logic(self,dtime) + --end - if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - return - end + --if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + -- return + --end --despawn mechanism --don't despawned tamed or bred mobs diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index d88066798..21ab1a62b 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -19,6 +19,22 @@ mobs:register_mob("mobs_mc:pig", { "mobs_mc_pig.png", -- base "blank.png", -- saddle }}, + + --head code + has_head = true, + head_bone = "head", + + swap_y_with_x = false, + reverse_head_yaw = false, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + visual_size = {x=2.5, y=2.5}, makes_footstep_sound = true, walk_velocity = 1, diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 5be276d8f..a6273afac 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -78,6 +78,22 @@ mobs:register_mob("mobs_mc:sheep", { makes_footstep_sound = true, walk_velocity = 1, run_velocity = 3, + + --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, + head_pitch_modifier = 0, + --end head code + drops = { {name = mobs_mc.items.mutton_raw, chance = 1, diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 6f0d5c0b9..f43790272 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -34,6 +34,22 @@ local skeleton = { "mcl_bows_bow_0.png", -- bow "mobs_mc_skeleton.png", -- skeleton } }, + + --head code + has_head = false, + head_bone = "head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + visual_size = {x=1, y=1}, makes_footstep_sound = true, textures = { diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index 941cc42f1..ab36c9173 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -30,6 +30,22 @@ local wolf = { rotate = 270, passive = false, group_attack = true, + + --head code + has_head = false, + 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, + head_pitch_modifier = 0, + --end head code + collisionbox = {-0.3, -0.00, -0.3, 0.3, 0.85, 0.3}, visual = "mesh", mesh = "mobs_mc_wolf.b3d", diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index ecb79621d..dde5af89a 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -75,6 +75,22 @@ local zombie = { damage = "mobs_mc_zombie_hurt", distance = 16, }, + + --head code + has_head = false, + head_bone = "Head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + eye_height = 1.65, walk_velocity = 1, run_velocity = 3.5, diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index af1da2962..e56b60e89 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -43,6 +43,22 @@ local pigman = { damage = "mobs_mc_zombiepig_hurt", distance = 16, }, + + --head code + has_head = false, + head_bone = "head", + + swap_y_with_x = true, + reverse_head_yaw = true, + + head_bone_pos_y = 2.4, + head_bone_pos_z = 0, + + head_height_offset = 1.1, + head_direction_offset = 0, + head_pitch_modifier = 0, + --end head code + jump = true, makes_footstep_sound = true, walk_velocity = .8,