diff options
Diffstat (limited to 'src/Java')
28 files changed, 1462 insertions, 1543 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index dd07e2cf8d..90bb90f6d0 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -814,10 +814,10 @@ public class ItemUtils { if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name")) { mLocaleCache.remove(mCacheKey); String mNew = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); - Logger.INFO("Re-caching "+mNew+" into locale cache."); + //Logger.INFO("Re-caching "+mNew+" into locale cache."); mLocaleCache.put(mCacheKey, mNew); } - Logger.INFO("Returning Cached Value."); + //Logger.INFO("Returning Cached Value."); return mLocaleCache.get(mCacheKey); } else { Item item = Item.getItemFromBlock(block); @@ -830,7 +830,7 @@ public class ItemUtils { blockName = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); } mLocaleCache.put(mCacheKey, blockName); - Logger.INFO("Cached New Value."); + //Logger.INFO("Cached New Value."); return blockName; } } 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); + |
