Fix itemdef defaults not being applied in async env

This commit is contained in:
sfan5 2023-06-24 17:58:43 +02:00
parent f6bddc4e8d
commit 43c9c38a28
3 changed files with 12 additions and 0 deletions

@ -36,11 +36,16 @@ do
setmetatable(v, {__newindex = {}}) setmetatable(v, {__newindex = {}})
-- Reassemble the other tables -- Reassemble the other tables
if v.type == "node" then if v.type == "node" then
getmetatable(v).__index = all.nodedef_default
all.registered_nodes[k] = v all.registered_nodes[k] = v
elseif v.type == "craft" then elseif v.type == "craft" then
getmetatable(v).__index = all.craftitemdef_default
all.registered_craftitems[k] = v all.registered_craftitems[k] = v
elseif v.type == "tool" then elseif v.type == "tool" then
getmetatable(v).__index = all.tooldef_default
all.registered_tools[k] = v all.registered_tools[k] = v
else
getmetatable(v).__index = all.noneitemdef_default
end end
end end

@ -261,6 +261,11 @@ function core.get_globals_to_transfer()
local all = { local all = {
registered_items = copy_filtering(core.registered_items), registered_items = copy_filtering(core.registered_items),
registered_aliases = core.registered_aliases, registered_aliases = core.registered_aliases,
nodedef_default = copy_filtering(core.nodedef_default),
craftitemdef_default = copy_filtering(core.craftitemdef_default),
tooldef_default = copy_filtering(core.tooldef_default),
noneitemdef_default = copy_filtering(core.noneitemdef_default),
} }
return all return all
end end

@ -19,6 +19,8 @@ local function do_tests()
-- alias handling -- alias handling
assert(core.registered_items["unittests:steel_ingot_alias"].name == assert(core.registered_items["unittests:steel_ingot_alias"].name ==
"unittests:steel_ingot") "unittests:steel_ingot")
-- fallback to item defaults
assert(core.registered_items["unittests:description_test"].on_place == true)
end end
function unittests.async_test() function unittests.async_test()