From 000740ff66534c00f2b2a6a2e8185e942cadda14 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 13 Jul 2017 01:57:38 +0800 Subject: [PATCH] Reduce the batch size if fluid amount is exceeding --- .../java/gregtech/common/GT_RecipeAdder.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index 28a5902c..2b528312 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -562,6 +562,31 @@ public class GT_RecipeAdder if ((aDuration = GregTech_API.sRecipeFile.get("distillery", aOutput.getFluid().getUnlocalizedName(), aDuration)) <= 0) { return false; } + //reduce the batch size if fluid amount is exceeding + int tScale = (Math.max(aInput.amount, aOutput.amount) + 999) / 1000; + if (tScale <= 0) tScale = 1; + if (tScale > 1){ + //trying to find whether there is a better factor + for (int i = tScale; i <= 10; i++) { + if (aInput.amount % i == 0 && aDuration % i == 0) { + tScale = i; + break; + } + } + for (int i = tScale; i <= 10; i++) { + if (aInput.amount % i == 0 && aDuration % i == 0 && aOutput.amount % i == 0) { + tScale = i; + break; + } + } + aInput = new FluidStack(aInput.getFluid(), (aInput.amount + tScale - 1) / tScale); + aOutput = new FluidStack(aOutput.getFluid(), aOutput.amount / tScale); + if (aSolidOutput != null) { + if (aSolidOutput.stackSize / tScale == 0) aSolidOutput = GT_Values.NI; + else aSolidOutput = new ItemStack(aSolidOutput.getItem(), aSolidOutput.stackSize / tScale); + } + aDuration = (aDuration + tScale - 1) / tScale; + } GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sDistilleryRecipes.addRecipe(true, new ItemStack[]{aCircuit}, new ItemStack[]{aSolidOutput}, null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, aDuration, aEUt, 0); if ((aHidden) && (tRecipe != null)) { tRecipe.mHidden = true;