2021-03-17 11:08:14 +01:00
|
|
|
MCLMob = class(MCLEntity)
|
|
|
|
|
|
|
|
function MCLMob:get_hp()
|
|
|
|
self:meta():get_float("hp")
|
|
|
|
end
|
|
|
|
|
|
|
|
function MCLMob:set_hp()
|
|
|
|
self:meta():set_float("hp", hp)
|
|
|
|
end
|
|
|
|
|
2021-03-17 15:21:27 +01:00
|
|
|
function MCLMob:on_damage(damage, source)
|
|
|
|
MCLEntity.on_damage(self, damage, source)
|
2021-03-17 11:08:14 +01:00
|
|
|
|
|
|
|
local new_hp = self:get_hp()
|
2021-03-17 15:21:27 +01:00
|
|
|
if new_hp <= 0 and new_hp + damage > 0 then
|
2021-03-17 11:08:14 +01:00
|
|
|
self:on_death(source)
|
|
|
|
end
|
|
|
|
end
|