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.
This commit is contained in:
Andrew Miner
2013-08-18 15:16:29 -07:00
parent 06247b258b
commit c21ed5c47e
+4 -3
View File
@@ -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;
}