forked from VoxeLibre/VoxeLibre
Fixed creative.lua invalidating iterator in loop (#4354)
Reviewed-on: VoxeLibre/VoxeLibre#4354 Co-authored-by: the-real-herowl <wiktor_t-i@proton.me> Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
This commit is contained in:
parent
ca033d0e8d
commit
21c182fc0e
|
@ -106,11 +106,6 @@ minetest.register_on_mods_loaded(function()
|
|||
end
|
||||
if def.groups.brewitem then
|
||||
local str = name
|
||||
if def.groups._mcl_potion == 1 then
|
||||
local stack = ItemStack(name)
|
||||
tt.reload_itemstack_description(stack)
|
||||
str = stack:to_string()
|
||||
end
|
||||
table.insert(inventory_lists["brew"], str)
|
||||
nonmisc = true
|
||||
end
|
||||
|
@ -128,14 +123,12 @@ minetest.register_on_mods_loaded(function()
|
|||
local stack = ItemStack(name)
|
||||
local potency = def._default_potent_level - 1
|
||||
stack:get_meta():set_int("mcl_potions:potion_potent", potency)
|
||||
tt.reload_itemstack_description(stack)
|
||||
table.insert(inventory_lists["brew"], stack:to_string())
|
||||
end
|
||||
if def.has_plus then
|
||||
local stack = ItemStack(name)
|
||||
local extend = def._default_extend_level
|
||||
stack:get_meta():set_int("mcl_potions:potion_plus", extend)
|
||||
tt.reload_itemstack_description(stack)
|
||||
table.insert(inventory_lists["brew"], stack:to_string())
|
||||
end
|
||||
end
|
||||
|
@ -144,6 +137,17 @@ minetest.register_on_mods_loaded(function()
|
|||
end
|
||||
end
|
||||
|
||||
-- Itemstack descriptions need to be reloaded separately, because tt invalidates minetest.registered_items iterators, somehow
|
||||
-- (and pairs() uses said iterators internally)
|
||||
-- TODO investigate the iterator invalidation, where does it happen?
|
||||
for name, list in pairs(inventory_lists) do
|
||||
for i=1, #list do
|
||||
local stack = ItemStack(list[i])
|
||||
tt.reload_itemstack_description(stack)
|
||||
list[i] = stack:to_string()
|
||||
end
|
||||
end
|
||||
|
||||
for ench, def in pairs(mcl_enchanting.enchantments) do
|
||||
local str = "mcl_enchanting:book_enchanted " .. ench .. " " .. def.max_level
|
||||
if def.inv_tool_tab then
|
||||
|
|
Loading…
Reference in New Issue