Closed fluxionary closed 5 months ago
I edited the the worldedit.deserialize function in worldedit/serialization.lua and it seemed to work. It maintains a table of already checked nodes and only tests minetest.registered_nodes if not in the shorter table. I don't know how much more expedient this is in real terms.
function worldedit.deserialize(origin_pos, value)
local nodes = load_schematic(value)
if not nodes then return nil end
if #nodes == 0 then return #nodes end
local pos1, pos2 = worldedit.allocate_with_nodes(origin_pos, nodes)
worldedit.keep_loaded(pos1, pos2)
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
local count = 0
local add_node, get_meta = minetest.add_node, minetest.get_meta
local node_check = { }
for i, entry in ipairs(nodes) do
entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z
local checked = node_check[entry.name]
if not checked then
if minetest.registered_nodes[entry.name] then
node_check[entry.name] = true
checked = true
end
end
if checked then
-- Entry acts as both position and node
add_node(entry, entry)
if entry.meta then
get_meta(entry):from_table(entry.meta)
end
else
print (string.format ("WorldEdit unknown node \"%s\"", entry.name or ""))
end
end
return #nodes
end
//save
on one server//load
result:
a possible fix would be to do a check to make sure all the nodes are registered before modifying the world, though that would slow down an already slow process.