Restore missing 'died formspec' after player exploded being in the bed

This commit is contained in:
kay27 2021-01-20 01:46:52 +04:00
parent 088f2eecae
commit 1a2c500873
2 changed files with 26 additions and 10 deletions

View File

@ -284,8 +284,18 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire,
impact = 0 impact = 0
end end
local damage = math.floor((impact * impact + impact) * 7 * strength + 1) local damage = math.floor((impact * impact + impact) * 7 * strength + 1)
local source = puncher or obj
local sleep_formspec_doesnt_close_mt53 = false
if obj:is_player() then if obj:is_player() then
local name = obj:get_player_name() local name = obj:get_player_name()
if mcl_beds then
local meta = obj:get_meta()
if meta:get_string("mcl_beds:sleeping") == "true" then
minetest.close_formspec(name, "") -- ABSOLUTELY NECESSARY FOR MT5.3 -- TODO: REMOVE THIS IN THE FUTURE
sleep_formspec_doesnt_close_mt53 = true
end
end
if mod_death_messages then if mod_death_messages then
mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name)) mcl_death_messages.player_damage(obj, S("@1 was caught in an explosion.", name))
end end
@ -293,12 +303,15 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire,
armor.last_damage_types[name] = "explosion" armor.last_damage_types[name] = "explosion"
end end
end end
local source = puncher
if not source then if sleep_formspec_doesnt_close_mt53 then
source = obj minetest.after(0.3, function(obj, damage, impact, punch_dir) -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE
end if not obj then return end
obj:punch(source, 10, { damage_groups = { full_punch_interval = 1, obj:punch(obj, 10, { damage_groups = { full_punch_interval = 1, fleshy = damage, knockback = impact * 20.0 } }, punch_dir)
fleshy = damage, knockback = impact * 20.0 } }, punch_dir) obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
end, obj, damage, impact, vector.new(punch_dir))
else
obj:punch(source, 10, { damage_groups = { full_punch_interval = 1, fleshy = damage, knockback = impact * 20.0 } }, punch_dir)
if obj:is_player() then if obj:is_player() then
obj:add_player_velocity(vector.multiply(punch_dir, impact * 20)) obj:add_player_velocity(vector.multiply(punch_dir, impact * 20))
@ -308,6 +321,7 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire,
end end
end end
end end
end
local airs, fires = {}, {} local airs, fires = {}, {}

View File

@ -141,6 +141,8 @@ function mcl_beds.register_bed(name, def)
after_destruct = destruct_bed, after_destruct = destruct_bed,
on_destruct = kick_player_after_destruct,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
mcl_beds.on_rightclick(pos, clicker, false) mcl_beds.on_rightclick(pos, clicker, false)
return itemstack return itemstack