diff --git a/mods/ENTITIES/extra_mobs/glow_squid_items.lua b/mods/ENTITIES/extra_mobs/glow_squid_items.lua index db4d88e89..c7f30662b 100644 --- a/mods/ENTITIES/extra_mobs/glow_squid_items.lua +++ b/mods/ENTITIES/extra_mobs/glow_squid_items.lua @@ -54,10 +54,11 @@ minetest.register_entity("extra_mobs:glow_item_frame_item",{ end end, get_staticdata = function(self) + if not self then return end if self._nodename ~= nil and self._texture ~= nil then local ret = self._nodename .. ';' .. self._texture if self._scale ~= nil then - ret = ret .. ';' .. self._scale + ret = ret .. ';' .. tostring(self._scale) end return ret end diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 9ec06d870..3a26c1b36 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -175,10 +175,13 @@ function boat.on_activate(self, staticdata, dtime_s) end function boat.get_staticdata(self) + if not self then return end + local object = self.object + local object_properties = object and object.get_properties and object:get_properties() return minetest.serialize({ v = self._v, itemstring = self._itemstring, - textures = self.object:get_properties().textures + textures = object_properties and object_properties.textures }) end diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index d527603de..769f1d4a9 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -89,6 +89,7 @@ minetest.register_entity(":__builtin:falling_node", { }) end, get_staticdata = function(self) + if not self then return end local meta = self.meta -- Workaround: Save inventory seperately from metadata. -- Because Minetest crashes when a node with inventory gets deactivated diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 0c1e6ca05..183456309 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -488,6 +488,7 @@ minetest.register_entity(":__builtin:item", { end, get_staticdata = function(self) + if not self then return end local data = minetest.serialize({ itemstring = self.itemstring, always_collect = self.always_collect, diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 119a13523..4294c4630 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -503,6 +503,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end function cart:get_staticdata() + if not self then return end return minetest.serialize({_railtype = self._railtype}) end diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index ea7589f47..c72dca0bd 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -425,7 +425,9 @@ function mobs:register_mob(name, def) end, get_staticdata = function(self) - return mobs.mob_staticdata(self) + if self and mobs then + return mobs.mob_staticdata(self) + end end, --harmed_by_heal = def.harmed_by_heal, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index 454794dda..d9cc4237c 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -42,7 +42,7 @@ mobs.mob_staticdata = function(self) self.following = nil if use_cmi then - self.serialized_cmi_components = cmi.serialize_components(self._cmi_components) + self.serialized_cmi_components = cmi and cmi.serialize_components(self._cmi_components) end local tmp = {} diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index 26bd2c61b..74e7341ca 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -160,6 +160,7 @@ minetest.register_entity("mcl_paintings:painting", { set_entity(self.object) end, get_staticdata = function(self) + if not self then return end local data = { _facing = self._facing, _pos = self._pos, diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index cc0e02e66..0be8610f0 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -618,6 +618,7 @@ local entity_standing = { -- pattern: name of pattern (see list above) get_staticdata = function(self) + if not self then return end local out = { _base_color = self._base_color, _layers = self._layers, _name = self._name } return minetest.serialize(out) end, diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 22ac7ce2e..13b487d8a 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -441,6 +441,7 @@ function ARROW_ENTITY.on_punch(self) end function ARROW_ENTITY.get_staticdata(self) + if not self then return end local out = { lastpos = self._lastpos, startpos = self._startpos, diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index c6f6351a4..cac466376 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -630,6 +630,7 @@ function ARROW_ENTITY.on_punch(self) end function ARROW_ENTITY.get_staticdata(self) + if not self then return end local out = { lastpos = self._lastpos, startpos = self._startpos, diff --git a/mods/ITEMS/mcl_end/eye_of_ender.lua b/mods/ITEMS/mcl_end/eye_of_ender.lua index 97dee9336..d2e273c8d 100644 --- a/mods/ITEMS/mcl_end/eye_of_ender.lua +++ b/mods/ITEMS/mcl_end/eye_of_ender.lua @@ -10,7 +10,7 @@ minetest.register_entity("mcl_end:ender_eye", { -- Save and restore age get_staticdata = function(self) - return tostring(self._age) or "0" + return tostring(self and self._age) or "0" end, on_activate = function(self, staticdata, dtime_s) local age = tonumber(staticdata) diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index d46a393b8..5dde560b7 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -33,6 +33,7 @@ minetest.register_entity("mcl_itemframes:item",{ end end, get_staticdata = function(self) + if not self then return end if self._nodename and self._texture then local ret = self._nodename .. ";" .. self._texture if self._scale then diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index 37720e1e8..11339e1a4 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -352,7 +352,7 @@ local doll_def = { } doll_def.get_staticdata = function(self) - return self._mob + return self and self._mob end doll_def.on_activate = function(self, staticdata, dtime_s) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 1717533a8..907580aef 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -391,6 +391,7 @@ function mcl_potions.register_arrow(name, desc, color, def) end function ARROW_ENTITY.get_staticdata(self) + if not self then return end local out = { lastpos = self._lastpos, startpos = self._startpos, diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index b6bfb3fe8..c3c779356 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -537,6 +537,7 @@ minetest.register_entity("mcl_signs:text", { self.object:set_armor_groups({ immortal = 1 }) end, get_staticdata = function(self) + if not self then return end local out = { _signnodename = self._signnodename } return minetest.serialize(out) end, diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index c468946dd..88c69a3f3 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -57,6 +57,7 @@ end -- Staticdata handling because objects may want to be reloaded function mcl_throwing.get_staticdata(self) + if not self then return end local thrower -- Only save thrower if it's a player name if type(self._thrower) == "string" then