aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
authorBlueWeabo <ilia.iliev2005@gmail.com>2023-07-24 19:11:34 +0300
committerGitHub <noreply@github.com>2023-07-24 18:11:34 +0200
commit5a4f0bfa3d1826d9a5634baea76f90333d2ae628 (patch)
tree62dee7ccb7fb09eb18d732703ff1a25c6c87af33 /src/main/java/gregtech
parentbbe274de228f3f5a18f3710d2f517fdd721a9de1 (diff)
downloadGT5-Unofficial-5a4f0bfa3d1826d9a5634baea76f90333d2ae628.tar.gz
GT5-Unofficial-5a4f0bfa3d1826d9a5634baea76f90333d2ae628.tar.bz2
GT5-Unofficial-5a4f0bfa3d1826d9a5634baea76f90333d2ae628.zip
Make Parallel Helper do better chanced output calculation for paralleled chanced recipes (#2130)
* better calculation * roll for each parallel * skip rolling for recipes with chance at 100% * address not setting as null when stcksize is 0
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r--src/main/java/gregtech/api/util/GT_ParallelHelper.java42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
index 47b8ba17fb..07439967d3 100644
--- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java
+++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
@@ -413,19 +413,7 @@ public class GT_ParallelHelper {
// If we want to calculate outputs we do it here
if (mCalculateOutputs && mCurrentParallel > 0) {
if (mRecipe.mOutputs != null) {
- mItemOutputs = new ItemStack[mRecipe.mOutputs.length];
- for (int i = 0; i < mRecipe.mOutputs.length; i++) {
- if (mRecipe.getOutputChance(i) >= XSTR.XSTR_INSTANCE.nextInt(10000)) {
- if (mRecipe.getOutput(i) == null) {
- mItemOutputs[i] = null;
- } else {
- ItemStack tItem = mRecipe.getOutput(i)
- .copy();
- tItem.stackSize *= mCurrentParallel;
- mItemOutputs[i] = tItem;
- }
- }
- }
+ calculateItemOutputs();
}
if (mRecipe.mFluidOutputs != null) {
mFluidOutputs = new FluidStack[mRecipe.mFluidOutputs.length];
@@ -442,4 +430,32 @@ public class GT_ParallelHelper {
}
}
}
+
+ protected void calculateItemOutputs() {
+ mItemOutputs = new ItemStack[mRecipe.mOutputs.length];
+ for (int i = 0; i < mRecipe.mOutputs.length; i++) {
+ if (mRecipe.getOutputChance(i) >= 10000) {
+ ItemStack item = mRecipe.getOutput(i)
+ .copy();
+ item.stackSize *= mCurrentParallel;
+ mItemOutputs[i] = item;
+ continue;
+ }
+ int items = 0;
+ int itemStackSize = mRecipe.getOutput(i).stackSize;
+ for (int roll = 0; roll < mCurrentParallel; roll++) {
+ if (mRecipe.getOutputChance(i) >= XSTR.XSTR_INSTANCE.nextInt(10000)) {
+ items += itemStackSize;
+ }
+ }
+ ItemStack item = mRecipe.getOutput(i)
+ .copy();
+ if (items == 0) {
+ item = null;
+ } else {
+ item.stackSize = items;
+ }
+ mItemOutputs[i] = item;
+ }
+ }
}