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:
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user