From c21ed5c47e18e5b4df0b944f3d18c2b218567c16 Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Sun, 18 Aug 2013 15:16:29 -0700 Subject: [PATCH] Fix bug with recipes that produce multiple items * When creating a recipe which creates multiple items (e.g., Pipe Wire in Buildcraft), the algorithm would add an extra n-1 items to the inventory. --- html/crafting.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/html/crafting.js b/html/crafting.js index 5ba85eeb5..b23795782 100644 --- a/html/crafting.js +++ b/html/crafting.js @@ -181,7 +181,9 @@ function createRecipe(data) { return recipe; } - queue.push({count: count, name: object.output[0].name}); + for (var i = 0; i < count; i++) { + craftItem({count: 1, name: object.output[0].name}); + } while (queue.length > 0) { var ingredient = queue.shift(); @@ -190,12 +192,11 @@ function createRecipe(data) { inventory.remove(1, ingredient.name); ingredient.count -= 1; } else { + console.log("Crafting ingredient: " + ingredient.name); craftItem(ingredient); } } } - - inventory.add(object.output[0].count * count, object.output[0].name); return missingMaterials; }