aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-06-16 06:19:32 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-06-16 06:19:32 +1000
commit269f39076c17abc4ba89b990e26e9bac905c1f70 (patch)
tree674240b46c4e39831e859e4e34e3fa81882a307e /src/Java/gtPlusPlus/xmod/gregtech/common
parentfb4c7480a983da4c3c88e6a5ea58f59c3e4366b4 (diff)
downloadGT5-Unofficial-269f39076c17abc4ba89b990e26e9bac905c1f70.tar.gz
GT5-Unofficial-269f39076c17abc4ba89b990e26e9bac905c1f70.tar.bz2
GT5-Unofficial-269f39076c17abc4ba89b990e26e9bac905c1f70.zip
+ Added Atmosphere cleaners.
% Changed the IDs of the newest blocks.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java252
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java8
2 files changed, 258 insertions, 2 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
new file mode 100644
index 0000000000..a2d1c9bb1d
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java
@@ -0,0 +1,252 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
+
+import static gregtech.api.enums.GT_Values.V;
+
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+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_Utility;
+import gregtech.common.GT_Pollution;
+import gregtech.common.items.GT_MetaGenerated_Tool_01;
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_BasicMachine {
+
+ protected int mPollutionReduction = 0;
+ protected int mBaseEff = 2500;
+ protected int mOptimalAirFlow = 0;
+ protected boolean mHasPollution = false;
+
+ private int mDamageFactorLow = 5;
+ private float mDamageFactorHigh = (float) 0.6000000238418579;
+
+ public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 1, "Making sure you don't live in Gwalior", 1, 1, "Massfabricator.png", "",
+ new ITexture[]{
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_MASSFAB_ACTIVE),
+ 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) {
+ super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName);
+ }
+
+ public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) {
+ super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName);
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaAtmosphericReconditioner(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow");
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return 4;
+ }
+
+ @Override
+ public long getMinimumStoredEU() {
+ return V[mTier] * 2;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return V[mTier] * 256;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return V[mTier];
+ }
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
+ if (getBaseMetaTileEntity().isServerSide()) {
+
+ }
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide()) {
+ //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]");
+
+ //Drain some power.
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) Math.pow(2, mTier), false);
+
+ //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;
+ }
+ 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.
+ } //End of can work block.
+ else { //Disable Machine.
+ aBaseMetaTileEntity.setActive(false);
+ }
+ } //End of 1/sec action block.
+ } //End of is serverside block.
+ }
+
+
+public int getCurrentChunkPollution(){
+ return getCurrentChunkPollution(this.getBaseMetaTileEntity());
+}
+
+public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){
+ int mCurrentChunkPollution = GT_Pollution.getPollution(aBaseMetaTileEntity);
+ if (mCurrentChunkPollution > 0){
+ mHasPollution = true;
+ }
+ else {
+ mHasPollution = 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)));
+ }
+ }
+ 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++;
+ }
+ return mAir;
+}
+
+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/GregtechMetaPollutionDetector.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java
index 784648dfed..f967be41a9 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java
@@ -9,6 +9,7 @@ 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;
@@ -64,7 +65,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity {
public ITexture[] getFront(final byte aColor) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]};
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)};
}
@@ -177,7 +178,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity {
}
else {
PlayerUtils.messagePlayer(playerIn, "This chunk contains "+getCurrentChunkPollution()+" pollution.");
- PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+this.mAveragePollution+" pollution.");
+ PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution.");
}
}
@@ -342,6 +343,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity {
}
//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;
@@ -358,6 +360,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity {
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];
@@ -372,6 +375,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity {
else {
returnValue = getCurrentChunkPollution();
}
+ Utils.LOG_INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" |");
return returnValue;
}