Fix various minor bugs

* Fix "update" recipes in IC2 classic to use the new "update" command
* Remove the crafting plan model from the item detail page as it isn't
  being used there right now and can be slow for complex items
* Update the `Recipe.compareFor` method to be able to work without an
  item slug as a reference
This commit is contained in:
Andrew Miner
2015-02-19 10:51:52 -08:00
parent 89247246bd
commit 2d330eedcd
5 changed files with 105 additions and 126 deletions
@@ -98,24 +98,6 @@ item: Biofuel Cell
input: Bio Cell
pattern: ... .0. ...
tools: Extractor
recipe:
input: Bio Cell
pattern: ... .0. ...
tools: Extractor
item: Blaze Powder
recipe:
input: Blaze Rod
pattern: ... .0. ...
quantity: 5
tools: Macerator
item: Bone Meal
recipe:
input: Bone
pattern: ... .0. ...
quantity: 5
tools: Macerator
item: Bronze Axe
recipe:
@@ -201,6 +183,12 @@ item: Carbon Plate
pattern: ... .0. ...
tools: Compressor
item: CF Backpack
recipe:
input: (empty) Fuel Can, CF Sprayer, Electronic Circuit, Tin Ingot
pattern: 121 030 0.0
tools: Crafting Table
item: CF Pellet
recipe:
input: Construction Foam
@@ -213,12 +201,6 @@ item: CF Sprayer
pattern: 00. 01. ..0
tools: Crafting Table
item: CF Backpack
recipe:
input: CF Sprayer, Electronic Circuit, (empty) Fuel Can, Tin Ingot
pattern: 010 232 2.2
tools: Crafting Table
item: Chainsaw
recipe:
input: Electronic Circuit, RE Battery, Refined Iron
@@ -355,6 +337,13 @@ item: Copper Ingot
item: Copper Ore
gatherable: yes
item: Crop
recipe:
input: Stick
pattern: ... 0.0 0.0
quantity: 2
tools: Crafting Table
item: Crop-Matron
recipe:
input: Chest, Crop, Electronic Circuit, Machine Block
@@ -367,13 +356,6 @@ item: Cropnalyzer
pattern: 22. 313 303
tools: Crafting Table
item: Crop
recipe:
input: Stick
pattern: ... 0.0 0.0
quantity: 2
tools: Crafting Table
item: Dense Copper Plate
recipe:
input: Copper Ingot
@@ -386,10 +368,10 @@ item: Depleted Isotope Cell
pattern: ... .0. .1.
tools: Crafting Table
item: EU Detector Cable
item: Diamond Drill
recipe:
input: Electronic Circuit, 4x Ins. HV Cable, Redstone
pattern: .0. 212 .2.
input: Diamond, Mining Drill
pattern: ... .0. 010
tools: Crafting Table
item: Diamond (industrial)
@@ -398,12 +380,6 @@ item: Diamond (industrial)
pattern: ... .0. ...
tools: Compressor
item: Diamond Drill
recipe:
input: Diamond, Mining Drill
pattern: ... .0. 010
tools: Crafting Table
item: Dual Uranium Cell
recipe:
input: Dense Copper Plate, Uranium Cell
@@ -496,6 +472,12 @@ item: Energy Storage Upgrade
pattern: 222 101 232
tools: Crafting Table
item: EU Detector Cable
recipe:
input: 4x Ins. HV Cable, Electronic Circuit, Redstone
pattern: .1. 202 .2.
tools: Crafting Table
item: EU Reader
recipe:
input: Electronic Circuit, Glowstone Dust, Insulated Copper Cable
@@ -525,12 +507,12 @@ item: Fertilizer
item: (filled) Fuel Can
recipe:
input: Coalfuel Cell, (empty) Fuel Can
pattern: 000 000 .1.
input: (empty) Fuel Can, Coalfuel Cell
pattern: 111 111 .0.
tools: Canning Machine
recipe:
input: Biofuel Cell, (empty) Fuel Can
pattern: 000 000 .1.
input: (empty) Fuel Can, Biofuel Cell
pattern: 111 111 .0.
tools: Canning Machine
item: (Filled) Tin Can
@@ -637,15 +619,10 @@ item: HV Cable
quantity: 12
tools: Crafting Table
item: Insulated HV Cable
recipe:
input: HV Cable, Rubber
pattern: ... .0. .1.
item: HV Transformer
recipe:
input: Electronic Circuit, Energy Crystal, 4x Ins. HV Cable, MV Transformer
pattern: .2. 031 .2.
input: 4x Ins. HV Cable, Electronic Circuit, Energy Crystal, MV Transformer
pattern: .0. 132 .0.
tools: Crafting Table
item: Hydrated Coal Dust
@@ -662,12 +639,6 @@ item: Hydration Cell
pattern: ... .0. ...
tools: Extractor
item: Ice
recipe:
input: Snowball
pattern: ... .0. ...
tools: Compressor
item: Induction Furnace
recipe:
input: Advanced Machine Block, Copper Ingot, Electric Furnace
@@ -691,6 +662,11 @@ item: Insulated Gold Cable
input: Gold Cable, Rubber
pattern: ... .0. .1.
item: Insulated HV Cable
recipe:
input: HV Cable, Rubber
pattern: ... .0. .1.
item: Insulation Cutter
recipe:
input: Iron Ingot, Refined Iron
@@ -742,7 +718,7 @@ item: Iron Scaffold
item: Jetpack
recipe:
input: (Empty) Fuel Can, Electronic Circuit, Redstone, Refined Iron
input: (empty) Fuel Can, Electronic Circuit, Redstone, Refined Iron
pattern: 313 303 2.2
tools: Crafting Table
@@ -893,12 +869,6 @@ item: Near-Depleted Uranium Cell
pattern: 000 010 000
tools: Crafting Table
item: Nether Brick
recipe:
input: Netherrack
pattern: .0. .0. .0.
tools: Compressor
item: Neutron Reflector
recipe:
input: Coal Dust, Dense Copper Plate, Tin Dust
@@ -1115,6 +1085,9 @@ item: Rubber Sheet
pattern: ... 000 000
tools: Crafting Table
item: Rubber Wood
gatherable: yes
item: Scaffold
recipe:
input: Oak Wood Planks, Stick
@@ -1122,6 +1095,9 @@ item: Scaffold
quantity: 16
tools: Crafting Table
item: Scrap
gatherable: yes
item: Scrap Box
recipe:
input: Scrap
@@ -1146,12 +1122,6 @@ item: Single-Use Battery
quantity: 5
tools: Crafting Table
item: Snowball
recipe:
input: Water Cell
pattern: ... .0. ...
tools: Compressor
item: Solar Helmet
recipe:
input: Insulated Copper Cable, Iron Ingot, Solar Panel
@@ -1186,13 +1156,6 @@ item: Stone Mug
pattern: 00. 000 00.
tools: Crafting Table
item: String
recipe:
input: Wool
pattern: ... .0. ...
quantity: 4
tools: Macerator
item: Terraformer
recipe:
input: Advanced Machine Block, Dirt, Glowstone Dust, TFBP - Empty
@@ -1253,13 +1216,6 @@ item: Tin Block
pattern: 000 000 000
tools: Crafting Table
item: Ultra Low Current Cable
recipe:
input: Tin Ingot
pattern: ... 000 ...
quantity: 9
tools: Crafting Table
item: Tin Can
recipe:
input: Tin Ingot
@@ -1307,6 +1263,13 @@ item: Treetap
pattern: .0. 000 0..
tools: Crafting Table
item: Ultra Low Current Cable
recipe:
input: Tin Ingot
pattern: ... 000 ...
quantity: 9
tools: Crafting Table
item: Uranium
gatherable: yes
@@ -1355,8 +1318,41 @@ item: Wrench
pattern: 0.0 000 .0.
tools: Crafting Table
item: Rubber Wood
gatherable: yes
update: Nether Brick
recipe:
input: Netherrack
pattern: .0. .0. .0.
tools: Compressor
item: Scrap
gatherable: yes
update: Blaze Powder
recipe:
input: Blaze Rod
pattern: ... .0. ...
quantity: 5
tools: Macerator
update: Bone Meal
recipe:
input: Bone
pattern: ... .0. ...
quantity: 5
tools: Macerator
update: Ice
recipe:
input: Snowball
pattern: ... .0. ...
tools: Compressor
update: Snowball
recipe:
input: Water Cell
pattern: ... .0. ...
tools: Compressor
update: String
recipe:
input: Wool
pattern: ... .0. ...
quantity: 4
tools: Macerator
@@ -2924,12 +2924,6 @@ group: Tools
pattern: 0.0 .0. 101
tools: Crafting Table
item: Windmeter
recipe:
input: Bronze Item Casing, Small Power Unit, Tin Item Casing
pattern: .2. 202 .21
tools: Crafting Table
item: Wrench
recipe:
input: Bronze Ingot
@@ -2996,6 +2990,12 @@ group: Tools: Electric
pattern: 30. 30. 121
tools: Crafting Table
item: Windmeter
recipe:
input: Bronze Item Casing, Small Power Unit, Tin Item Casing
pattern: .2. 202 .21
tools: Crafting Table
group: Tools: Painters
item: Black Painter
-22
View File
@@ -18,14 +18,6 @@ module.exports = class ItemPage extends BaseModel
attributes.item ?= null
super attributes, options
@_plan = new CraftingPlan modPack:@modPack
@on Event.change + ':item', => @_updateCraftingPlan()
@_updateCraftingPlan()
Object.defineProperties this,
craftingRawMaterials: {get:-> @_plan.need}
craftingSteps: {get:-> @_plan.steps}
# Property Methods #############################################################################
findComponentInItems: ->
@@ -56,17 +48,3 @@ module.exports = class ItemPage extends BaseModel
findRecipes: ->
return @modPack.findRecipes @item?.slug
# Private Methods ##############################################################################
_updateCraftingPlan: ->
@_plan.clear()
if @item?
@_plan.want.add @item.slug
@_plan.craft()
if @_plan.steps.length > 0
@_primaryRecipe = @_plan.steps[@_plan.steps.length - 1].recipe
else
@_primaryRecipe = null
+5 -1
View File
@@ -9,6 +9,7 @@ BaseModel = require './base_model'
{Event} = require '../constants'
Item = require './item'
ItemSlug = require './item_slug'
Recipe = require './recipe'
{RequiredMods} = require '../constants'
{Url} = require '../constants'
@@ -116,13 +117,16 @@ module.exports = class ModVersion extends BaseModel
# Recipe Methods ###############################################################################
addRecipe: (recipe)->
return unless recipe?
recipe.modVersion = this
if @_recipes[recipe.slug]? then throw new Error "duplicate recipe: #{recipe.slug}"
@_recipes[recipe.slug] = recipe
return this
eachRecipe: (callback)->
recipes = _.values(@_recipes).sort (a, b)-> a.compareTo b
recipes = _.values(@_recipes).sort (a, b)-> Recipe.compareFor a, b
for recipe in recipes
callback recipe
return this
+10 -9
View File
@@ -38,16 +38,17 @@ module.exports = class Recipe extends BaseModel
# Class Methods ################################################################################
@compareFor: (a, b, itemSlug)->
aValue = a.itemSlug.matches itemSlug
bValue = b.itemSlug.matches itemSlug
if aValue isnt bValue
return -1 if aValue
return +1 if bValue
if itemSlug?
aValue = a.itemSlug.matches itemSlug
bValue = b.itemSlug.matches itemSlug
if aValue isnt bValue
return -1 if aValue
return +1 if bValue
aValue = a.getQuantityProducedOf itemSlug
bValue = b.getQuantityProducedOf itemSlug
if aValue isnt bValue
return if aValue > bValue then -1 else +1
aValue = a.getQuantityProducedOf itemSlug
bValue = b.getQuantityProducedOf itemSlug
if aValue isnt bValue
return if aValue > bValue then -1 else +1
aValue = a.getInputCount()
bValue = b.getInputCount()