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'
|
global.Backbone = require 'backbone'
|
||||||
|
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
|
Logger = require '../src/scripts/logger'
|
||||||
ModVersionParser = require '../src/scripts/models/mod_version_parser'
|
ModVersionParser = require '../src/scripts/models/mod_version_parser'
|
||||||
|
|
||||||
require '../src/scripts/underscore_mixins'
|
require '../src/scripts/underscore_mixins'
|
||||||
@@ -33,6 +34,8 @@ else
|
|||||||
"""
|
"""
|
||||||
process.exit -1
|
process.exit -1
|
||||||
|
|
||||||
|
global.logger = new Logger level:Logger.WARNING
|
||||||
|
|
||||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||||
data = JSON.parse text
|
data = JSON.parse text
|
||||||
parser = new ModVersionParser
|
parser = new ModVersionParser
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
}, {
|
}, {
|
||||||
"output": "Flood Gate",
|
"output": "Flood Gate",
|
||||||
"input": [[4, "Iron Ingot"], [3, "Iron Bars"], "Iron Gear", "Tank"],
|
"input": [[4, "Iron Ingot"], [3, "Iron Bars"], "Iron Gear", "Tank"],
|
||||||
"tools": "Crafting Guide"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": "Gate Copier",
|
"output": "Gate Copier",
|
||||||
"input": ["Redstone Chipset", "Wrench"]
|
"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={})->
|
constructor: (options={})->
|
||||||
options.defaultUrl ?= ''
|
options.defaultUrl ?= ''
|
||||||
options.onLoading ?= -> @hide()
|
options.onLoading ?= -> @hide()
|
||||||
options.onLoad ?= -> @fadeIn Duration.fast
|
options.onLoad ?= -> @show()
|
||||||
|
|
||||||
@defaultUrl = options.defaultUrl
|
@defaultUrl = options.defaultUrl
|
||||||
@onLoading = options.onLoading
|
@onLoading = options.onLoading
|
||||||
|
|||||||
@@ -113,11 +113,14 @@ module.exports.V1 = class V1
|
|||||||
if not data.input? then throw new Error "#{@_errorLocation} is missing input"
|
if not data.input? then throw new Error "#{@_errorLocation} is missing input"
|
||||||
data.tools ?= []
|
data.tools ?= []
|
||||||
|
|
||||||
output = @_parseStackList data.output, field:'output', canBeEmpty:false
|
attributes =
|
||||||
input = @_parseStackList data.input, field:'input', canBeEmpty:true
|
item: item
|
||||||
tools = @_parseStackList data.tools, field:'tools', canBeEmpty:true
|
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
|
item.addRecipe recipe
|
||||||
return recipe
|
return recipe
|
||||||
|
|
||||||
@@ -201,6 +204,12 @@ module.exports.V1 = class V1
|
|||||||
result.push ' "input": '
|
result.push ' "input": '
|
||||||
@_unparseStackList recipe.input, result
|
@_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
|
if recipe.tools.length > 0
|
||||||
result.push ',\n'
|
result.push ',\n'
|
||||||
result.push ' "tools": '
|
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.input? then throw new Error 'attributes.input is required'
|
||||||
if not attributes.output? then throw new Error 'attributes.output 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 ?= []
|
attributes.tools ?= []
|
||||||
super attributes, options
|
super attributes, options
|
||||||
|
|
||||||
@@ -25,7 +25,8 @@ module.exports = class Recipe extends BaseModel
|
|||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
|
|
||||||
getItemSlugAt: (index)->
|
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?
|
||||||
return null unless patternDigit.match /[0-9]/
|
return null unless patternDigit.match /[0-9]/
|
||||||
|
|
||||||
@@ -84,10 +85,24 @@ module.exports = class Recipe extends BaseModel
|
|||||||
|
|
||||||
# Private Methods ##############################################################################
|
# 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)->
|
_computeShapelessPattern: (input)->
|
||||||
result = []
|
result = '728506314'
|
||||||
for i in [0...input.length]
|
|
||||||
stack = input[i]
|
total = _.reduce input, ((total, stack)-> total + stack.quantity), 0
|
||||||
for j in [0...stack.quantity]
|
|
||||||
result.push "#{i}"
|
for i in [total...9]
|
||||||
return result.join ''
|
result = result.replace "#{i}", '.'
|
||||||
|
|
||||||
|
return result
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ _.mixin
|
|||||||
result = text.toLowerCase()
|
result = text.toLowerCase()
|
||||||
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
||||||
result = result.replace /__+/, '_'
|
result = result.replace /__+/, '_'
|
||||||
|
result = result.replace /^_/, ''
|
||||||
|
result = result.replace /_$/, ''
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -15,4 +15,6 @@
|
|||||||
.input
|
.input
|
||||||
table.view__crafting_grid
|
table.view__crafting_grid
|
||||||
.tool: p
|
.tool: p
|
||||||
|
.output
|
||||||
|
|
||||||
.next
|
.next
|
||||||
|
|||||||
Reference in New Issue
Block a user