From b73ab976a1115044bc336f9e3f181ecf6e75cc06 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Thu, 22 Apr 2021 20:25:58 -0400 Subject: [PATCH] Implement framework for mob death --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 5 +++++ .../mcl_mobs/api/mob_functions/interaction.lua | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index ad8e26a584..cf19f3ab30 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -610,6 +610,11 @@ mobs.mob_step = function(self, dtime) return false end + if self.health <= 0 then + print("I'm DEAD :(") + return + end + local attacking = nil --scan for players within eyesight diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua index 0d24d569ed..32011aafe8 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -43,6 +43,10 @@ end -- I have no idea what this does mobs.create_mob_on_rightclick = function(on_rightclick) return function(self, clicker) + --don't allow rightclicking dead mobs + if self.health <= 0 then + return + end local stop = on_rightclick_prefix(self, clicker) if (not stop) and (on_rightclick) then on_rightclick(self, clicker) @@ -54,6 +58,11 @@ end -- deal damage and effects when mob punched mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) + --don't do anything if the mob is already dead + if self.health <= 0 then + return + end + --neutral passive mobs switch to neutral hostile if self.neutral then @@ -82,7 +91,6 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) --don't do damage until pause timer resets if self.pause_timer > 0 then - print(self.pause_timer) return end