Don't show pass-through recipes
A pass-through recipe is one which requires an item as input which is carried through to the output (e.g., using a Golden Railway Ticket to create a regular Railway Ticket in Railcraft). As these aren't really recipes, they should not be listed as such in the item detail page.
This commit is contained in:
@@ -99,13 +99,26 @@ module.exports = class Recipe extends BaseModel
|
||||
|
||||
return 0
|
||||
|
||||
isPassThroughFor: (itemSlug)->
|
||||
amountCreated = 0
|
||||
for stack in @output
|
||||
if stack.itemSlug.matches itemSlug
|
||||
amountCreated += stack.quantity
|
||||
|
||||
for stack in @input
|
||||
if stack.itemSlug.matches itemSlug
|
||||
amountCreated -= stack.quantity
|
||||
|
||||
return amountCreated <= 0
|
||||
|
||||
produces: (itemSlug)->
|
||||
if not @_produces?
|
||||
@_produces = {}
|
||||
|
||||
for stack in @output
|
||||
@_produces[stack.itemSlug.qualified] = true
|
||||
@_produces[stack.itemSlug.item] = true
|
||||
actuallyProduces = not @isPassThroughFor stack.itemSlug
|
||||
@_produces[stack.itemSlug.qualified] = actuallyProduces
|
||||
@_produces[stack.itemSlug.item] = actuallyProduces
|
||||
|
||||
return @_produces[itemSlug.qualified] or @_produces[itemSlug.item]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user