aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2019-06-07 21:30:20 +0200
committerTec <daniel112092@gmail.com>2019-06-07 21:30:20 +0200
commit06ebe41b63c58d34ae195dc2cf267457cb014364 (patch)
tree238316da938dc31e85628d5eb53b2eb2c6e4d654 /src/main/java/com
parentd8a6787fffd976450ba05b3451368cdd7f3bc38c (diff)
downloadGT5-Unofficial-06ebe41b63c58d34ae195dc2cf267457cb014364.tar.gz
GT5-Unofficial-06ebe41b63c58d34ae195dc2cf267457cb014364.tar.bz2
GT5-Unofficial-06ebe41b63c58d34ae195dc2cf267457cb014364.zip
Working Decay generator
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java41
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java2
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java17
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java52
5 files changed, 76 insertions, 38 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java
index 1f93f75213..7c04fe2c40 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java
@@ -275,17 +275,21 @@ public final class cElementalInstanceStack implements iHasElementalDefinition {
}
cElementalInstanceStackMap products=decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount);
if(newProductsAge<0){
- for(cElementalInstanceStack stack:products.values()){
- if(stack.definition.equals(definition)){
- stack.age= age;
- stack.setEnergy(energy);
+ if(products.size()==1) {
+ if(products.size()==1 && products.get(0).definition.equals(definition)) {
+ products.get(0).setEnergy(energy);
+ products.get(0).age=age;
+ }
+ }else {
+ for (cElementalInstanceStack stack : products.values()) {
+ if (stack.definition.equals(definition)) {
+ stack.age = age;
+ }
}
}
}else{
- for(cElementalInstanceStack stack:products.values()){
- if(stack.definition.equals(definition)){
- stack.setEnergy(energy);
- }
+ if(products.size()==1 && products.get(0).definition.equals(definition)) {
+ products.get(0).setEnergy(energy);
}
}
if(this.energy <= 0 && products.getMass() > getMass()){
@@ -361,18 +365,21 @@ public final class cElementalInstanceStack implements iHasElementalDefinition {
}
}
- if(newProductsAge<0){
- for(cElementalInstanceStack stack:output.values()){
- if(stack.definition.equals(definition)){
- stack.age= age;
- stack.setEnergy(energy);
+ if(newProductsAge<0) {
+ if (output.size() == 1 && output.get(0).definition.equals(definition)) {
+ output.get(0).setEnergy(energy);
+ output.get(0).age = age;
+ } else {
+ for (cElementalInstanceStack stack : output.values()) {
+ if (stack.definition.equals(definition)) {
+ stack.age = age;
+ }
}
}
}else{
- for(cElementalInstanceStack stack:output.values()){
- if(stack.definition.equals(definition)){
- stack.setEnergy(energy);
- }
+ if(output.size()==1 && output.get(0).definition.equals(definition)) {
+ output.get(0).setEnergy(energy);
+ output.get(0).age=age;
}
}
if(this.energy <= 0 && output.getMass() > getMass()){
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java
index ccf7f1a063..6078c6379a 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java
@@ -10,7 +10,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
*/
public class GT_MetaTileEntity_Hatch_InputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer {
public GT_MetaTileEntity_Hatch_InputElemental(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, "Elemental Input for Multiblocks (" + 1000 * aTier * (aTier - 7) + "U, " + aTier * 2 + " stacks)");
+ super(aID, aName, aNameRegional, aTier, "Elemental Input for Multiblocks");
Util.setTier(aTier,this);
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java
index 942dc48256..937779ba94 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java
@@ -13,7 +13,7 @@ import gregtech.api.util.GT_Utility;
*/
public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer {
public GT_MetaTileEntity_Hatch_OutputElemental(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, "Elemental Output for Multiblocks (" + 1000 * aTier * (aTier - 7) + "U, " + aTier * 2 + " stacks)");
+ super(aID, aName, aNameRegional, aTier, "Elemental Output for Multiblocks");
Util.setTier(aTier,this);
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java
index b52637d220..14bebc4caa 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java
@@ -162,13 +162,10 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase
for(cElementalInstanceStack stack:outputEM[0].values()){
- if(stack.getEnergy()==0 && stack.definition.decayMakesEnergy(1)){
- if(getBaseMetaTileEntity().decreaseStoredEnergyUnits((long)(stack.getEnergySettingCost(1)*MASS_TO_EU_INSTANT),false)){
- stack.setEnergy(1);
- }else{
- outputEM[0].remove(stack.definition);
- outputEM[1].putReplace(stack);
- }
+ if (stack.getEnergy() == 0 && stack.definition.decayMakesEnergy(1)
+ && getBaseMetaTileEntity().decreaseStoredEnergyUnits(
+ (long) (stack.getEnergySettingCost(1) * MASS_TO_EU_INSTANT), false)) {
+ stack.setEnergy(1);
}else if(!stack.definition.decayMakesEnergy(stack.getEnergy())){
outputEM[0].remove(stack.definition);
outputEM[1].putReplace(stack);
@@ -176,7 +173,6 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase
//System.out.println(stack.definition.getSymbol()+" "+stack.amount);
}
-
float preMass=outputEM[0].getMass();
outputEM[0].tickContent(1,0,1);
double energyDose=((preMass-outputEM[0].getMass())* MASS_TO_EU_PARTIAL);
@@ -233,9 +229,4 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase
"Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET,
};
}
-
- @Override
- public long maxEUStore() {
- return super.maxEUStore();
- }
}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java
index 83cf86126d..53e1803615 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java
@@ -124,10 +124,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
protected boolean ePowerPass = false, eSafeVoid = false;
//max amperes machine can take in after computing it to the lowest tier (exchange packets to min tier count)
- protected long eMaxAmpereFlow = 0;
+ protected long eMaxAmpereFlow = 0,eMaxAmpereGen=0;
//What is the max and minimal tier of eu hatches installed
- private long maxEUinputMin = 0, maxEUinputMax = 0;
+ private long maxEUinputMin = 0, maxEUinputMax = 0,maxEUoutputMin = 0, maxEUoutputMax = 0;
//read only unless you are making computation generator - read computer class
protected long eAvailableData = 0; // data being available
@@ -820,7 +820,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
-
+ aNBT.setLong("eMaxGenEUmin", maxEUoutputMin);
+ aNBT.setLong("eMaxGenEUmax", maxEUoutputMax);
+ aNBT.setLong("eGenRating", eMaxAmpereGen);
aNBT.setLong("eMaxEUmin", maxEUinputMin);
aNBT.setLong("eMaxEUmax", maxEUinputMax);
aNBT.setLong("eRating", eAmpereFlow);
@@ -907,7 +909,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
-
+ maxEUoutputMin = aNBT.getLong("eMaxGenEUmin");
+ maxEUoutputMax = aNBT.getLong("eMaxGenEUmax");
+ eMaxAmpereGen = aNBT.getLong("eGenRating");
maxEUinputMin = aNBT.getLong("eMaxEUmin");
maxEUinputMax = aNBT.getLong("eMaxEUmax");
eAmpereFlow = aNBT.getLong("eRating");
@@ -1359,9 +1363,11 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
}
}
- if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty()) {
+ if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty() || !mDynamoHatches.isEmpty() || !eDynamoMulti.isEmpty()) {
maxEUinputMin = V[15];
maxEUinputMax = V[0];
+ maxEUoutputMin = V[15];
+ maxEUoutputMax = V[0];
for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) {
if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
if (hatch.maxEUInput() < maxEUinputMin) {
@@ -1382,7 +1388,28 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
}
}
}
+ for (GT_MetaTileEntity_Hatch_Dynamo hatch : mDynamoHatches) {
+ if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
+ if (hatch.maxEUOutput() < maxEUoutputMin) {
+ maxEUoutputMin = hatch.maxEUOutput();
+ }
+ if (hatch.maxEUOutput() > maxEUoutputMax) {
+ maxEUoutputMax = hatch.maxEUOutput();
+ }
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : eDynamoMulti) {
+ if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
+ if (hatch.maxEUOutput() < maxEUoutputMin) {
+ maxEUoutputMin = hatch.maxEUOutput();
+ }
+ if (hatch.maxEUOutput() > maxEUoutputMax) {
+ maxEUoutputMax = hatch.maxEUOutput();
+ }
+ }
+ }
eMaxAmpereFlow = 0;
+ eMaxAmpereGen = 0;
//counts only full amps
for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) {
if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
@@ -1394,6 +1421,16 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes;
}
}
+ for (GT_MetaTileEntity_Hatch_Dynamo hatch : mDynamoHatches) {
+ if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
+ eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin;
+ }
+ }
+ for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : eDynamoMulti) {
+ if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
+ eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin * hatch.Amperes;
+ }
+ }
if (getEUVar() > maxEUStore()) {
setEUVar(maxEUStore());
}
@@ -1401,6 +1438,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
maxEUinputMin = 0;
maxEUinputMax = 0;
eMaxAmpereFlow = 0;
+ maxEUoutputMin = 0;
+ maxEUoutputMax = 0;
+ eMaxAmpereGen = 0;
setEUVar(0);
}
@@ -1690,7 +1730,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt
@Override
public long maxEUStore() {
- return maxEUinputMin * eMaxAmpereFlow << 3;
+ return Math.max(maxEUinputMin * (eMaxAmpereFlow << 3),maxEUoutputMin*(eMaxAmpereGen << 3));
}
@Override