aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-29 05:13:11 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-29 05:13:11 +0000
commit222fbc044f89a2d272f0bace58c28db1e6927e0f (patch)
tree19a16783690890d374ec6af5814b1d067eda3d97 /src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines
parent22c6a05a8a3a00294bcb8890a1e2a0fdc9196de8 (diff)
downloadGT5-Unofficial-222fbc044f89a2d272f0bace58c28db1e6927e0f.tar.gz
GT5-Unofficial-222fbc044f89a2d272f0bace58c28db1e6927e0f.tar.bz2
GT5-Unofficial-222fbc044f89a2d272f0bace58c28db1e6927e0f.zip
+ Added Super Busses.
+ Added Breaker Boxes. + Added Super Jukebox. (framework) + Added King Bat. (framework) + Added Custom WAILA plugin. (framework) + Added lots of simple function calls to CI. (Recipe simplification) % Rewrote the recipes for Wireless Chargers, they now require assembly. % Cleaned up some old code. $ Adjusted bug with pollution scrubbers using no durability and removing LOTS of pollution. $ Greatly improved code base for pollution scrubbers. $ Added pollution back to the Cyclotron.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java228
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java3
2 files changed, 193 insertions, 38 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 a55876ac35..9c66e1e05c 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
@@ -2,17 +2,21 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
import static gregtech.api.enums.GT_Values.V;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
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_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.item.general.ItemAirFilter;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
@@ -29,7 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_BasicMachine {
- protected int mPollutionReduction = 0;
+ public int mPollutionReduction = 0;
protected int mBaseEff = 2500;
protected int mOptimalAirFlow = 0;
protected boolean mHasPollution = false;
@@ -74,7 +78,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
this.mDescription,
"Requires a turbine rotor and an Air Filter [T1/T2] to run.",
"The turbine rotor must be manually inserted/replaced",
- "Can be configured with a screwdriver to change modes",
+ "Can be configured with a soldering iron to change modes",
"Low Efficiency: Removes half pollution, Turbine takes 50% dmg",
"High Efficiency: Removes full pollution, Turbine takes 100% dmg",
"Turbine Rotor will not break in LE mode",
@@ -97,7 +101,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
@Override
public long maxAmperesIn() {
- return 4;
+ return 2;
}
@Override
@@ -129,42 +133,56 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
//Get Current Pollution Amount.
int mCurrentPollution = getCurrentChunkPollution();
+ boolean isIdle = true;
//Get Inventory Item
ItemStack stackRotor = this.mInventory[SLOT_ROTOR];
- ItemStack stackFilter = this.mInventory[SLOT_FILTER];
-
- //Enable machine animation/graphic
- if (this.mHasPollution && mCurrentPollution > 0 && hasRotor(stackRotor) && hasAirFilter(stackFilter)){
- aBaseMetaTileEntity.setActive(true);
- }
- else if (!this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || hasRotor(stackRotor) || !hasAirFilter(stackFilter)){
- aBaseMetaTileEntity.setActive(false);
- }
+ ItemStack stackFilter = this.mInventory[SLOT_FILTER];
//Power Drain
- long drainEU = V[mTier];
+ long drainEU = maxEUInput() * maxAmperesIn();
if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){
if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){
- //Utils.LOG_WARNING("Draining "+drainEU+" EU");
+ isIdle = false;
+ }
+ else {
+ aBaseMetaTileEntity.setActive(false);
+ this.sendSound((byte) -122);
}
}
else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){
if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){
- //Utils.LOG_WARNING("Draining "+(drainEU/4)+" EU");
+ isIdle = false;
+ }
+ else {
+ aBaseMetaTileEntity.setActive(false);
+ this.sendSound((byte) -122);
}
}
else {
aBaseMetaTileEntity.setActive(false);
- }
-
-
+ this.sendSound((byte) -122);
+ }
+
//Only try once/sec.
- if (aTick % 20L == 0L){
-
+ if (!isIdle && aTick % 20L == 0L){
+
//Check if machine can work.
if ((aBaseMetaTileEntity.isAllowedToWork())){
+ //Enable machine animation/graphic
+ if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution){
+ if (!this.getBaseMetaTileEntity().isActive()) {
+ aBaseMetaTileEntity.setActive(true);
+ }
+ }
+ else if (!this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){
+ if (!this.getBaseMetaTileEntity().isActive()) {
+ aBaseMetaTileEntity.setActive(false);
+ this.sendSound((byte) -122);
+ }
+ }
+
//If Active.
if (aBaseMetaTileEntity.isActive()){
@@ -187,31 +205,35 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
Logger.WARNING("mOptimalAirFlow[1]:"+mOptimalAirFlow);
//Calculate The Voltage we are running
- long tVoltage = maxEUInput();
+ long tVoltage = drainEU;
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
//Check Sides for Air,
//More air means more pollution processing.
int mAirSides = getFreeSpaces();
+ int reduction = 0;
+
//If no sides are free, how will you process the atmosphere?
if (mAirSides > 0){
- mPollutionReduction += (((mTier*2)*100)*mAirSides); //Was originally *100
- Logger.WARNING("mPollutionReduction[1]:"+mPollutionReduction);
+ reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); //Was originally *100
+ Logger.WARNING("mPollutionReduction[1]:"+reduction);
//I stole this code
- mPollutionReduction = (MathUtils.safeInt((long)mPollutionReduction*this.mBaseEff)/100000)*mAirSides*tTier;
- //Utils.LOG_WARNING("mPollutionReduction[2]:"+mPollutionReduction);
- //mPollutionReduction = GT_Utility.safeInt((long)mPollutionReduction*this.mOptimalAirFlow/10000);
- //Utils.LOG_WARNING("mPollutionReduction[3]:"+mPollutionReduction);
+ reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1);
+ Logger.WARNING("reduction[2]:"+reduction);
+ reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow);
+ Logger.WARNING("reduction[3]:"+reduction);
+ mPollutionReduction = reduction;
+
//Set a temp to remove variable to aleviate duplicate code.
int toRemove = 0;
Logger.WARNING("mCurrentPollution[4]:"+mCurrentPollution);
- if (mPollutionReduction <= mCurrentPollution){
+ if (reduction <= mCurrentPollution){
//Clean some Air.
- toRemove = mPollutionReduction;
+ toRemove = reduction;
}
else {
//Makes sure we don't get negative pollution.
@@ -236,12 +258,31 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
//Utils.LOG_WARNING("Wrong Tool metaitem Found.");
}
}
- }
+ }
+ else if (!aBaseMetaTileEntity.isActive()) {
+ return;
+ }
} //End of can work block.
else { //Disable Machine.
//aBaseMetaTileEntity.setActive(false);
}
} //End of 1/sec action block.
+ else {
+
+ if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution && !isIdle && aBaseMetaTileEntity.isAllowedToWork()){
+ aBaseMetaTileEntity.setActive(true);
+ }
+ else if (isIdle || !this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){
+ aBaseMetaTileEntity.setActive(false);
+ }
+
+ }
+ if (this.getBaseMetaTileEntity().isActive()) {
+ if (MathUtils.randInt(0, 5) <= 2) {
+ this.sendSound((byte) -120);
+ }
+ }
+
} //End of is serverside block.
}
@@ -272,6 +313,22 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
public boolean damageTurbineRotor(){
try{
+
+ boolean creativeRotor = false;
+ ItemStack rotorStack = this.mInventory[SLOT_ROTOR];
+ if (rotorStack == null) {
+ return false;
+ }
+ else {
+ if(rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) {
+ Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack);
+ Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack);
+ if (t1 == Materials._NULL && t2 == Materials._NULL){
+ creativeRotor = true;
+ }
+ }
+ }
+
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 ) {
@@ -280,16 +337,16 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
double fDam = Math.floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f);
damageValue -= fDam;
- //Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]");
+ //Logger.WARNING("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]");
/*Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]);
Materials M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]);
- Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]");*/
+ Logger.WARNING("Trying to do "+damageValue+" damage to the rotor. [2]");*/
//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 rotorDamage = creativeRotor ? 0 : GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]);
+ long rotorDurabilityMax = creativeRotor ? Integer.MAX_VALUE : GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]);
long rotorDurability = (rotorDurabilityMax - rotorDamage);
Logger.WARNING("Rotor Damage: "+rotorDamage + " | Max Durability: "+rotorDurabilityMax+" | "+" Remaining Durability: "+rotorDurability);
if (rotorDurability >= damageValue){
@@ -297,6 +354,8 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
if (!mSaveRotor){
Logger.WARNING("Damaging Rotor.");
+
+ if (!creativeRotor)
GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null);
long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]);
@@ -310,6 +369,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
else {
Logger.WARNING("Damaging Rotor.");
if (rotorDurability > 1000){
+ if (!creativeRotor)
GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue/2, 0, null);
long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]);
if (tempDur < rotorDurabilityMax){
@@ -324,7 +384,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
}
- if (rotorDurability <= 0 && !mSaveRotor) {
+ if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) {
Logger.WARNING("Destroying Rotor.");
this.mInventory[this.SLOT_ROTOR] = null;
return false;
@@ -388,6 +448,29 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
public boolean damageAirFilter(){
ItemStack filter = this.mInventory[this.SLOT_FILTER];
+
+ boolean creativeRotor = false;
+ ItemStack rotorStack = this.mInventory[SLOT_ROTOR];
+ if (rotorStack == null) {
+ return false;
+ }
+ else {
+ if(rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) {
+ Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack);
+ Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack);
+ if (t1 == Materials._NULL && t2 == Materials._NULL){
+ creativeRotor = true;
+ }
+ }
+ }
+
+ if (creativeRotor) {
+ return true;
+ }
+ if (filter == null) {
+ return false;
+ }
+
if (filter.getItem() instanceof ItemAirFilter){
@@ -398,7 +481,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
this.mInventory[this.SLOT_FILTER] = null;
return false;
}
- else if (filter.getItemDamage() == 1 && currentUse >= 150-1){
+ else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){
this.mInventory[this.SLOT_FILTER] = null;
return false;
}
@@ -432,7 +515,13 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
}
@Override
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ }
+
+ @Override
+ public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY,
+ float aZ) {
this.mSaveRotor = Utils.invertBoolean(mSaveRotor);
if (mSaveRotor){
PlayerUtils.messagePlayer(aPlayer, "Running in low efficiency mode, rotors will not break.");
@@ -440,8 +529,71 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
else {
PlayerUtils.messagePlayer(aPlayer, "Running in high efficiency mode, rotors will break.");
}
+ return true;
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {
+ if (aIndex == -120) {
+ GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(103)), MathUtils.randInt(5, 50), 0.05F, aX, aY, aZ);
+ } else if (aIndex == -121 || aIndex == -122) {
+ //GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(108)), 0, 0.5F, aX, aY, aZ);
+ } /*else if (aIndex == -122) {
+ GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 100, 1.0F, aX, aY, aZ);
+ }*/ else {
+ super.doSound((byte) 0, aX, aY, aZ);
+ }
+ }
+
+ @Override
+ public boolean canHaveInsufficientEnergy() {
+ // TODO Auto-generated method stub
+ return super.canHaveInsufficientEnergy();
+ }
+
+ @Override
+ public String[] getInfoData() {
+ AutoMap<String> aTooltipSuper = new AutoMap<String>();
+ for (String s : super.getInfoData()) {
+ aTooltipSuper.put(s);
+ }
+ int mAirSides = getFreeSpaces();
+ int reduction = 0;
- super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ long tVoltage = maxEUInput();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides);
+ reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1);
+ reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow);
+
+ aTooltipSuper.put("Maximum pollution removed per second: "+reduction);
+ aTooltipSuper.put("Air Sides: "+mAirSides);
+ return aTooltipSuper.toArray();
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
+ if (aSide <= 1) {
+ return false;
+ }
+ return super.allowCoverOnSide(aSide, aCoverID);
+ }
+
+ @Override
+ public ITexture[] getTopFacingInactive(byte aColor) {
+ return super.getTopFacingInactive(aColor);
+ }
+
+ @Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow);
+ aNBT.setBoolean("mSaveRotor", mSaveRotor);
+ super.setItemNBT(aNBT);
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
index eb2339cbea..1623e7cb54 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
@@ -27,6 +27,7 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.item.chemistry.IonParticles;
import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Cyclotron;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
@@ -530,6 +531,8 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
}
}
}
+ PollutionUtils.addPollution(getBaseMetaTileEntity(), this.getPollutionPerTick(aStack));
+
return true;
}