Add shaped crafing and recipes for MC 1.7.10
This commit is contained in:
@@ -4,6 +4,7 @@ global._ = require 'underscore'
|
||||
global.Backbone = require 'backbone'
|
||||
|
||||
fs = require 'fs'
|
||||
Logger = require '../src/scripts/logger'
|
||||
ModVersionParser = require '../src/scripts/models/mod_version_parser'
|
||||
|
||||
require '../src/scripts/underscore_mixins'
|
||||
@@ -33,6 +34,8 @@ else
|
||||
"""
|
||||
process.exit -1
|
||||
|
||||
global.logger = new Logger level:Logger.WARNING
|
||||
|
||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||
data = JSON.parse text
|
||||
parser = new ModVersionParser
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
}, {
|
||||
"output": "Flood Gate",
|
||||
"input": [[4, "Iron Ingot"], [3, "Iron Bars"], "Iron Gear", "Tank"],
|
||||
"tools": "Crafting Guide"
|
||||
"tools": "Crafting Table"
|
||||
}, {
|
||||
"output": "Gate Copier",
|
||||
"input": ["Redstone Chipset", "Wrench"]
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
+562
-169
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ module.exports = class ImageLoader
|
||||
constructor: (options={})->
|
||||
options.defaultUrl ?= ''
|
||||
options.onLoading ?= -> @hide()
|
||||
options.onLoad ?= -> @fadeIn Duration.fast
|
||||
options.onLoad ?= -> @show()
|
||||
|
||||
@defaultUrl = options.defaultUrl
|
||||
@onLoading = options.onLoading
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,4 +13,6 @@ _.mixin
|
||||
result = text.toLowerCase()
|
||||
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
||||
result = result.replace /__+/, '_'
|
||||
result = result.replace /^_/, ''
|
||||
result = result.replace /_$/, ''
|
||||
return result
|
||||
|
||||
@@ -15,4 +15,6 @@
|
||||
.input
|
||||
table.view__crafting_grid
|
||||
.tool: p
|
||||
.output
|
||||
|
||||
.next
|
||||
|
||||
Reference in New Issue
Block a user