From b0b1ec9436776fdc89edaf3046499a9e2cfaed0f Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Wed, 21 Apr 2021 10:53:20 -0400 Subject: [PATCH] Implement zombie pigmen and make them turn hostile when punched --- mods/ENTITIES/mcl_mobs/api/api.lua | 2 +- .../mcl_mobs/api/mob_functions/interaction.lua | 13 ++++++++++++- mods/ENTITIES/mobs_mc/zombiepig.lua | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 756366bbe..bafad3651 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -357,7 +357,7 @@ function mobs:register_mob(name, def) --do_punch = def.do_punch, - --on_punch = mob_punch, + on_punch = mobs.mob_punch, --on_breed = def.on_breed, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua index b36051a38..17a48e931 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -1,3 +1,5 @@ +local math_floor = math.floor + mobs.feed_tame = function(self) return nil end @@ -40,8 +42,16 @@ mobs.create_mob_on_rightclick = function(on_rightclick) end -- deal damage and effects when mob punched -local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) +mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) + if self.neutral then + self.hostile = true + --hostile_cooldown timer is initialized here + self.hostile_cooldown_timer + end + + + --[[ -- custom punch function if self.do_punch then @@ -312,4 +322,5 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) end end end + ]]-- end diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index efaf1b396..4777cd7cb 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -14,6 +14,8 @@ local pigman = { -- type="animal", passive=false: This combination is needed for a neutral mob which becomes hostile, if attacked type = "animal", passive = false, + neutral = true, + rotate = 270, spawn_class = "passive", hp_min = 20, hp_max = 20,