From e42c5641b277850d801255d2b995477f325a3232 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 3 Feb 2018 01:03:36 +0100 Subject: [PATCH] Anvils: Fix destruction of whole material stack --- mods/ITEMS/mcl_anvils/init.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 30b9803d..58a78d39 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -197,7 +197,18 @@ local anvildef = { local meta = minetest.get_meta(pos) if listname == "output" then local inv = meta:get_inventory() - inv:set_list("input", {"",""}) + local input1 = inv:get_stack("input", 1) + local input2 = inv:get_stack("input", 2) + if not input1:is_empty() and not input2:is_empty() then + -- Both slots occupied: Repair mode. Only take 1 item from each stack + input1:take_item() + input2:take_item() + inv:set_stack("input", 1, input1) + inv:set_stack("input", 2, input2) + else + -- Otherwise: Rename mode: Clear all input slots as the whole stack is renamed. + inv:set_list("input", {"", ""}) + end end update_anvil_slots(meta) end,