From 0a8ae9a3d7a151c0458c92a541dfa26b565afc49 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 14 Aug 2022 20:29:22 +0200 Subject: [PATCH] Take replacements into consideration in Quick Crafting (fix #73) --- src/common.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common.lua b/src/common.lua index 7978c31..b9465ad 100644 --- a/src/common.lua +++ b/src/common.lua @@ -408,6 +408,7 @@ end local function craft_stack(player, data, craft_rcp) local inv = player:get_inventory() local rcp_usg = craft_rcp and "recipe" or "usage" + local rcp_def = rcp_usg == "recipe" and data.recipes[data.rnum] or data.usages[data.unum] local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output output = ItemStack(output) local stackname, stackcount, stackmax = output:get_name(), output:get_count(), output:get_stack_max() @@ -441,6 +442,14 @@ local function craft_stack(player, data, craft_rcp) end end + if rcp_def.replacements then + for _, v in ipairs(rcp_def.replacements) do + for _, item2 in ipairs(v) do + get_stack(player, ItemStack(item2)) + end + end + end + local count = stackcount * scrbar_val local iter = ceil(count / stackmax) local leftover = count