aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2021-05-12 08:41:59 +0200
committerGitHub <noreply@github.com>2021-05-12 08:41:59 +0200
commit01542a4762a7fa5eb87bd76abdf50784ed0082b0 (patch)
tree8dd2f8f058187962b8fefe24ec3b6fa52ba1e775 /src/main/java/common
parentb474bd9b062291c4715073666ffa783bc5b68b31 (diff)
parentbc9e80c28fc5ed99830c0b3bf21d48be00c60fb8 (diff)
downloadGT5-Unofficial-01542a4762a7fa5eb87bd76abdf50784ed0082b0.tar.gz
GT5-Unofficial-01542a4762a7fa5eb87bd76abdf50784ed0082b0.tar.bz2
GT5-Unofficial-01542a4762a7fa5eb87bd76abdf50784ed0082b0.zip
Merge pull request #14 from MatthewCOwen/master
FInished implementing functionality for the energy detector cover
Diffstat (limited to 'src/main/java/common')
-rw-r--r--src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java108
1 files changed, 92 insertions, 16 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
index 0b95e5ffb2..7564c41330 100644
--- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
+++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
@@ -11,7 +11,7 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
+import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
@@ -55,10 +55,13 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
private BigInteger capacity = BigInteger.ZERO;
private BigInteger stored = BigInteger.ZERO;
private BigInteger passiveDischargeAmount = BigInteger.ZERO;
- private BigInteger intputLastTick = BigInteger.ZERO;
+ private BigInteger inputLastTick = BigInteger.ZERO;
private BigInteger outputLastTick = BigInteger.ZERO;
private int repairStatusCache = 0;
+ private long mMaxEUIn = 0;
+ private long mMaxEUOut = 0;
+
public GTMTE_LapotronicSuperCapacitor(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -189,6 +192,9 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
mDynamoHatchesTT.clear();
mEnergyTunnelsTT.clear();
mDynamoTunnelsTT.clear();
+
+ mMaxEUIn = 0;
+ mMaxEUOut = 0;
// Temp var for loss calculation
BigInteger tempCapacity = BigInteger.ZERO;
@@ -386,17 +392,28 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
return false;
} else {
final IMetaTileEntity mte = te.getMetaTileEntity();
+
+ if (mte instanceof MetaTileEntity) {
+ mMaxEUIn += ((MetaTileEntity) mte).maxEUInput() * ((MetaTileEntity) mte).maxAmperesIn();
+ }
+
if (mte instanceof GT_MetaTileEntity_Hatch_Energy) {
// Add GT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return super.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) mte);
+ final GT_MetaTileEntity_Hatch_Energy tHatch = ((GT_MetaTileEntity_Hatch_Energy) mte);
+ tHatch.updateTexture(aBaseCasingIndex);
+
+ return super.mEnergyHatches.add(tHatch);
} else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyTunnel) {
// Add TT Laser hatches
+ final GT_MetaTileEntity_Hatch_EnergyTunnel tHatch = ((GT_MetaTileEntity_Hatch_EnergyTunnel) mte);
+
return mEnergyTunnelsTT.add((GT_MetaTileEntity_Hatch_EnergyTunnel) mte);
} else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyMulti) {
// Add TT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return mEnergyHatchesTT.add((GT_MetaTileEntity_Hatch_EnergyMulti) mte);
+ final GT_MetaTileEntity_Hatch_EnergyMulti tHatch = (GT_MetaTileEntity_Hatch_EnergyMulti) mte;
+ tHatch.updateTexture(aBaseCasingIndex);
+
+ return mEnergyHatchesTT.add(tHatch);
} else {
return false;
}
@@ -409,17 +426,28 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
return false;
} else {
final IMetaTileEntity mte = te.getMetaTileEntity();
+
+ if (mte instanceof MetaTileEntity) {
+ mMaxEUOut += ((MetaTileEntity) mte).maxEUOutput() * ((MetaTileEntity) mte).maxAmperesOut();
+ }
+
if (mte instanceof GT_MetaTileEntity_Hatch_Dynamo) {
// Add GT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return super.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) mte);
+ final GT_MetaTileEntity_Hatch_Dynamo tDynamo = (GT_MetaTileEntity_Hatch_Dynamo) mte;
+ tDynamo.updateTexture(aBaseCasingIndex);
+
+ return super.mDynamoHatches.add(tDynamo);
} else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoTunnel) {
// Add TT Laser hatches
- return mDynamoTunnelsTT.add((GT_MetaTileEntity_Hatch_DynamoTunnel) mte);
+ final GT_MetaTileEntity_Hatch_DynamoTunnel tDynamo = (GT_MetaTileEntity_Hatch_DynamoTunnel) mte;
+
+ return mDynamoTunnelsTT.add(tDynamo);
} else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoMulti) {
// Add TT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return mDynamoHatchesTT.add((GT_MetaTileEntity_Hatch_DynamoMulti) mte);
+ final GT_MetaTileEntity_Hatch_DynamoMulti tDynamo = (GT_MetaTileEntity_Hatch_DynamoMulti) mte;
+ tDynamo.updateTexture(aBaseCasingIndex);
+
+ return mDynamoHatchesTT.add(tDynamo);
} else {
return false;
}
@@ -429,9 +457,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public boolean onRunningTick(ItemStack stack){
// Reset I/O cache
- intputLastTick = BigInteger.ZERO;
+ inputLastTick = BigInteger.ZERO;
outputLastTick = BigInteger.ZERO;
+ //System.out.println(getBaseMetaTileEntity().)
+
// Draw energy from GT hatches
for(GT_MetaTileEntity_Hatch_Energy eHatch : super.mEnergyHatches) {
if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) {
@@ -441,7 +471,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to GT hatches
@@ -465,7 +495,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to TT hatches
@@ -490,7 +520,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to TT Laser hatches
@@ -514,6 +544,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
stored = stored.subtract(passiveDischargeAmount);
stored = (stored.compareTo(BigInteger.ZERO) <= 0) ? BigInteger.ZERO : stored;
+ IGregTechTileEntity tBMTE = this.getBaseMetaTileEntity();
+
+ tBMTE.injectEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), inputLastTick.longValue(), 1L);
+ tBMTE.drainEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), outputLastTick.longValue(), 1L);
+
return true;
}
@@ -559,7 +594,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
ll.add("Used Capacity: " + NumberFormat.getNumberInstance().format(stored) + "EU");
ll.add("Total Capacity: " + NumberFormat.getNumberInstance().format(capacity) + "EU");
ll.add("Passive Loss: " + NumberFormat.getNumberInstance().format(passiveDischargeAmount) + "EU/t");
- ll.add("EU IN: " + NumberFormat.getNumberInstance().format(intputLastTick) + "EU/t");
+ ll.add("EU IN: " + NumberFormat.getNumberInstance().format(inputLastTick) + "EU/t");
ll.add("EU OUT: " + NumberFormat.getNumberInstance().format(outputLastTick) + "EU/t");
ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
@@ -609,15 +644,56 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public boolean explodesOnComponentBreak(ItemStack stack) { return false; }
+ //called by the getEUCapacity() function in BaseMetaTileEntity
@Override
public long maxEUStore()
{
return capacity.longValue();
}
+ //called by the getEUStored() function in BaseMetaTileEntity
@Override
public long getEUVar()
{
return stored.longValue();
}
+
+ /* all of these are needed for the injectEnergyUnits() and drainEnergyUnits()
+ in IGregTechTileEntity
+ */
+ @Override
+ public long maxEUInput()
+ {
+ return mMaxEUIn;
+ }
+
+ @Override
+ public long maxAmperesIn()
+ {
+ return 1L;
+ }
+
+ @Override
+ public long maxEUOutput()
+ {
+ return mMaxEUOut;
+ }
+
+ @Override
+ public long maxAmperesOut()
+ {
+ return 1L;
+ }
+
+ @Override
+ public boolean isEnetInput()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isEnetOutput()
+ {
+ return true;
+ }
}