From b07d7d7a923d4634250ded62d9cc7a449112db01 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Sat, 13 May 2023 19:43:14 +1200 Subject: [PATCH] Ignore unknown nodes when loading in saves --- worldedit/serialization.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/worldedit/serialization.lua b/worldedit/serialization.lua index c79c2a4..f024f47 100644 --- a/worldedit/serialization.lua +++ b/worldedit/serialization.lua @@ -241,6 +241,7 @@ end --- Loads the nodes represented by string `value` at position `origin_pos`. -- @return The number of nodes deserialized. +local registered_nodes = minetest.registered_nodes function worldedit.deserialize(origin_pos, value) local nodes = load_schematic(value) if not nodes then return nil end @@ -252,11 +253,13 @@ function worldedit.deserialize(origin_pos, value) local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z local add_node, get_meta = minetest.add_node, minetest.get_meta 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 - -- Entry acts as both position and node - add_node(entry, entry) - if entry.meta then - get_meta(entry):from_table(entry.meta) + if registered_nodes[entry.name] then + entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z + -- Entry acts as both position and node + add_node(entry, entry) + if entry.meta then + get_meta(entry):from_table(entry.meta) + end end end return #nodes