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.
|
-- 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.
|
-- 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 function src_to_dst(src_stack, idx, src_name, num_items, inp_num, inv, dst_name)
|
||||||
local taken, output
|
|
||||||
if inp_num > 1 then
|
if inp_num > 1 then
|
||||||
if src_stack:get_count() >= inp_num then
|
local input = ItemStack(src_name)
|
||||||
taken = src_stack:take_item(inp_num)
|
input:set_count(inp_num)
|
||||||
output = ItemStack(dst_name)
|
local output = ItemStack(dst_name)
|
||||||
else
|
if inv:contains_item("src", input) and inv:room_for_item("dst", output) then
|
||||||
return false
|
inv:remove_item("src", input)
|
||||||
|
inv:add_item("dst", output)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
taken = src_stack:take_item(num_items)
|
local taken = src_stack:take_item(num_items)
|
||||||
output = ItemStack(dst_name)
|
local output = ItemStack(dst_name)
|
||||||
output:set_count(output:get_count() * taken:get_count())
|
output:set_count(output:get_count() * taken:get_count())
|
||||||
end
|
if inv:room_for_item("dst", output) then
|
||||||
if inv:room_for_item("dst", output) then
|
inv:set_stack("src", idx, src_stack)
|
||||||
inv:set_stack("src", idx, src_stack)
|
inv:add_item("dst", output)
|
||||||
inv:add_item("dst", output)
|
return true
|
||||||
return true
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -104,7 +105,7 @@ local function grinding(pos, crd, nvm, inv)
|
|||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
if Recipes[name] then
|
if Recipes[name] then
|
||||||
local recipe = Recipes[name]
|
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)
|
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||||
else
|
else
|
||||||
crd.State:blocked(pos, nvm)
|
crd.State:blocked(pos, nvm)
|
||||||
|
Loading…
Reference in New Issue
Block a user