diff options
| author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-01-12 16:26:50 +0000 |
|---|---|---|
| committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-01-12 16:26:50 +0000 |
| commit | e77318c49d6aa5c1c626e32375fbb7331fbc804c (patch) | |
| tree | 748a7f4f5b0ca445fe6b350fa0f790cb8c6e5531 /src/Java/gtPlusPlus/xmod/gregtech/api | |
| parent | 5821c31b6df50cfbdd64734a12fa5add1e493e1a (diff) | |
| download | GT5-Unofficial-e77318c49d6aa5c1c626e32375fbb7331fbc804c.tar.gz GT5-Unofficial-e77318c49d6aa5c1c626e32375fbb7331fbc804c.tar.bz2 GT5-Unofficial-e77318c49d6aa5c1c626e32375fbb7331fbc804c.zip | |
% Refactored *most* Multiblock Tooltips.
% Disabled lots of debug logging.
$ Greatly improved the structural checks of many multis.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
| -rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java | 1950 |
1 files changed, 1001 insertions, 949 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 c288fac496..81f6e9281b 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 @@ -51,6 +51,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -225,11 +226,11 @@ GT_MetaTileEntity_MultiBlockBase { " "+StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); - + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + this.getPollutionPerTick(null)*20+ EnumChatFormatting.RESET+"/sec"); mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"); - + mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier")+": "+ EnumChatFormatting.GREEN+tTier+EnumChatFormatting.RESET); @@ -244,901 +245,927 @@ GT_MetaTileEntity_MultiBlockBase { mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); - String[] mInfo2 = new String[mInfo.size()]; - mInfo.toArray(mInfo2); - return mInfo2; + String[] mInfo2 = new String[mInfo.size()]; + mInfo.toArray(mInfo2); + return mInfo2; -} + } -@Override -public boolean isGivingInformation() { - return true; -} + @Override + public boolean isGivingInformation() { + return true; + } -private String[] aCachedToolTip; - -@Override -public final String[] getDescription() { - if (aCachedToolTip != null) { - return aCachedToolTip; - } - String[] x = getTooltip(); - //Add Stock Tooltip to bottom of list - String[] z; - if (getPollutionPerTick(null) > 0) { - z = new String[] { - getPollutionTooltip(), - getMachineTooltip(), - CORE.GT_Tooltip}; - } - else { - z = new String[] { - getMachineTooltip(), - CORE.GT_Tooltip}; - } - - int a2, a3; - a2 = x != null ? x.length : 0; - a3 = z != null ? z.length : 0; - String[] aToolTip = new String[(a2 + a3)]; - aToolTip = ArrayUtils.addAll(aToolTip, x); - aToolTip = ArrayUtils.addAll(aToolTip, z); - aCachedToolTip = aToolTip; - return aToolTip; -} + private String[] aCachedToolTip; -public abstract String[] getTooltip(); + /*private final String aRequiresMuffler = "1x Muffler Hatch"; + private final String aRequiresCoreModule = "1x Core Module"; + private final String aRequiresMaint = "1x Maintanence Hatch";*/ -public synchronized final MultiblockRequirements getRequirements() { - return mRequirements; -} + @Override + public final String[] getDescription() { + /*if (aCachedToolTip != null) { + boolean uuuu = false; + for (String s : aCachedToolTip) { + if (s.toLowerCase().contains(".")) { + uuuu = true; + break; + } + } + if (!uuuu) { + return aCachedToolTip; + } + else { + aCachedToolTip = null; + } + }*/ + + String aRequiresMuffler = "1x Muffler Hatch"; + String aRequiresCoreModule = "1x Core Module"; + String aRequiresMaint = "1x Maintanence Hatch"; + + String[] x = getTooltip(); + //Add Stock Tooltip to bottom of list + String[] z; + if (getPollutionPerTick(null) > 0) { + z = new String[] { + aRequiresMaint, + aRequiresCoreModule, + aRequiresMuffler, + getPollutionTooltip(), + getMachineTooltip(), + CORE.GT_Tooltip}; + } + else { + z = new String[] { + aRequiresMaint, + aRequiresCoreModule, + getMachineTooltip(), + CORE.GT_Tooltip}; + } -//public abstract MultiblockRequirements setRequirements(); + int a2, a3; + a2 = x != null ? x.length : 0; + a3 = z != null ? z.length : 0; + String[] aToolTip = new String[(a2 + a3)]; + aToolTip = ArrayUtils.addAll(aToolTip, x); + aToolTip = ArrayUtils.addAll(aToolTip, z); + aCachedToolTip = aToolTip; + return aToolTip; + } -public synchronized final void setRequirementsInternal() { - //this.mRequirements = setRequirements(); - this.mRequirements = null; -} + public abstract String[] getTooltip(); -public int getAmountOfOutputs() { - return 1; -} + public synchronized final MultiblockRequirements getRequirements() { + return mRequirements; + } -public abstract int getMaxParallelRecipes(); -public abstract int getEuDiscountForParallelism(); + //public abstract MultiblockRequirements setRequirements(); -@Override -public boolean isCorrectMachinePart(final ItemStack paramItemStack) { - return true; -} + public synchronized final void setRequirementsInternal() { + //this.mRequirements = setRequirements(); + this.mRequirements = null; + } -@Override -public int getDamageToComponent(final ItemStack paramItemStack) { - return 0; -} + public int getAmountOfOutputs() { + return 1; + } -@Override -public boolean explodesOnComponentBreak(ItemStack p0) { - return false; -} + public abstract int getMaxParallelRecipes(); + public abstract int getEuDiscountForParallelism(); -@Override -public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(getSound(), 10, 1.0F, aX, aY, aZ); + @Override + public boolean isCorrectMachinePart(final ItemStack paramItemStack) { + return true; } -} -public void startProcess() { - if(GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); -} + @Override + public int getDamageToComponent(final ItemStack paramItemStack) { + return 0; + } -public String getSound() { return ""; } + @Override + public boolean explodesOnComponentBreak(ItemStack p0) { + return false; + } -public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { - if (aRecipe.mOutputs.length > 16) { - // Gendustry custom comb with a billion centrifuge outputs? Do it anyway. - return true; + @Override + public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(getSound(), 10, 1.0F, aX, aY, aZ); + } + } + + public void startProcess() { + if(GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); } - // Count slots available in output buses - ArrayList<ItemStack> tBusStacks = new ArrayList<>(); + public String getSound() { return ""; } - int tEmptySlots = 0; - for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { - if (!isValidMetaTileEntity(tBus)) { - continue; + public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { + if (aRecipe.mOutputs.length > 16) { + // Gendustry custom comb with a billion centrifuge outputs? Do it anyway. + return true; } - final IInventory tBusInv = tBus.getBaseMetaTileEntity(); - for (int i = 0; i < tBusInv.getSizeInventory(); i++) { - if (tBus.getStackInSlot(i) == null) { - tEmptySlots++; + + // Count slots available in output buses + ArrayList<ItemStack> tBusStacks = new ArrayList<>(); + + int tEmptySlots = 0; + for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { + if (!isValidMetaTileEntity(tBus)) { + continue; } - else { - tBusStacks.add(tBus.getStackInSlot(i)); + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + tEmptySlots++; + } + else { + tBusStacks.add(tBus.getStackInSlot(i)); + } } } - } - int slotsNeeded = aRecipe.mOutputs.length; - for (final ItemStack tRecipeOutput: aRecipe.mOutputs) { - if (tRecipeOutput == null) continue; - int amount = tRecipeOutput.stackSize * aParallelRecipes; - for (final ItemStack tBusStack : tBusStacks) { - if (GT_Utility.areStacksEqual(tBusStack, tRecipeOutput)) { - if (tBusStack.stackSize + amount <= tBusStack.getMaxStackSize()) { - slotsNeeded--; - break; + int slotsNeeded = aRecipe.mOutputs.length; + for (final ItemStack tRecipeOutput: aRecipe.mOutputs) { + if (tRecipeOutput == null) continue; + int amount = tRecipeOutput.stackSize * aParallelRecipes; + for (final ItemStack tBusStack : tBusStacks) { + if (GT_Utility.areStacksEqual(tBusStack, tRecipeOutput)) { + if (tBusStack.stackSize + amount <= tBusStack.getMaxStackSize()) { + slotsNeeded--; + break; + } } } } - } - // Enough open slots? - if (tEmptySlots < slotsNeeded) return false; - - // For each output fluid, make sure an output hatch can accept it. - for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) { - if (tRecipeFluid == null) continue; - boolean tCanBufferFluid = false; - int tRecipeAmount = tRecipeFluid.amount; - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - FluidStack tHatchFluid = tHatch.getFluid(); - if (tHatchFluid == null) { - if(tHatch.getCapacity() > tRecipeAmount) { + // Enough open slots? + if (tEmptySlots < slotsNeeded) return false; + + // For each output fluid, make sure an output hatch can accept it. + for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) { + if (tRecipeFluid == null) continue; + boolean tCanBufferFluid = false; + int tRecipeAmount = tRecipeFluid.amount; + for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { + FluidStack tHatchFluid = tHatch.getFluid(); + if (tHatchFluid == null) { + if(tHatch.getCapacity() > tRecipeAmount) { + tCanBufferFluid = true; + break; + } + } + else if (tHatchFluid.isFluidEqual(tRecipeFluid) && tHatch.getCapacity() - tHatchFluid.amount > tRecipeAmount) { tCanBufferFluid = true; break; } } - else if (tHatchFluid.isFluidEqual(tRecipeFluid) && tHatch.getCapacity() - tHatchFluid.amount > tRecipeAmount) { - tCanBufferFluid = true; - break; - } + if (!tCanBufferFluid) return false; } - if (!tCanBufferFluid) return false; + return true; } - return true; -} -/** - * A Static {@link Method} object which holds the current status of logging. - */ -public static Method aLogger = null; + /** + * A Static {@link Method} object which holds the current status of logging. + */ + public static Method aLogger = null; -public void log(String s) { - boolean isDebugLogging = CORE.DEBUG; - boolean reset = false; - if (aLogger == null || reset) { - if (isDebugLogging) { - try { - aLogger = Logger.class.getMethod("INFO", String.class); - } catch (NoSuchMethodException | SecurityException e) {} - } - else { - try { - aLogger = Logger.class.getMethod("MACHINE_INFO", String.class); - } catch (NoSuchMethodException | SecurityException e) {} + public void log(String s) { + boolean isDebugLogging = CORE.DEBUG; + boolean reset = false; + if (aLogger == null || reset) { + if (isDebugLogging) { + try { + aLogger = Logger.class.getMethod("INFO", String.class); + } catch (NoSuchMethodException | SecurityException e) {} + } + else { + try { + aLogger = Logger.class.getMethod("MACHINE_INFO", String.class); + } catch (NoSuchMethodException | SecurityException e) {} + } } - } - try { - aLogger.invoke(null, s); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} + try { + aLogger.invoke(null, s); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} -} - -public boolean checkRecipeGeneric() { - return checkRecipeGeneric(1, 100, 0); -} + } -public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent) { - return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); -} + public boolean checkRecipeGeneric() { + return checkRecipeGeneric(1, 100, 0); + } -public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); -} + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent) { + return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); + } + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); + } -public boolean checkRecipeGeneric(GT_Recipe aRecipe, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - if (aRecipe == null) { - return false; - } - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); -} -public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null); -} + public boolean checkRecipeGeneric(GT_Recipe aRecipe, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + if (aRecipe == null) { + return false; + } + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); + } + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null); + } -public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. - //Control Core to control the Multiblocks behaviour. - int aControlCoreTier = getControlCoreTier(); - //If no core, return false; - if (aControlCoreTier == 0) { - log("No control core found."); - return false; - } + //Control Core to control the Multiblocks behaviour. + int aControlCoreTier = getControlCoreTier(); + //If no core, return false; + if (aControlCoreTier == 0) { + log("No control core found."); + return false; + } - // 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)); - log("Running checkRecipeGeneric(0)"); + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; - //Check to see if Voltage Tier > Control Core Tier - if (tTier > aControlCoreTier) { - log("Control core found is lower tier than power tier."); - return false; - } + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + log("Running checkRecipeGeneric(0)"); + //Check to see if Voltage Tier > Control Core Tier + if (tTier > aControlCoreTier) { + log("Control core found is lower tier than power tier."); + return false; + } - GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; + GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; - if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { - log("BAD RETURN - 2"); - return false; - } + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + log("BAD RETURN - 2"); + return false; + } - int parallelRecipes = 0; + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // 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)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // 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)) { - log("Broke at "+parallelRecipes+"."); - break; + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } + // -- Try not to fail after this point - inputs have already been consumed! -- - // -- 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); - // 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); + this.mEUt = (int)Math.ceil(tTotalEUt); - this.mEUt = (int)Math.ceil(tTotalEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + //Only Overclock as high as the control circuit. + byte tTierOld = tTier; + tTier = (byte) aControlCoreTier; - //Only Overclock as high as the control circuit. - byte tTierOld = tTier; - tTier = (byte) aControlCoreTier; + // 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 /= 2; + } + } - // 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 /= 2; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - 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 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; + } } - } - // 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; + } + } } - } - // 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); } } - } - tOutputItems = removeNulls(tOutputItems); + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } - // 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); + // 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()]); - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); - // 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()]); + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); + log("GOOD RETURN - 1"); + return true; + } - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); + public GT_Recipe reduceRecipeTimeByPercentage(final GT_Recipe tRecipe, + final float percentage) { + int cloneTime = 0; + GT_Recipe baseRecipe; + GT_Recipe cloneRecipe = null; - log("GOOD RETURN - 1"); - return true; -} + baseRecipe = tRecipe.copy(); + if ((baseRecipe != null) && ((cloneRecipe != baseRecipe) || (cloneRecipe == null))) { + cloneRecipe = baseRecipe.copy(); + log("Setting Recipe"); + } + if ((baseRecipe != null) && ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0))) { + cloneTime = baseRecipe.mDuration; + log("Setting Time"); + } -public GT_Recipe reduceRecipeTimeByPercentage(final GT_Recipe tRecipe, - final float percentage) { - int cloneTime = 0; - GT_Recipe baseRecipe; - GT_Recipe cloneRecipe = null; - - baseRecipe = tRecipe.copy(); - if ((baseRecipe != null) && ((cloneRecipe != baseRecipe) || (cloneRecipe == null))) { - cloneRecipe = baseRecipe.copy(); - log("Setting Recipe"); - } - if ((baseRecipe != null) && ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0))) { - cloneTime = baseRecipe.mDuration; - log("Setting Time"); - } - - if ((cloneRecipe != null) && cloneRecipe.mDuration > 0) { - final int originalTime = cloneRecipe.mDuration; - final int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, - (100 - percentage)); - cloneRecipe.mDuration = tempTime; - if (cloneRecipe.mDuration < originalTime) { - log("Generated recipe with a smaller time. | " - + originalTime + " | " + cloneRecipe.mDuration + " |"); - return cloneRecipe; - } else { - log("Did not generate recipe with a smaller time. | " - + originalTime + " | " + cloneRecipe.mDuration + " |"); - return tRecipe; + if ((cloneRecipe != null) && cloneRecipe.mDuration > 0) { + final int originalTime = cloneRecipe.mDuration; + final int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, + (100 - percentage)); + cloneRecipe.mDuration = tempTime; + if (cloneRecipe.mDuration < originalTime) { + log("Generated recipe with a smaller time. | " + + originalTime + " | " + cloneRecipe.mDuration + " |"); + return cloneRecipe; + } else { + log("Did not generate recipe with a smaller time. | " + + originalTime + " | " + cloneRecipe.mDuration + " |"); + return tRecipe; + } } + log("Error generating recipe, returning null."); + return null; } - log("Error generating recipe, returning null."); - return null; -} -public boolean isMachineRunning() { - boolean aRunning = this.getBaseMetaTileEntity().isActive(); - Logger.INFO("Queried Multiblock is currently running: "+aRunning); - return aRunning; -} - -@Override -public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, - final long aTick) { - - //Time Counter - if (aBaseMetaTileEntity.isServerSide()){ - this.mTotalRunTime++; + public boolean isMachineRunning() { + boolean aRunning = this.getBaseMetaTileEntity().isActive(); + Logger.INFO("Queried Multiblock is currently running: "+aRunning); + return aRunning; } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mChargeHatches.clear(); - this.mDischargeHatches.clear(); - this.mControlCoreBus.clear(); - this.mMultiDynamoHatches.clear(); + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, + final long aTick) { + + //Time Counter + if (aBaseMetaTileEntity.isServerSide()){ + this.mTotalRunTime++; } - } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mChargeHatches.clear(); + this.mDischargeHatches.clear(); + this.mControlCoreBus.clear(); + this.mMultiDynamoHatches.clear(); + } + } - super.onPostTick(aBaseMetaTileEntity, aTick); -} -@Override -public void explodeMultiblock() { - MetaTileEntity tTileEntity; - for (final Iterator<GT_MetaTileEntity_Hatch_InputBattery> localIterator = this.mChargeHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } - tTileEntity = null; - for (final Iterator<GT_MetaTileEntity_Hatch_OutputBattery> localIterator = this.mDischargeHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } - tTileEntity = null; - for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mMultiDynamoHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); + super.onPostTick(aBaseMetaTileEntity, aTick); } + @Override + public void explodeMultiblock() { + MetaTileEntity tTileEntity; + for (final Iterator<GT_MetaTileEntity_Hatch_InputBattery> localIterator = this.mChargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch_OutputBattery> localIterator = this.mDischargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mMultiDynamoHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } - super.explodeMultiblock(); -} -protected int getGUICircuit(ItemStack[] t) { - Item g = CI.getNumberedCircuit(0).getItem(); - ItemStack guiSlot = this.mInventory[1]; - int mMode = -1; - if (guiSlot != null && guiSlot.getItem() == g) { - this.mInternalCircuit = true; - return guiSlot.getItemDamage(); - } - else { - this.mInternalCircuit = false; + super.explodeMultiblock(); } - if (!this.mInternalCircuit) { - for (ItemStack j : t) { - if (j.getItem() == g) { - mMode = j.getItemDamage(); - break; + protected int getGUICircuit(ItemStack[] t) { + Item g = CI.getNumberedCircuit(0).getItem(); + ItemStack guiSlot = this.mInventory[1]; + int mMode = -1; + if (guiSlot != null && guiSlot.getItem() == g) { + this.mInternalCircuit = true; + return guiSlot.getItemDamage(); + } + else { + this.mInternalCircuit = false; + } + + if (!this.mInternalCircuit) { + for (ItemStack j : t) { + if (j.getItem() == g) { + mMode = j.getItemDamage(); + break; + } } } + return mMode; } - return mMode; -} -protected ItemStack getGUIItemStack() { - ItemStack guiSlot = this.mInventory[1]; - return guiSlot; -} + protected ItemStack getGUIItemStack() { + ItemStack guiSlot = this.mInventory[1]; + return guiSlot; + } -@Override -public void updateSlots() { - for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.updateSlots(); + @Override + public void updateSlots() { + for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } } - } - for (final GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { - if (isValidMetaTileEntity(tHatch)) { |
