GregTechCE / GregTech

GregTech rewrite for modern versions of Minecraft
GNU Lesser General Public License v3.0
269 stars 150 forks source link

Fixed CT 'inputs' getter, added 'nonConsumable' getter #1728

Open TheDarkDnKTv opened 2 years ago

TheDarkDnKTv commented 2 years ago

Closes #1439

What

While iterating recipes, in case recipe has non consumable ingredient (count = 0), it will crash. Crafttweaker has check for empty stacks.

How solved:

Added filtration of inputs, to provide only normal ingredients. Non consumables getter was missing, so I added it.

Outcome:

Additional info:

Crash

java.lang.IllegalArgumentException: stack cannot be null
    at crafttweaker.mc1120.item.MCItemStack.<init>(MCItemStack.java:94)
    at crafttweaker.mc1120.item.MCItemStack.withAmount(MCItemStack.java:238)
    at crafttweaker.mc1120.item.MCItemStack.amount(MCItemStack.java:336)
    at crafttweaker.mc1120.item.MCItemStack.amount(MCItemStack.java:56)
    at gregtech.api.recipes.crafttweaker.InputIngredient.<init>(InputIngredient.java:23)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Iterator.forEachRemaining(Unknown Source)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.collect(Unknown Source)
    at gregtech.api.recipes.crafttweaker.CTRecipe.getInputs(CTRecipe.java:37)

ZenScript example

for recipe in RecipeMaps.BLAST_RECIPES.recipes {
  var ingredients = recipe.inputs;
}

Possible compatibility issue:

None, API changes only adds method, and fixing broken logic of one of old.