diff options
author | GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com> | 2022-12-21 18:56:41 +0000 |
---|---|---|
committer | GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com> | 2022-12-21 18:56:41 +0000 |
commit | 82ca849f75cd6d4e3160c619b552b37ddd8dc1c4 (patch) | |
tree | a34ed4fe821fc021b2fd85e51333ea5fa9b0a3ff /src/main | |
parent | 5b017150822b4780108d1d705c015fa5504c3315 (diff) | |
download | GT5-Unofficial-82ca849f75cd6d4e3160c619b552b37ddd8dc1c4.tar.gz GT5-Unofficial-82ca849f75cd6d4e3160c619b552b37ddd8dc1c4.tar.bz2 GT5-Unofficial-82ca849f75cd6d4e3160c619b552b37ddd8dc1c4.zip |
Fix recipe yield by changing shallow to deep copies of objects.
Diffstat (limited to 'src/main')
3 files changed, 31 insertions, 13 deletions
diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java index 2ec4ffabb1..aa71c388d8 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java @@ -67,12 +67,24 @@ public class EyeOfHarmonyRecipe { this.miningTimeSeconds = miningTimeSeconds; } - public List<ItemStackLong> getOutputItems() { - return outputItems; + // Return clone of list. + public ArrayList<ItemStackLong> getOutputItems() { + ArrayList<ItemStackLong> copyOutputList = new ArrayList<>(); + for (ItemStackLong itemStackLong : outputItems) { + copyOutputList.add(new ItemStackLong(itemStackLong)); + } + + return copyOutputList; } public FluidStack[] getOutputFluids() { - return outputFluids; + ArrayList<FluidStack> copyOutputList = new ArrayList<>(); + + for (FluidStack fluidStack : outputFluids) { + copyOutputList.add(fluidStack.copy()); + } + + return copyOutputList.toArray(new FluidStack[0]); } public long getHydrogenRequirement() { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java index 8599a97432..72d9e80bf4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java @@ -1694,8 +1694,8 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl public boolean processRecipe(EyeOfHarmonyRecipe recipeObject) { - if ((getHydrogenStored() < currentRecipe.getHydrogenRequirement()) - && (getHeliumStored() < currentRecipe.getHeliumRequirement())) { + // todo: fix changing the tier of block causing multi to unform + if ((getHydrogenStored() < currentRecipe.getHydrogenRequirement()) || (getHeliumStored() < currentRecipe.getHeliumRequirement())) { return false; } @@ -1731,18 +1731,18 @@ public class GT_MetaTileEntity_EM_EyeOfHarmony extends GT_MetaTileEntity_Multibl validFluidMap.put(Materials.Helium.getGas(1), 0L); double yield = recipeYieldCalculator(); - yield = 1; //todo debug, remove. successChance = 1; // todo debug, remove. - mOutputFluids = recipeObject.getOutputFluids().clone(); - - // Iterate over item output list and apply yield values. - for (ItemStackLong itemStack : recipeObject.getOutputItems()) { - itemStack.stackSize *= yield; - outputItems.add(itemStack); - } + // Return copies of the output objects. + mOutputFluids = recipeObject.getOutputFluids(); + outputItems = recipeObject.getOutputItems(); if (yield != 1.0) { + // Iterate over item output list and apply yield values. + for (ItemStackLong itemStackLong : outputItems) { + itemStackLong.stackSize *= yield; + } + // Iterate over fluid output list and apply yield values. for (FluidStack fluidStack : mOutputFluids) { fluidStack.amount *= yield; diff --git a/src/main/java/com/github/technus/tectech/util/ItemStackLong.java b/src/main/java/com/github/technus/tectech/util/ItemStackLong.java index e245cc94bf..68a7bafd04 100644 --- a/src/main/java/com/github/technus/tectech/util/ItemStackLong.java +++ b/src/main/java/com/github/technus/tectech/util/ItemStackLong.java @@ -11,4 +11,10 @@ public class ItemStackLong { this.itemStack = itemStack; this.stackSize = stackSize; } + + // Copy constructor. + public ItemStackLong(ItemStackLong itemStackLong) { + this.itemStack = itemStackLong.itemStack; + this.stackSize = itemStackLong.stackSize; + } } |