From 9d554fc31fb4edebb05b64ab4396aeac738d349c Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sun, 30 Oct 2016 21:06:33 +0000 Subject: [PATCH] only play damage sound and show blood if mob damage is >=1 --- api.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/api.lua b/api.lua index db95700..d6fa261 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ --- Mobs Api (26th October 2016) +-- Mobs Api (30th October 2016) mobs = {} mobs.mod = "redo" @@ -1900,6 +1900,9 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) hitter:set_wielded_item(weapon) end +-- only play hit sound and show blood effects if damage is 1 or over +if damage >= 1 then + -- weapon sounds if weapon:get_definition().sounds ~= nil then @@ -1916,6 +1919,19 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) }) end + -- blood_particles + if self.blood_amount > 0 + and not disable_blood then + + local pos = self.object:getpos() + + pos.y = pos.y + (-self.collisionbox[2] + self.collisionbox[5]) * .5 + + effect(pos, self.blood_amount, self.blood_texture) + end + +end + -- do damage self.health = self.health - floor(damage) @@ -1933,17 +1949,6 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) end) end) ]] - -- blood_particles - if self.blood_amount > 0 - and not disable_blood then - - local pos = self.object:getpos() - - pos.y = pos.y + (-self.collisionbox[2] + self.collisionbox[5]) * .5 - - effect(pos, self.blood_amount, self.blood_texture) - end - -- knock back effect (only on full punch) if self.knock_back > 0 and tflp > punch_interval then