diff options
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java | 204 |
1 files changed, 103 insertions, 101 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 298ad948e6..b8f6578448 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -105,123 +105,125 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi //Get Inventory Item ItemStack aStack = this.mInventory[SLOT_ROTOR]; - + //Enable machine animation/graphic if (this.mHasPollution && mCurrentPollution > 0 && slotContainsRotor(aStack)){ aBaseMetaTileEntity.setActive(true); - this.mEUt = mTier; } else if (!this.mHasPollution || mCurrentPollution <= 0 || aStack == null){ aBaseMetaTileEntity.setActive(false); - this.mEUt = 0; } + //Power Drain - if (aTick % 2L == 0L){ - aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.pow(mTier/4, mTier/2), false); + if (aTick % 1L == 0L){ + long drainEU = V[mTier]; + if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){ + Utils.LOG_INFO("Draining "+drainEU+" EU"); + } + } + else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){ + //Utils.LOG_INFO("Draining "+(drainEU/4)+" EU"); + } + } + else { + aBaseMetaTileEntity.setActive(false); + } } //Only try once/sec. if (aTick % 20L == 0L){ - //Utils.LOG_INFO("Pollution Cleaner [1]"); //Check if machine can work. - if ((aBaseMetaTileEntity.isAllowedToWork())/* && (getBaseMetaTileEntity().getRedstone())*/){ - //Utils.LOG_INFO("Pollution Cleaner [2] | "+aBaseMetaTileEntity.getStoredEU()+" | "+getMinimumStoredEU()); - - //Check if enough power to work. - if (aBaseMetaTileEntity.getStoredEU() >= getMinimumStoredEU()) { - //Utils.LOG_INFO("Pollution Cleaner [3] | Power Stored:"+aBaseMetaTileEntity.getStoredEU()); - - //Drain some power. - if (aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.pow(2, mTier), false)){ - - //Do nothing if there is no pollution or machine is not active. - if(this.mHasPollution && mCurrentPollution > 0){ - - //Use a Turbine - if(slotContainsRotor(aStack)){ - Utils.LOG_INFO("Found Turbine."); - mBaseEff = (int) ((50.0F + (10.0F * ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack))) * 100); - mOptimalAirFlow = (int) Math.max(Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed * 50); - - //Make sure we have a valid Turbine and Eff/Airflow - if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0){ - //Utils.LOG_INFO("Pollution Cleaner [5]"); - - //Log Debug information. - Utils.LOG_INFO("mBaseEff[1]:"+mBaseEff); - Utils.LOG_INFO("mOptimalAirFlow[1]:"+mOptimalAirFlow); - - //Calculate The Voltage we are running - long tVoltage = maxEUInput(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - //Check Sides for Air, - //More air means more pollution processing. - int mAirSides = getFreeSpaces(); - - //If no sides are free, how will you process the atmosphere? - if (mAirSides > 0){ - mPollutionReduction += (((mTier*2)*100)*mAirSides); //Was originally *100 - Utils.LOG_INFO("mPollutionReduction[1]:"+mPollutionReduction); - - //I stole this code - mPollutionReduction = (GT_Utility.safeInt((long)mPollutionReduction*this.mBaseEff)/100000)*mAirSides; - //Utils.LOG_INFO("mPollutionReduction[2]:"+mPollutionReduction); - //mPollutionReduction = GT_Utility.safeInt((long)mPollutionReduction*this.mOptimalAirFlow/10000); - //Utils.LOG_INFO("mPollutionReduction[3]:"+mPollutionReduction); - - //Set a temp to remove variable to aleviate duplicate code. - int toRemove = 0; - - Utils.LOG_INFO("mCurrentPollution[4]:"+mCurrentPollution); - if (mPollutionReduction <= mCurrentPollution){ - //Clean some Air. - toRemove = mPollutionReduction; - } - else { - //Makes sure we don't get negative pollution. - toRemove = mCurrentPollution; - } - - //We are good to clean - if (toRemove > 0){ - if (doDamageToTurbine()){ - removePollution(toRemove); - Utils.LOG_INFO("mNewPollution[4]:"+getCurrentChunkPollution()); - } - else { - Utils.LOG_INFO("Could not damage turbine rotor."); - } - } //End of pollution removal block. - } //End of valid air sides block. - } //End of valid toolstats block. - } //End of correct inventory item block. - else { - //Utils.LOG_INFO("Wrong Tool metaitem Found."); - } - } - else { - //Utils.LOG_INFO("No Turbine Rotor Found. Size:"+this.mInventory.length); - if (this.mInventory.length > 0){ - for (int i=0;i<this.mInventory.length;i++){ - if (this.mInventory[i] != null){ - //Utils.LOG_INFO("Pos:"+i+" | "+"item:"+this.mInventory[i].getDisplayName()); - } + if ((aBaseMetaTileEntity.isAllowedToWork())){ + + //If Active. + if (aBaseMetaTileEntity.isActive()){ + + //Do nothing if there is no pollution. + if(this.mHasPollution && mCurrentPollution > 0){ + + //Use a Turbine + if(slotContainsRotor(aStack)){ + Utils.LOG_INFO("Found Turbine."); + mBaseEff = (int) ((50.0F + (10.0F * ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack))) * 100); + mOptimalAirFlow = (int) Math.max(Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed * 50); + + //Make sure we have a valid Turbine and Eff/Airflow + if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0){ + //Utils.LOG_INFO("Pollution Cleaner [5]"); + + //Log Debug information. + Utils.LOG_INFO("mBaseEff[1]:"+mBaseEff); + Utils.LOG_INFO("mOptimalAirFlow[1]:"+mOptimalAirFlow); + + //Calculate The Voltage we are running + long tVoltage = maxEUInput(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + //Check Sides for Air, + //More air means more pollution processing. + int mAirSides = getFreeSpaces(); + + //If no sides are free, how will you process the atmosphere? + if (mAirSides > 0){ + mPollutionReduction += (((mTier*2)*100)*mAirSides); //Was originally *100 + Utils.LOG_INFO("mPollutionReduction[1]:"+mPollutionReduction); + + //I stole this code + mPollutionReduction = (GT_Utility.safeInt((long)mPollutionReduction*this.mBaseEff)/100000)*mAirSides; + //Utils.LOG_INFO("mPollutionReduction[2]:"+mPollutionReduction); + //mPollutionReduction = GT_Utility.safeInt((long)mPollutionReduction*this.mOptimalAirFlow/10000); + //Utils.LOG_INFO("mPollutionReduction[3]:"+mPollutionReduction); + + //Set a temp to remove variable to aleviate duplicate code. + int toRemove = 0; + + Utils.LOG_INFO("mCurrentPollution[4]:"+mCurrentPollution); + if (mPollutionReduction <= mCurrentPollution){ + //Clean some Air. + toRemove = mPollutionReduction; } + else { + //Makes sure we don't get negative pollution. + toRemove = mCurrentPollution; + } + + //We are good to clean + if (toRemove > 0){ + if (doDamageToTurbine()){ + removePollution(toRemove); + Utils.LOG_INFO("mNewPollution[4]:"+getCurrentChunkPollution()); + } + else { + Utils.LOG_INFO("Could not damage turbine rotor."); + } + } //End of pollution removal block. + } //End of valid air sides block. + } //End of valid toolstats block. + } //End of correct inventory item block. + else { + //Utils.LOG_INFO("Wrong Tool metaitem Found."); + } + } + else { + //Utils.LOG_INFO("No Turbine Rotor Found. Size:"+this.mInventory.length); + if (this.mInventory.length > 0){ + for (int i=0;i<this.mInventory.length;i++){ + if (this.mInventory[i] != null){ + //Utils.LOG_INFO("Pos:"+i+" | "+"item:"+this.mInventory[i].getDisplayName()); } - else { - Utils.LOG_INFO("Bad Inventory."); - } + } + } + else { + Utils.LOG_INFO("Bad Inventory."); + } - } //End of Has Pollution block. - } //End of power check block. - else { - //aBaseMetaTileEntity.setActive(false); - } - } + } //End of Has Pollution block. + } } //End of can work block. else { //Disable Machine. //aBaseMetaTileEntity.setActive(false); @@ -245,7 +247,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } return mCurrentChunkPollution; } - + public boolean slotContainsRotor(ItemStack rotorStack){ if(rotorStack != null){ if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 && rotorStack.getItemDamage() <= 179){ @@ -288,7 +290,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi return true; } else { - rotorDurability = 0; + rotorDurability = 0; } } |