Merge branch 'master' into sponge-API

This commit is contained in:
AFCMS 2021-05-08 10:04:01 +02:00
commit 4f0a3b625b
5 changed files with 27 additions and 7 deletions

View File

@ -149,13 +149,18 @@ minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
end, true)
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
if player:get_hp() > 0 then
mt_reason.approved = true
if hp_change < 0 then
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason))
end
end
end, false)
minetest.register_on_dieplayer(function(player, mt_reason)
if mt_reason.approved then
mcl_damage.run_death_callbacks(player, mcl_damage.from_mt(mt_reason))
end
end)
minetest.register_on_mods_loaded(function()

View File

@ -539,7 +539,7 @@ function mcl_util.get_object_name(object)
local luaentity = object:get_luaentity()
if not luaentity then
return ""
return tostring(object)
end
return luaentity.nametag and luaentity.nametag ~= "" and luaentity.nametag or luaentity.description or luaentity.name

View File

@ -87,6 +87,12 @@ end
mobs.death_logic = function(self, dtime)
--stop crashing game when object is nil
if not self or not self.object or not self.object:get_luaentity() then
return
end
self.death_animation_timer = self.death_animation_timer + dtime
--get all attached entities and sort through them

View File

@ -204,8 +204,9 @@ mcl_damage.register_on_death(function(obj, reason)
if obj:is_player() then
send_to = true
end -- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name")
end
-- ToDo: add mob death messages for owned mobs, only send to owner (sent_to = "player name")
if send_to then
local messages = mcl_death_messages.messages[reason.type] or {}

View File

@ -27,8 +27,16 @@ end
local function crystal_explode(self, puncher)
if self._exploded then return end
self._exploded = true
local strength = puncher and explosion_strength or 1
mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, puncher)
local strength = 1
local source
if puncher then
strength = explosion_strength
local reason = {}
mcl_damage.from_punch(reason, puncher)
mcl_damage.finish_reason(reason)
source = reason.source
end
mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, self.object, source)
minetest.after(0, self.object.remove, self.object)
end