Fix shulker box recolor craft erasing contents

This commit is contained in:
Wuzzy 2020-01-18 04:46:41 +01:00
parent 87ac0c952c
commit 3dcd986863
1 changed files with 23 additions and 0 deletions

View File

@ -883,6 +883,29 @@ minetest.register_craft({
} }
}) })
-- Save metadata of shulker box when used in crafting
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
local new = itemstack:get_name()
if minetest.get_item_group(itemstack:get_name(), "shulker_box") ~= 1 then
return
end
local original
for i = 1, #old_craft_grid do
local item = old_craft_grid[i]:get_name()
if minetest.get_item_group(item, "shulker_box") == 1 then
original = old_craft_grid[i]
break
end
end
if original then
local ometa = original:get_meta():to_table()
local nmeta = itemstack:get_meta()
nmeta:from_table(ometa)
return itemstack
end
end)
minetest.register_lbm({ minetest.register_lbm({
-- Disable active/open trapped chests when loaded because nobody could -- Disable active/open trapped chests when loaded because nobody could
-- have them open at loading time. -- have them open at loading time.