Allow item stacks as input for recipes
* Create the SlotController and refactor it into the various places where a crafting grid or crafting output is displayed * Update the Recipe model to allow each "input" stack to retain the count indicated in the data file. This required changing how a few other classes interact with it in order for them to get the full stack back again for each input (instead of just getting the item slug) * Update the ModVersionParser to allow for full stacks to be given as input and refactored common code out for handling input/output/ tools stacks
This commit is contained in:
@@ -177,7 +177,7 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
step.multiplier = Math.ceil(@need.quantityOf(step.itemSlug) / recipe.output[0].quantity)
|
||||
|
||||
if @includingTools
|
||||
for stack in recipe.tools
|
||||
recipe.eachToolStack (stack)=>
|
||||
itemSlug = @_qualifyItemSlug stack.itemSlug
|
||||
available = @result.quantityOf(itemSlug) + @need.quantityOf(itemSlug)
|
||||
needed = Math.max 0, stack.quantity - available
|
||||
@@ -185,7 +185,7 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
@need.add itemSlug, needed
|
||||
@result.add itemSlug, needed
|
||||
|
||||
for stack in recipe.input
|
||||
recipe.eachInputStack (stack)=>
|
||||
itemSlug = @_qualifyItemSlug stack.itemSlug
|
||||
needed = step.multiplier * stack.quantity
|
||||
consumed = Math.min needed, @result.quantityOf itemSlug
|
||||
@@ -194,7 +194,7 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
@result.remove itemSlug, consumed
|
||||
@need.add itemSlug, remaining
|
||||
|
||||
for stack in recipe.output
|
||||
recipe.eachOutputStack (stack)=>
|
||||
itemSlug = @_qualifyItemSlug stack.itemSlug
|
||||
created = stack.quantity * step.multiplier
|
||||
consumed = Math.min created, @need.quantityOf itemSlug
|
||||
|
||||
Reference in New Issue
Block a user