diff options
author | Jason Mitchell <mitchej@gmail.com> | 2019-10-29 20:22:42 -0700 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2019-10-29 20:22:42 -0700 |
commit | 1f7b870f378f7fd71eed910e984fd45ccffb17f0 (patch) | |
tree | 9f1be3b0a929b39c3f6ad8646077b409df099c8b /src/main/java/gregtech/api/util | |
parent | a200e8bd2ffea5a93ec5a783ceb5c752d3c32e76 (diff) | |
download | GT5-Unofficial-1f7b870f378f7fd71eed910e984fd45ccffb17f0.tar.gz GT5-Unofficial-1f7b870f378f7fd71eed910e984fd45ccffb17f0.tar.bz2 GT5-Unofficial-1f7b870f378f7fd71eed910e984fd45ccffb17f0.zip |
More gracefully handle nulls in LCR recipes
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Recipe.java | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 5a5ba21fa4..17f54b6f53 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -814,7 +814,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (aInputs == null) return null;
int tAmount = 0;
for (ItemStack aInput : aInputs) if (aInput != null) tAmount++;
- if (tAmount < mMinimalInputItems) return null;
+ if (tAmount < mMinimalInputItems) return null;
}
}
@@ -1592,9 +1592,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (aInputs == null) {
aInputs = new ItemStack[0];
+ } else {
+ aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
}
+
for (ItemStack input : aInputs) {
- FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input);
+ FluidStack inputFluidContent = FluidContainerRegistry.getFluidForFilledItem(input);
if (inputFluidContent != null) {
inputFluidContent.amount *= input.stackSize;
if (inputFluidContent.getFluid().getName().equals("ic2steam")) {
@@ -1628,8 +1631,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> { }
aInputs = adjustedInputs.toArray(new ItemStack[adjustedInputs.size()]);
aFluidInputs = adjustedFluidInputs.toArray(new FluidStack[adjustedFluidInputs.size()]);
+
if (aOutputs == null) {
aOutputs = new ItemStack[0];
+ } else {
+ aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
}
for (ItemStack output : aOutputs) {
@@ -1677,34 +1683,36 @@ public class GT_Recipe implements Comparable<GT_Recipe> { ArrayList<PositionedStack> inputStacks = new ArrayList<PositionedStack>(inputlimit);
for (int i = 0; i < itemLimit; i++, j++) {
- if (GT_Values.allow_broken_recipemap) {
- if (this != null && this.mInputs != null && this.mInputs[i] != null)
- inputStacks.add(new FixedPositionedStack(this.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- else {
- if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
- GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
- else
- GT_Log.out.println("recipe " + this.toString() + " has errored!");
- inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- }
- }else
+ if( this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1)) ) {
+ if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
+ GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
+ else
+ GT_Log.out.println("recipe " + this.toString() + " has errored!");
+
+ new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
+ }
+
+
+ if ((this.mInputs != null && this.mInputs[i] != null) || !GT_Values.allow_broken_recipemap)
inputStacks.add(new FixedPositionedStack(this.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
+ else
+ inputStacks.add(new FixedPositionedStack(new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
}
for (int i = 0; i < fluidLimit; i++, j++) {
- if (GT_Values.allow_broken_recipemap) {
- if (this != null && this.mFluidInputs != null && this.mFluidInputs[i] != null)
- inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
- else {
- if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
- GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
- else
- GT_Log.out.println("recipe " + this.toString() + " has errored!");
- }
- }else
+ if (this.mFluidInputs == null || this.mFluidInputs[i] == null) {
+ if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null)
+ GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!");
+ else
+ GT_Log.out.println("recipe " + this.toString() + " has errored!");
+
+ new Exception("Recipe Fixme").printStackTrace(GT_Log.out);
+ }
+
+ if ((this.mFluidInputs != null && this.mFluidInputs[i] != null) || !GT_Values.allow_broken_recipemap)
inputStacks.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(this.mFluidInputs[i], true), 48 - j % 3 * 18, (j >= 3 ? 5 : 23)));
}
-
+
return inputStacks;
}
|