aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-09-19 07:16:30 +1000
committerAlkalus <draknyte1@hotmail.com>2017-09-19 07:16:30 +1000
commit98d4998aafa2f5b6f1ad518b6effe52b6a7c7c18 (patch)
tree7fd4e6e103ec937347f2bfa88e0b06534b9d2d7b /src
parentedb43bce755587ce57142ae7bb5a67f56c5f09cd (diff)
downloadGT5-Unofficial-98d4998aafa2f5b6f1ad518b6effe52b6a7c7c18.tar.gz
GT5-Unofficial-98d4998aafa2f5b6f1ad518b6effe52b6a7c7c18.tar.bz2
GT5-Unofficial-98d4998aafa2f5b6f1ad518b6effe52b6a7c7c18.zip
% Changed Wash Plant recipe handling.
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java84
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java143
2 files changed, 163 insertions, 64 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 911ba9a88e..fa551407ce 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -937,38 +937,58 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity {
}
public int getValidOutputSlots(final IGregTechTileEntity machineCalling, final GT_Recipe sRecipes, final ItemStack[] sInputs){
- Utils.LOG_WARNING("Finding valid output slots for "+machineCalling.getInventoryName());
- final ArrayList<ItemStack> tInputList = this.getStoredInputs();
- final GT_Recipe tRecipe = sRecipes;
- final int outputItemCount = tRecipe.mOutputs.length;
- int tValidOutputHatches = 0;
-
- for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
- if (!isValidMetaTileEntity(tHatch)) continue;
-
- int tEmptySlots = 0;
- boolean foundRoom = false;
- final IInventory tHatchInv = tHatch.getBaseMetaTileEntity();
- for(int i = 0; i < tHatchInv.getSizeInventory() && !foundRoom; ++i)
- {
- if(tHatchInv.getStackInSlot(i) != null) continue;
-
- tEmptySlots++;
- if(tEmptySlots < outputItemCount) continue;
-
- tValidOutputHatches++;
- foundRoom = true;
- }
- }
-
- return tValidOutputHatches;
- }
-
+ Utils.LOG_INFO("Finding valid output slots for "+machineCalling.getInventoryName());
+
+ try{
+
+ if (sRecipes == null){
+ return 0;
+ }
+
+ final ArrayList<ItemStack> tInputList = this.getStoredInputs();
+ final GT_Recipe tRecipe = sRecipes;
+ final int outputItemCount;
+ if (tRecipe.mOutputs != null){
+ outputItemCount= tRecipe.mOutputs.length;
+ }
+ else {
+ outputItemCount= 0;
+ }
+ int tValidOutputHatches = 0;
+
+ for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
+ if (!isValidMetaTileEntity(tHatch)) continue;
+
+ int tEmptySlots = 0;
+ boolean foundRoom = false;
+ final IInventory tHatchInv = tHatch.getBaseMetaTileEntity();
+ for(int i = 0; i < tHatchInv.getSizeInventory() && !foundRoom; ++i)
+ {
+ if(tHatchInv.getStackInSlot(i) != null) continue;
+
+ tEmptySlots++;
+ if(tEmptySlots < outputItemCount) continue;
+
+ tValidOutputHatches++;
+ foundRoom = true;
+ }
+ }
+ if (tValidOutputHatches < 0){
+ tValidOutputHatches = 0;
+ }
+
+ return tValidOutputHatches;
+ } catch (Throwable t){
+ t.printStackTrace();
+ return 0;
+ }
+ }
+
public GT_Recipe reduceRecipeTimeByPercentage(GT_Recipe tRecipe, float percentage){
int cloneTime = 0;
GT_Recipe baseRecipe;
GT_Recipe cloneRecipe = null;
-
+
baseRecipe = tRecipe.copy();
if (cloneRecipe != baseRecipe || cloneRecipe == null){
cloneRecipe = baseRecipe.copy();
@@ -978,7 +998,7 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity {
cloneTime = baseRecipe.mDuration;
Utils.LOG_WARNING("Setting Time");
}
-
+
if (cloneRecipe.mDuration > 0){
int originalTime = cloneRecipe.mDuration;
int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, (100-percentage));
@@ -991,9 +1011,9 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity {
}
}
return null;
-
-
-
+
+
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java
index a0f244ade3..b1da555095 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWashPlant.java
@@ -1,6 +1,10 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
import gregtech.api.enums.TAE;
import gregtech.api.enums.Textures;
@@ -50,7 +54,6 @@ extends GregtechMeta_MultiBlockBase {
"1x Input Bus (Any casing)",
"1x Output Bus (Any casing)",
"1x Maintenance Hatch (Any casing)",
- "1x Muffler Hatch (Any casing)",
"1x Energy Hatch (Any casing)",
CORE.GT_Tooltip
@@ -84,46 +87,122 @@ extends GregtechMeta_MultiBlockBase {
public boolean checkRecipe(final ItemStack aStack) {
if (!checkForWater()){
+ Utils.LOG_INFO("Did not find enough cleaning solution.");
return false;
}
-
final ArrayList<ItemStack> tInputList = this.getStoredInputs();
- for (final ItemStack tInput : tInputList) {
+ for (int i = 0; i < (tInputList.size() - 1); i++) {
+ for (int j = i + 1; j < tInputList.size(); j++) {
+ if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) {
+ if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) {
+ tInputList.remove(j--);
+ } else {
+ tInputList.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+ final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2);
+
+ final ArrayList<FluidStack> tFluidList = this.getStoredFluids();
+ for (int i = 0; i < (tFluidList.size() - 1); i++) {
+ for (int j = i + 1; j < tFluidList.size(); j++) {
+ if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) {
+ if (tFluidList.get(i).amount >= tFluidList.get(j).amount) {
+ tFluidList.remove(j--);
+ } else {
+ tFluidList.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+ final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1);
+
+ Utils.LOG_INFO("0");
+ final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[(byte) Math.max(1, GT_Utility.getTier(this.getMaxInputVoltage()))], tFluids, tInputs), tInputs);
+ Utils.LOG_INFO("Valid Output Slots: "+tValidOutputSlots);
+
+ //More than or one input
+ if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) {
+ Utils.LOG_INFO("1");
final long tVoltage = this.getMaxInputVoltage();
final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
+ tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 40F);
+ if ((tRecipe != null) && (7500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) {
+ this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000));
+ this.mEfficiencyIncrease = 10000;
+ if (tRecipe.mEUt <= 16) {
+ this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1)));
+ this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1)));
+ } else {
+ this.mEUt = tRecipe.mEUt;
+ this.mMaxProgresstime = tRecipe.mDuration;
+ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
+ this.mEUt *= 4;
+ this.mMaxProgresstime /= 2;
+ }
+ }
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput});
- tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F);
- if (tRecipe != null) {
-
- final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), tRecipe, new ItemStack[]{tInput});
- Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots);
- //More than or one input
- if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) {
-
- if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) {
- this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000));
- this.mEfficiencyIncrease = 10000;
- if (tRecipe.mEUt <= 16) {
- this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1)));
- this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1)));
- } else {
- this.mEUt = tRecipe.mEUt;
- this.mMaxProgresstime = tRecipe.mDuration;
- while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
- this.mEUt *= 4;
- this.mMaxProgresstime /= 2;
+ ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length];
+ for (int h = 0; h < tRecipe.mOutputs.length; h++) {
+ tOut[h] = tRecipe.getOutput(h).copy();
+ tOut[h].stackSize = 0;
+ }
+ FluidStack tFOut = null;
+ if (tRecipe.getFluidOutput(0) != null) {
+ tFOut = tRecipe.getFluidOutput(0).copy();
+ }
+ for (int f = 0; f < tOut.length; f++) {
+ if ((tRecipe.mOutputs[f] != null) && (tOut[f] != null)) {
+ for (int g = 0; g < 1; g++) {
+ if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) {
+ tOut[f].stackSize += tRecipe.mOutputs[f].stackSize;
}
}
- if (this.mEUt > 0) {
- this.mEUt = (-this.mEUt);
+ }
+ }
+ if (tFOut != null) {
+ final int tSize = tFOut.amount;
+ tFOut.amount = tSize * 1;
+ }
+
+ final List<ItemStack> overStacks = new ArrayList<>();
+ for (int f = 0; f < tOut.length; f++) {
+ if (tOut[f].getMaxStackSize() < tOut[f].stackSize) {
+ while (tOut[f].getMaxStackSize() < tOut[f].stackSize) {
+ final ItemStack tmp = tOut[f].copy();
+ tmp.stackSize = tmp.getMaxStackSize();
+ tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize();
+ overStacks.add(tmp);
}
- this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
- this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)};
- this.updateSlots();
- return true;
}
}
+ if (overStacks.size() > 0) {
+ ItemStack[] tmp = new ItemStack[overStacks.size()];
+ tmp = overStacks.toArray(tmp);
+ tOut = ArrayUtils.addAll(tOut, tmp);
+ }
+ final List<ItemStack> tSList = new ArrayList<>();
+ for (final ItemStack tS : tOut) {
+ if (tS.stackSize > 0) {
+ tSList.add(tS);
+ }
+ }
+ tOut = tSList.toArray(new ItemStack[tSList.size()]);
+ this.mOutputItems = tOut;
+ this.mOutputFluids = new FluidStack[]{tFOut};
+ this.updateSlots();
+
+ /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)};
+ updateSlots();*/
+ return true;
}
}
return false;
@@ -351,13 +430,13 @@ extends GregtechMeta_MultiBlockBase {
}
}
}
- if ((tAmount == 45)){
+ if ((tAmount >= 45)){
Utils.LOG_WARNING("Filled structure.");
}
else {
Utils.LOG_WARNING("Did not fill structure.");
}
- return (tAmount == 45);
+ return (tAmount >= 45);
}
} \ No newline at end of file