forked from VoxeLibre/VoxeLibre
Handle conversion of mobs that were incorrectly converted
This commit is contained in:
parent
75a767a0ab
commit
0a2336ad82
|
@ -149,6 +149,11 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
|
||||
local tmp = minetest.deserialize(staticdata)
|
||||
|
||||
-- Patch incorrectly converted mobs
|
||||
if tmp.base_mesh ~= minetest.registered_entities[self.name].mesh then
|
||||
mcl_mobs.strip_staticdata(tmp)
|
||||
end
|
||||
|
||||
if tmp then
|
||||
for _,stat in pairs(tmp) do
|
||||
self[_] = stat
|
||||
|
|
|
@ -344,14 +344,17 @@ end -- END mcl_mobs.register_mob function
|
|||
|
||||
|
||||
local STRIP_FIELDS = { "mesh", "base_size", "textures", "base_mesh", "base_texture" }
|
||||
function mcl_mobs.register_conversion(old_name, new_name)
|
||||
minetest.register_entity(old_name, {
|
||||
on_activate = function(self, staticdata, dtime)
|
||||
function mcl_mobs.strip_staticdata(staticdata)
|
||||
-- Strip select fields from the staticdata to prevent conversion issues
|
||||
local unpacked_staticdata = minetest.deserialize(staticdata)
|
||||
for i = 1,#STRIP_FIELDS do
|
||||
unpacked_staticdata[STRIP_FIELDS[i]] = nil
|
||||
end
|
||||
end
|
||||
function mcl_mobs.register_conversion(old_name, new_name)
|
||||
minetest.register_entity(old_name, {
|
||||
on_activate = function(self, staticdata, dtime)
|
||||
local unpacked_staticdata = minetest.deserialize(staticdata)
|
||||
mcl_mobs.strip_staticdata(unpacked_staticdata)
|
||||
staticdata = minetest.serialize(unpacked_staticdata)
|
||||
|
||||
local old_object = self.object
|
||||
|
|
Loading…
Reference in New Issue