diff options
author | miozune <miozune@gmail.com> | 2023-04-06 18:20:04 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 11:20:04 +0200 |
commit | 8fd89b40f50a1af98eec25819726f6023a0f7bc0 (patch) | |
tree | 507c04e7729bd0a4599993a17dae699dd9940455 /src/main/java | |
parent | ad9d05f8730b596a64ee8d8e9d7747df1cfcea83 (diff) | |
download | GT5-Unofficial-8fd89b40f50a1af98eec25819726f6023a0f7bc0.tar.gz GT5-Unofficial-8fd89b40f50a1af98eec25819726f6023a0f7bc0.tar.bz2 GT5-Unofficial-8fd89b40f50a1af98eec25819726f6023a0f7bc0.zip |
Fix NPE in dev with Blast Smelter recipes (#592)
Co-authored-by: boubou19 <12850933+boubou19@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java index 4a82c5e92f..5504d3e439 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java @@ -8,6 +8,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.ArrayUtils; + import gregtech.api.util.*; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.ItemStackData; @@ -73,23 +75,25 @@ public class RecipeGen_BlastSmelterGT_GTNH { for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList) { ItemStack validInput = null; FluidStack validOutput = null; - // If we the input is an ingot and it and the output are valid, map it to cache. - if (x.mInputs[0] != null) { - for (int tag : OreDictionary.getOreIDs(x.mInputs[0])) { - String oreName = OreDictionary.getOreName(tag).toLowerCase(); - String mType = "ingot"; - if (oreName.startsWith(mType) && !oreName.contains("double") - && !oreName.contains("triple") - && !oreName.contains("quad") - && !oreName.contains("quintuple")) { - validInput = x.mInputs[0]; - } - } + // If there aren't both non empty inputs and outputs, we skip + if (ArrayUtils.isEmpty(x.mInputs) || ArrayUtils.isEmpty(x.mFluidOutputs)) { + continue; } - if (x.mFluidOutputs[0] != null) { - validOutput = x.mFluidOutputs[0]; + + for (int tag : OreDictionary.getOreIDs(x.mInputs[0])) { + String oreName = OreDictionary.getOreName(tag).toLowerCase(); + String mType = "ingot"; + if (oreName.startsWith(mType) && !oreName.contains("double") + && !oreName.contains("triple") + && !oreName.contains("quad") + && !oreName.contains("quintuple")) { + validInput = x.mInputs[0]; + } } - if (validInput != null && validOutput != null) { + + validOutput = x.mFluidOutputs[0]; + + if (validInput != null) { ItemStackData R = new ItemStackData(validInput); setIngotToFluid(R, validOutput); Logger.MACHINE_INFO( @@ -110,10 +114,10 @@ public class RecipeGen_BlastSmelterGT_GTNH { ItemStack validInput = null; ItemStack validOutput = null; // If we the input is an ingot and it and the output are valid, map it to cache. - if (x.mInputs != null && x.mInputs.length > 0 && x.mInputs[0] != null) { + if (ArrayUtils.isNotEmpty(x.mInputs) && x.mInputs[0] != null) { validInput = x.mInputs[0]; } - if (x.mOutputs != null && x.mOutputs.length > 0 && x.mOutputs[0] != null) { + if (ArrayUtils.isNotEmpty(x.mOutputs) && x.mOutputs[0] != null) { validOutput = x.mOutputs[0]; } if (validInput != null && validOutput != null) { |