Merge pull request 'More burning HUD fixes (kabou)' (#2076) from fix-burning-hud into master

Reviewed-on: MineClone2/MineClone2#2076
This commit is contained in:
cora 2022-03-18 10:52:07 +00:00
commit 81a1b9973a
2 changed files with 5 additions and 17 deletions

View File

@ -131,17 +131,6 @@ function mcl_burning.set_on_fire(obj, burn_time)
if obj:is_player() then if obj:is_player() then
mcl_burning.update_hud(obj) mcl_burning.update_hud(obj)
end end
-- FIXME: does this code make sense? It removes attached fire luaentities from
-- another object that happen to be at the same position.
local fire_luaentity = fire_entity:get_luaentity()
for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do
local other_luaentity = other:get_luaentity()
if other_luaentity and other_luaentity.name == "mcl_burning:fire" and other_luaentity ~= fire_luaentity then
other:remove()
break
end
end
end end
function mcl_burning.extinguish(obj) function mcl_burning.extinguish(obj)

View File

@ -57,7 +57,7 @@ minetest.register_on_joinplayer(function(player)
local storage = {} local storage = {}
local burn_data = player:get_meta():get_string("mcl_burning:data") local burn_data = player:get_meta():get_string("mcl_burning:data")
if burn_data ~= "" then if burn_data ~= "" then
storage = minetest.deserialize(burn_data) storage = minetest.deserialize(burn_data) or storage
end end
mcl_burning.storage[player] = storage mcl_burning.storage[player] = storage
if storage.burn_time and storage.burn_time > 0 then if storage.burn_time and storage.burn_time > 0 then
@ -98,8 +98,7 @@ minetest.register_entity("mcl_burning:fire", {
glow = -1, glow = -1,
backface_culling = false, backface_culling = false,
}, },
animation_frame = 0, _mcl_animation_timer = 0,
animation_timer = 0,
on_activate = function(self) on_activate = function(self)
self.object:set_sprite({x = 0, y = 0}, animation_frames, 1.0 / animation_frames) self.object:set_sprite({x = 0, y = 0}, animation_frames, 1.0 / animation_frames)
end, end,
@ -115,9 +114,9 @@ minetest.register_entity("mcl_burning:fire", {
return return
end end
if parent:is_player() then if parent:is_player() then
self.animation_timer = self.animation_timer + dtime self._mcl_animation_timer = self._mcl_animation_timer + dtime
if self.animation_timer >= 0.1 then if self._mcl_animation_timer >= 0.1 then
self.animation_timer = 0 self._mcl_animation_timer = 0
mcl_burning.update_hud(parent) mcl_burning.update_hud(parent)
end end
end end