diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-05-13 07:37:49 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-05-13 07:37:49 +1000 |
commit | 786ef3637908f5663cbdeea0fe0f5090c9875cb1 (patch) | |
tree | 78ad82bfca429a641183c23f753355b66a0d815f /src | |
parent | 6a9785b515ad165f68216e6eabaf98e5dba34c6a (diff) | |
download | GT5-Unofficial-786ef3637908f5663cbdeea0fe0f5090c9875cb1.tar.gz GT5-Unofficial-786ef3637908f5663cbdeea0fe0f5090c9875cb1.tar.bz2 GT5-Unofficial-786ef3637908f5663cbdeea0fe0f5090c9875cb1.zip |
% Industrial Vacuum Freezer now consumes Cryotheum while running.
$ Fixed Adv. EBF running recipes regardless of coil level.
Diffstat (limited to 'src')
5 files changed, 195 insertions, 12 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index e22f8e0f83..3cb2dbefee 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -40,10 +40,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.ArrayUtils; import gtPlusPlus.core.util.data.LocaleUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.sys.GeoUtils; import gtPlusPlus.core.util.sys.NetworkUtils; import gtPlusPlus.plugin.manager.Core_Manager; @@ -53,6 +52,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import gtPlusPlus.xmod.gregtech.loaders.GT_Material_Loader; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelterGT_GTNH; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @MCVersion(value = "1.7.10") @@ -225,8 +225,13 @@ public class GTplusplus implements ActionListener { //Advanced Vacuum Freezer generation for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sVacuumRecipes.mRecipeList) { - if (x != null && RecipeUtils.doesGregtechRecipeHaveEqualCells(x)) { - CORE.RA.addAdvancedFreezerRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, (x.mDuration/2), x.mEUt); + if (x != null && RecipeUtils.doesGregtechRecipeHaveEqualCells(x)) { + int mTime = (x.mDuration/2); + int len = x.mFluidInputs.length; + FluidStack[] y = new FluidStack[len + 1]; + int slot = y.length - 1; + y[slot] = FluidUtils.getFluidStack("cryotheum", mTime); + CORE.RA.addAdvancedFreezerRecipe(x.mInputs, y, x.mFluidOutputs, x.mOutputs, mTime, x.mEUt); } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index d0371b160f..0a8f7b041b 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1271,11 +1271,11 @@ public class RECIPES_GREGTECH { //Refine GT HF into GT++ HF GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellHydroFluoricAcid", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 2), ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid_gt5u", 5), null, // Fluid Input FluidUtils.getFluidStack("hydrofluoricacid", 6000), // Fluid Output - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 12), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 7), 2 * 20); } diff --git a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java index a60f44d95d..afccf6bd2b 100644 --- a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -6,9 +6,10 @@ import net.minecraft.item.ItemStack; public class ArrayUtils { - public static void expandArray(final Object[] someArray, final Object newValueToAdd) { + public static Object[] expandArray(final Object[] someArray, final Object newValueToAdd) { Object[] series = someArray; series = addElement(series, newValueToAdd); + return series; } private static Object[] addElement(Object[] series, final Object newValueToAdd) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index a2d71c2c15..a8a6f33b3c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + import gregtech.api.enums.TAE; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -27,18 +29,21 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta public static int CASING_TEXTURE_ID; public static String mCryoFuelName = "Gelid Cryotheum"; public static String mCasingName = "Advanced Cryogenic Casing"; + public static FluidStack mFuelStack; public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); + mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = GregtechItemList.Casing_AdvancedVacuum.get(1).getDisplayName(); } public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { super(aName); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); - mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); + mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = GregtechItemList.Casing_AdvancedVacuum.get(1).getDisplayName(); } @@ -147,6 +152,16 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta @Override public boolean hasSlotInGUI() { - return false; + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /*if (this.getBaseMetaTileEntity().isActive()) { + if (!this.depleteInput(mFuelStack.copy())) { + this.getBaseMetaTileEntity().setActive(false); + } + } */ + super.onPostTick(aBaseMetaTileEntity, aTick); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index 8fa9beac33..641ebd656b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -10,12 +10,12 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -26,7 +26,12 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase { @@ -250,5 +255,162 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase public boolean hasSlotInGUI() { return true; } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + + GT_Recipe tRecipe = this.getRecipeMap().findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null || this.mHeatingCapacity < tRecipe.mSpecialValue) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue) / 900; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at "+parallelRecipes+"."); + break; + } + Logger.WARNING("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + int rInt = 2; + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); + } + } + + if (tHeatCapacityDivTiers > 0) this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + + } }
\ No newline at end of file |