Add shaped crafing and recipes for MC 1.7.10
This commit is contained in:
@@ -113,11 +113,14 @@ module.exports.V1 = class V1
|
||||
if not data.input? then throw new Error "#{@_errorLocation} is missing input"
|
||||
data.tools ?= []
|
||||
|
||||
output = @_parseStackList data.output, field:'output', canBeEmpty:false
|
||||
input = @_parseStackList data.input, field:'input', canBeEmpty:true
|
||||
tools = @_parseStackList data.tools, field:'tools', canBeEmpty:true
|
||||
attributes =
|
||||
item: item
|
||||
output: @_parseStackList data.output, field:'output', canBeEmpty:false
|
||||
input: @_parseStackList data.input, field:'input', canBeEmpty:true
|
||||
tools: @_parseStackList data.tools, field:'tools', canBeEmpty:true
|
||||
attributes.pattern = data.pattern if data.pattern?
|
||||
|
||||
recipe = new Recipe item:item, input:input, output:output, tools:tools
|
||||
recipe = new Recipe attributes
|
||||
item.addRecipe recipe
|
||||
return recipe
|
||||
|
||||
@@ -201,6 +204,12 @@ module.exports.V1 = class V1
|
||||
result.push ' "input": '
|
||||
@_unparseStackList recipe.input, result
|
||||
|
||||
if recipe.pattern is recipe._computeShapelessPattern(recipe.input)
|
||||
result.push ',\n'
|
||||
result.push ' "pattern": "'
|
||||
result.push recipe.pattern
|
||||
result.push '"'
|
||||
|
||||
if recipe.tools.length > 0
|
||||
result.push ',\n'
|
||||
result.push ' "tools": '
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = class Recipe extends BaseModel
|
||||
if not attributes.input? then throw new Error 'attributes.input is required'
|
||||
if not attributes.output? then throw new Error 'attributes.output is required'
|
||||
|
||||
attributes.pattern ?= @_computeShapelessPattern attributes.input
|
||||
attributes.pattern = @_parsePattern attributes.pattern, attributes.input
|
||||
attributes.tools ?= []
|
||||
super attributes, options
|
||||
|
||||
@@ -25,7 +25,8 @@ module.exports = class Recipe extends BaseModel
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
getItemSlugAt: (index)->
|
||||
patternDigit = @pattern[index]
|
||||
trueIndex = 0:0, 1:1, 2:2, 3:4, 4:5, 5:6, 6:8, 7:9, 8:10
|
||||
patternDigit = @pattern[trueIndex[index]]
|
||||
return null unless patternDigit?
|
||||
return null unless patternDigit.match /[0-9]/
|
||||
|
||||
@@ -84,10 +85,24 @@ module.exports = class Recipe extends BaseModel
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_parsePattern: (pattern, input)->
|
||||
pattern ?= ''
|
||||
pattern = pattern.replace /\ /g, ''
|
||||
|
||||
if pattern.length > 0
|
||||
pattern = pattern.replace /[^0-9]/g, '.'
|
||||
else
|
||||
pattern = @_computeShapelessPattern input
|
||||
|
||||
pattern = pattern.replace /(...)(...)(...)/, '$1 $2 $3'
|
||||
return pattern
|
||||
|
||||
_computeShapelessPattern: (input)->
|
||||
result = []
|
||||
for i in [0...input.length]
|
||||
stack = input[i]
|
||||
for j in [0...stack.quantity]
|
||||
result.push "#{i}"
|
||||
return result.join ''
|
||||
result = '728506314'
|
||||
|
||||
total = _.reduce input, ((total, stack)-> total + stack.quantity), 0
|
||||
|
||||
for i in [total...9]
|
||||
result = result.replace "#{i}", '.'
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user