diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-07-03 15:03:44 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-07-03 15:03:44 +1000 |
commit | 5ae801c9fff5d1c62fa0532c0e7e2dd3c898db6b (patch) | |
tree | 87164706af2044fda0ad682561c2f1343e4a4b00 | |
parent | 269f39076c17abc4ba89b990e26e9bac905c1f70 (diff) | |
download | GT5-Unofficial-5ae801c9fff5d1c62fa0532c0e7e2dd3c898db6b.tar.gz GT5-Unofficial-5ae801c9fff5d1c62fa0532c0e7e2dd3c898db6b.tar.bz2 GT5-Unofficial-5ae801c9fff5d1c62fa0532c0e7e2dd3c898db6b.zip |
$ Fixed most of the issues with the Atmospheric Conditioners.
+ Added a dev machine to create pollution.
4 files changed, 626 insertions, 127 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 3e63f63a20..384fe995a4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -167,7 +167,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Fancy Pollution Devices Pollution_Detector, Pollution_Cleaner_ULV, Pollution_Cleaner_LV, Pollution_Cleaner_MV, Pollution_Cleaner_HV, Pollution_Cleaner_EV, - Pollution_Cleaner_IV, Pollution_Cleaner_LuV, Pollution_Cleaner_ZPM, Pollution_Cleaner_UV, Pollution_Cleaner_MAX + Pollution_Cleaner_IV, Pollution_Cleaner_LuV, Pollution_Cleaner_ZPM, Pollution_Cleaner_UV, Pollution_Cleaner_MAX, + + //Debug machine + Pollution_Creator ; public static final GregtechItemList[] 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 a2d1c9bb1d..74945fb998 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 @@ -9,6 +9,7 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; @@ -22,6 +23,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi protected int mBaseEff = 2500; protected int mOptimalAirFlow = 0; protected boolean mHasPollution = false; + protected int SLOT_ROTOR = 4; private int mDamageFactorLow = 5; private float mDamageFactorHigh = (float) 0.6000000238418579; @@ -37,7 +39,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_MASSFAB), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) - }); + }); } public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { @@ -96,157 +98,247 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { + + //Get Current Pollution Amount. + int mCurrentPollution = getCurrentChunkPollution(); + + //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; + } + + + if (aTick % 2L == 0L){ + aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.pow(mTier/4, mTier/2), false); + } + //Only try once/sec. if (aTick % 20L == 0L){ - Utils.LOG_INFO("Pollution Cleaner [1]"); + //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()); + //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]"); - - //Drain some power. - aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.pow(2, mTier), false); + //Utils.LOG_INFO("Pollution Cleaner [3] | Power Stored:"+aBaseMetaTileEntity.getStoredEU()); - //Get Inventory Item - ItemStack aStack = this.mInventory[0]; - - //Get Current Pollution Amount. - int mCurrentPollution = getCurrentChunkPollution(); - - //Do nothing if there is no pollution or machine is not active. - if(this.mHasPollution && mCurrentPollution > 0){ - Utils.LOG_INFO("Pollution Cleaner [4]"); - - //Use a Turbine - if(aStack != null && (aStack.getItem() instanceof GT_MetaGenerated_Tool) && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ - 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)*50)*mAirSides); //Was originally *100 - Utils.LOG_INFO("mPollutionReduction[1]:"+mPollutionReduction); - - //I stole this code - mPollutionReduction = GT_Utility.safeInt((long)mPollutionReduction*this.mBaseEff)/10000; - 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; + //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()); + } } - else { - //Makes sure we don't get negative pollution. - toRemove = mCurrentPollution; - } - - //We are good to clean - if (toRemove > 0){ - removePollution(toRemove); - aBaseMetaTileEntity.setActive(true); - Utils.LOG_INFO("mNewPollution[4]:"+getCurrentChunkPollution()); - } //End of pollution removal block. - } //End of valid air sides block. - } //End of valid toolstats block. - } //End of correct inventory item block. - } //End of Has Pollution block. - } //End of power check block. + } + else { + Utils.LOG_INFO("Bad Inventory."); + } + + } //End of Has Pollution block. + } //End of power check block. + else { + //aBaseMetaTileEntity.setActive(false); + } + } } //End of can work block. else { //Disable Machine. - aBaseMetaTileEntity.setActive(false); + //aBaseMetaTileEntity.setActive(false); } } //End of 1/sec action block. } //End of is serverside block. } -public int getCurrentChunkPollution(){ - return getCurrentChunkPollution(this.getBaseMetaTileEntity()); -} + public int getCurrentChunkPollution(){ + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } -public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ - int mCurrentChunkPollution = GT_Pollution.getPollution(aBaseMetaTileEntity); - if (mCurrentChunkPollution > 0){ - mHasPollution = true; + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ + int mCurrentChunkPollution = GT_Pollution.getPollution(aBaseMetaTileEntity); + if (mCurrentChunkPollution > 0){ + mHasPollution = true; + } + else { + mHasPollution = false; + } + return mCurrentChunkPollution; } - else { - mHasPollution = false; + + public boolean slotContainsRotor(ItemStack rotorStack){ + if(rotorStack != null){ + if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 && rotorStack.getItemDamage() <= 179){ + return true; + } + } + return false; } - return mCurrentChunkPollution; -} -public boolean doDamageToTurbine(){ - try{ - if(mInventory[0].getItem() instanceof GT_MetaGenerated_Tool_01 && - ((GT_MetaGenerated_Tool) mInventory[0].getItem()).getToolStats(mInventory[0]).getSpeedMultiplier()>0 && - GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[0]).mToolSpeed>0 ) { - return ((GT_MetaGenerated_Tool) mInventory[0].getItem()).doDamage(mInventory[0], 10L*(long) Math.min(-mEUt / mDamageFactorLow, Math.pow(-mEUt, this.mDamageFactorHigh))); + public boolean doDamageToTurbine(){ + try{ + if(mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 && + ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]).getSpeedMultiplier()>0 && + GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed>0 ) { + long damageValue = (10L*(long) Math.min(-mTier / mDamageFactorLow, Math.pow(-mTier, this.mDamageFactorHigh))); + + if (damageValue <= 1){ + if (this.mOptimalAirFlow > 0){ + damageValue = (this.mOptimalAirFlow/10); + } + else { + return false; + } + } + + Utils.LOG_INFO("Trying to do "+damageValue+" damage to the rotor."); + + //Damage Rotor + //int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); + long rotorDamage = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurabilityMax = GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurability = (rotorDurabilityMax - rotorDamage); + Utils.LOG_INFO("Rotor Damage: "+rotorDamage + " | Max Durability: "+rotorDurabilityMax+" | "+" Remaining Durability: "+rotorDurability); + if (rotorDurability > damageValue){ + Utils.LOG_INFO("Damaging Rotor."); + GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); + + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax){ + return true; + } + else { + rotorDurability = 0; + } + } + + if (rotorDurability <= 0) { + Utils.LOG_INFO("Destroying Rotor."); + this.mInventory[this.SLOT_ROTOR] = null; + return false; + } + + + }else { + Utils.LOG_INFO("Bad Rotor."); + return false; + } } + catch (Throwable t){} + return false; } - catch (Throwable t){} - return false; -} -public int getFreeSpaces(){ - int mAir = 0; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int x = aBaseMetaTileEntity.getXCoord(); - int y = aBaseMetaTileEntity.getYCoord(); - int z = aBaseMetaTileEntity.getZCoord(); - if(aBaseMetaTileEntity.getAirOffset(x+1, y, z)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(x-1, y, z)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(x, y, z+1)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(x, y, z-1)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(x, y+1, z)){ - mAir++; - } - if(aBaseMetaTileEntity.getAirOffset(x, y-1, z)){ - mAir++; + public int getFreeSpaces(){ + int mAir = 0; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int x = aBaseMetaTileEntity.getXCoord(); + int y = aBaseMetaTileEntity.getYCoord(); + int z = aBaseMetaTileEntity.getZCoord(); + if(aBaseMetaTileEntity.getAirOffset(x+1, y, z)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(x-1, y, z)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(x, y, z+1)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(x, y, z-1)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(x, y+1, z)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(x, y-1, z)){ + mAir++; + } + return mAir; } - return mAir; -} -public boolean removePollution(int toRemove){ - int before = getCurrentChunkPollution(); - GT_Pollution.addPollution(this.getBaseMetaTileEntity(), -toRemove); - int after = getCurrentChunkPollution(); - return (after<before); -} + public boolean removePollution(int toRemove){ + int before = getCurrentChunkPollution(); + GT_Pollution.addPollution(this.getBaseMetaTileEntity(), -toRemove); + int after = getCurrentChunkPollution(); + return (after<before); + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java new file mode 100644 index 0000000000..549112f950 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java @@ -0,0 +1,402 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import gregtech.GT_Mod; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaPollutionCreator extends GregtechMetaTileEntity { + + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + + public GregtechMetaPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaPollutionCreator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (pollutionMultiplier >= 9){ + pollutionMultiplier = 1; + } + else { + pollutionMultiplier++; + } + PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now "+pollutionMultiplier+"."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPollutionCreator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 0;} + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + public int pollutionMultiplier = 1; + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + if(!GT_Mod.gregtechproxy.mPollution){ + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } + else { + addPollution(); + PlayerUtils.messagePlayer(playerIn, "This chunk now contains "+getCurrentChunkPollution()+" pollution."); + //PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution."); + } + } + + private boolean addPollution(){ + GT_Pollution.addPollution(getBaseMetaTileEntity(), 100000*pollutionMultiplier); + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution(){ + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ + return GT_Pollution.getPollution(aBaseMetaTileEntity); + } + + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Current Pollution: "+this.mCurrentPollution, + "Average/10 minutes:"+getAveragePollutionOverLastTen()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return null; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + //int mCurrentPollution; + //int mAveragePollution; + //int mAveragePollutionArray[] = new int[10]; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mCurrentPollution == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + if (this.mArrayPos < 0 || this.mArrayPos > 9) { + this.mArrayPos = 0; + } + this.mTickTimer = 0; + } + } + + + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + //TickTimer - 20 times a second + if (this.mTickTimer >= 0 || this.mTickTimer <= 19){ + this.mTickTimer++; + } + else { + this.mTickTimer = 0; + //Perform pollution update once a second + this.mCurrentPollution = getCurrentChunkPollution(); + this.mSecondTimer++; + } + //Update Pollution array once a minute + if (this.mSecondTimer >= 60){ + Utils.sendServerMessage("Udating Average of pollution array. Using Array slot"+this.mArrayPos); + this.mSecondTimer = 0; + if (this.mArrayPos<this.mAveragePollutionArray.length){ + this.mAveragePollutionArray[this.mArrayPos] = this.mCurrentPollution; + this.mArrayPos++; + } + else if (this.mArrayPos==this.mAveragePollutionArray.length){ + this.mAveragePollutionArray[this.mArrayPos] = this.mCurrentPollution; + this.mArrayPos = 0; + } + } + } + } + + public int getAveragePollutionOverLastTen(){ + int counter = 0; + int total = 0; + + for (int i=0;i<this.mAveragePollutionArray.length;i++){ + if (this.mAveragePollutionArray[i] != 0){ + total += this.mAveragePollutionArray[i]; + counter++; + } + } + int returnValue = 0; + if (total > 0 && counter > 0){ + returnValue = (total/counter); + this.mAveragePollution = returnValue; + } + else { + returnValue = getCurrentChunkPollution(); + } + Utils.LOG_INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" |"); + return returnValue; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java index 0fefa02091..957786e8d5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionCreator; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionDetector; public class GregtechPollutionDevices { @@ -20,6 +21,7 @@ public class GregtechPollutionDevices { private static void run1(){ //759 GregtechItemList.Pollution_Detector.set(new GregtechMetaPollutionDetector(756, "pollutiondetector.01.tier.single", "Pollution Detection Device", 0, "Tells you if you're living in Gwalior yet.", 0).getStackForm(1L)); + GregtechItemList.Pollution_Creator.set(new GregtechMetaPollutionCreator(951, "pollutioncreator.01.tier.single", "Smog Device", 4, "Polluting the skies.", 0).getStackForm(1L)); GregtechItemList.Pollution_Cleaner_ULV.set(new GregtechMetaAtmosphericReconditioner(757, "pollutioncleaner.01.tier.single", "Pollution Scrubber", 0).getStackForm(1L)); GregtechItemList.Pollution_Cleaner_LV.set(new GregtechMetaAtmosphericReconditioner(758, "pollutioncleaner.02.tier.single", "Upgraded Pollution Scrubber", 1).getStackForm(1L)); |