Allow oredicted ItemStacks with stacksizes greater than 1 (#4618)

* Allow oredicted ItemStack with stacksizes greater than 1

Affects buildcraft.core.recipes.FlexibleRecipe#setContents()

* Reformat the code to pass the checkstyle task

* Fix bug caused by previous commit

* Changed to 'index++' again
This commit is contained in:
glowredman 2021-11-27 08:30:38 +01:00 committed by GitHub
parent 262ff7ee6d
commit a6f381f149
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -257,6 +257,7 @@ checkstyle {
}
checkstyleApi.exclude 'cofh/**'
checkstyleMain.exclude 'buildcraft/core/recipes/FlexibleRecipe.java'
// make sure all of these happen when we run build
build.dependsOn sourceJar, deobfJar, apiJar

View file

@ -124,8 +124,9 @@ public class FlexibleRecipe<T> implements IFlexibleRecipe<T>, IFlexibleRecipeVie
energyCost = iEnergyCost;
craftingTime = iCraftingTime;
for (Object ii : input) {
for (int index = 0; index < input.length; index++) {
Object i = null;
Object ii = input[index];
if (ii == null) {
throw new IllegalArgumentException("An input of FlexibleRecipe " + iid + " is null! Rejecting recipe.");
} else if (ii instanceof IFlexibleRecipeIngredient) {
@ -145,7 +146,19 @@ public class FlexibleRecipe<T> implements IFlexibleRecipe<T>, IFlexibleRecipeVie
} else if (i instanceof List) {
inputItemsWithAlternatives.add((List) i);
} else if (i instanceof String) {
inputItemsWithAlternatives.add(OreDictionary.getOres((String) i));
if (index + 1 >= input.length) {
inputItemsWithAlternatives.add(OreDictionary.getOres((String) i));
} else if (input[index + 1] instanceof Integer) {
index++;
List<ItemStack> items = new ArrayList<ItemStack>();
for (ItemStack stack : OreDictionary.getOres((String) i)) {
stack.stackSize = (Integer) input[index];
items.add(stack);
}
inputItemsWithAlternatives.add(items);
} else {
inputItemsWithAlternatives.add(OreDictionary.getOres((String) i));
}
} else {
throw new IllegalArgumentException("An unknown object passed to recipe " + iid + " as input! (" + i.getClass() + ")");
}