Update parser to unparse multiblocks

This commit is contained in:
Andrew Miner
2015-11-25 20:40:53 -08:00
parent aa43e97c6c
commit 23622a2c54
2 changed files with 21 additions and 0 deletions
@@ -297,10 +297,25 @@ module.exports = class ModVersionParserV1 extends CommandParserVersionBase
.line 'item: ', item.name .line 'item: ', item.name
.indent() .indent()
.onlyIf item.isGatherable, => builder.line 'gatherable: yes' .onlyIf item.isGatherable, => builder.line 'gatherable: yes'
.onlyIf item.multiblock?, =>
builder
.indent()
.call => @_unparseMultiblock builder, item.multiblock
.outdent()
.onlyIf recipes.length > 0, => .onlyIf recipes.length > 0, =>
builder.loop recipes, delimiter:'', onEach:(b, r)=> @_unparseRecipe(b, r) builder.loop recipes, delimiter:'', onEach:(b, r)=> @_unparseRecipe(b, r)
.outdent() .outdent()
_unparseMultiblock: (builder, multiblock)->
builder
.line 'multiblock:'
.indent()
.push "input: "
.call => @_unparseStackList builder, multiblock.input
.push ";\n"
.loop(multiblock.layers, delimiter:'', onEach:(builder, layer)=> builder.line "layer: #{layer}")
.outdent()
_unparseRecipe: (builder, recipe)-> _unparseRecipe: (builder, recipe)->
inputStacks = recipe.input[..] inputStacks = recipe.input[..]
inputStacks.sort (a, b)-> Stack.compare a, b inputStacks.sort (a, b)-> Stack.compare a, b
@@ -312,6 +312,12 @@ describe 'mod_version_parser_v1.coffee', ->
input: 4 (Empty) Tin Can, Apple input: 4 (Empty) Tin Can, Apple
pattern: .1. .0. ... pattern: .1. .0. ...
item: Pyramid
multiblock:
input: Cobblestone
layer: 000 000 000
layer: ... .0. ...
group: Functional Blocks group: Functional Blocks
item: Furnace item: Furnace