Fix wheat recipe issue
This commit is contained in:
parent
6d618cb0cb
commit
f93773ef31
@ -75,24 +75,25 @@ end
|
||||
|
||||
-- Grinder normaly handles 'num_items' per cycle. 'num_items' is node stage dependent.
|
||||
-- But if 'inp_num' > 1 (wheat recipes), use 'inp_num' and produce one output item.
|
||||
local function src_to_dst(src_stack, idx, num_items, inp_num, inv, dst_name, num_input)
|
||||
local taken, output
|
||||
local function src_to_dst(src_stack, idx, src_name, num_items, inp_num, inv, dst_name)
|
||||
if inp_num > 1 then
|
||||
if src_stack:get_count() >= inp_num then
|
||||
taken = src_stack:take_item(inp_num)
|
||||
output = ItemStack(dst_name)
|
||||
else
|
||||
return false
|
||||
local input = ItemStack(src_name)
|
||||
input:set_count(inp_num)
|
||||
local output = ItemStack(dst_name)
|
||||
if inv:contains_item("src", input) and inv:room_for_item("dst", output) then
|
||||
inv:remove_item("src", input)
|
||||
inv:add_item("dst", output)
|
||||
return true
|
||||
end
|
||||
else
|
||||
taken = src_stack:take_item(num_items)
|
||||
output = ItemStack(dst_name)
|
||||
local taken = src_stack:take_item(num_items)
|
||||
local output = ItemStack(dst_name)
|
||||
output:set_count(output:get_count() * taken:get_count())
|
||||
end
|
||||
if inv:room_for_item("dst", output) then
|
||||
inv:set_stack("src", idx, src_stack)
|
||||
inv:add_item("dst", output)
|
||||
return true
|
||||
if inv:room_for_item("dst", output) then
|
||||
inv:set_stack("src", idx, src_stack)
|
||||
inv:add_item("dst", output)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -104,7 +105,7 @@ local function grinding(pos, crd, nvm, inv)
|
||||
local name = stack:get_name()
|
||||
if Recipes[name] then
|
||||
local recipe = Recipes[name]
|
||||
if src_to_dst(stack, idx, crd.num_items, recipe.inp_num, inv, recipe.output) then
|
||||
if src_to_dst(stack, idx, name, crd.num_items, recipe.inp_num, inv, recipe.output) then
|
||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
else
|
||||
crd.State:blocked(pos, nvm)
|
||||
|
Loading…
Reference in New Issue
Block a user