From 3509b85a3e7d3b038d828b91909672b70d15d2b0 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 20 Mar 2024 22:52:33 +0100 Subject: [PATCH 1/2] Fix possible crash due to engine bug reloading XP orbs --- mods/HUD/mcl_experience/orb.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/HUD/mcl_experience/orb.lua b/mods/HUD/mcl_experience/orb.lua index 462456aad..2f703125a 100644 --- a/mods/HUD/mcl_experience/orb.lua +++ b/mods/HUD/mcl_experience/orb.lua @@ -187,10 +187,10 @@ minetest.register_entity("mcl_experience:orb", { self.object:set_armor_groups({immortal = 1}) self.object:set_velocity({x = 0, y = 2, z = 0}) self.object:set_acceleration(gravity) - local xp = tonumber(staticdata) + local xp = tonumber(staticdata) or 0 --assing 0 xp in case the entity was persisted even though it should not have been (static_save = false) this was a minetest bug for a while: https://github.com/minetest/minetest/issues/14420 self._xp = xp - size = xp_to_size(xp) - self.object:set_properties({ + size = xp_to_size(xp) + self.object:set_properties({ visual_size = {x = size, y = size}, glow = 14, }) From 44bb07507d7bbb77416a9c548ee6c42d012238bc Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 30 Mar 2024 07:27:49 +0000 Subject: [PATCH 2/2] Cleanup comment, whitespace for readability --- mods/HUD/mcl_experience/orb.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mods/HUD/mcl_experience/orb.lua b/mods/HUD/mcl_experience/orb.lua index 2f703125a..9d426a1d7 100644 --- a/mods/HUD/mcl_experience/orb.lua +++ b/mods/HUD/mcl_experience/orb.lua @@ -177,7 +177,6 @@ minetest.register_entity("mcl_experience:orb", { delete_timer = 0, radius = 4, - on_activate = function(self, staticdata, dtime_s) self.object:set_velocity(vector.new( math.random(-2,2)*math.random(), @@ -187,9 +186,13 @@ minetest.register_entity("mcl_experience:orb", { self.object:set_armor_groups({immortal = 1}) self.object:set_velocity({x = 0, y = 2, z = 0}) self.object:set_acceleration(gravity) - local xp = tonumber(staticdata) or 0 --assing 0 xp in case the entity was persisted even though it should not have been (static_save = false) this was a minetest bug for a while: https://github.com/minetest/minetest/issues/14420 + + -- Assign 0 xp in case the entity was persisted even though it should not have been (static_save = false) + -- This was a minetest bug for a while: https://github.com/minetest/minetest/issues/14420 + local xp = tonumber(staticdata) or 0 self._xp = xp size = xp_to_size(xp) + self.object:set_properties({ visual_size = {x = size, y = size}, glow = 14,