diff options
author | Technus <daniel112092@gmail.com> | 2017-05-29 12:42:45 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-05-29 12:42:45 +0200 |
commit | 9b8ed927880b8cd93b77f6e1049f0c9f73ad955c (patch) | |
tree | 642433bc9095354fed30a0659e2b79918ab1fd2c /src | |
parent | 99b3126e9bf909e14ff8becb9f1d63d1d8c8cf61 (diff) | |
download | GT5-Unofficial-9b8ed927880b8cd93b77f6e1049f0c9f73ad955c.tar.gz GT5-Unofficial-9b8ed927880b8cd93b77f6e1049f0c9f73ad955c.tar.bz2 GT5-Unofficial-9b8ed927880b8cd93b77f6e1049f0c9f73ad955c.zip |
Rework muffler a bit, more dumb proofing.
Diffstat (limited to 'src')
3 files changed, 30 insertions, 20 deletions
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index 414ed0b390..6c56ae7fb7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -112,10 +112,9 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 1); if (tGTTileEntity != null && (tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) { GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); - aMetaTileEntity.overflowMatter += overflowMatter; overflowMatter = 0F; deathDelay = 3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... - if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { + if (aMetaTileEntity.addOverflowMatter(overflowMatter)) { if (TecTech.ModConfig.BOOM_ENABLE) tGTTileEntity.doExplosion(V[14]); else TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java index 5f0044bab9..0dcd80d4b5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java @@ -30,9 +30,9 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; private static Textures.BlockIcons.CustomIcon MufflerEM; private static Textures.BlockIcons.CustomIcon MufflerEMidle; - public float overflowMatter = 0f; + private float overflowMatter = 0f; public final float overflowMax; - public final float overflowDisperse; + private final float overflowDisperse; public GT_MetaTileEntity_Hatch_MufflerElemental(int aID, String aName, String aNameRegional, int aTier, float max) { super(aID, aName, aNameRegional, aTier, 0, "Disposes excess elemental Matter"); @@ -172,4 +172,20 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ else TecTech.proxy.broadcast("Muffler BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); } + + //Return - Should Explode + public boolean addOverflowMatter(float matter){ + overflowMatter+=matter; + return overflowMatter > overflowMax; + } + + public float getOverflowMatter() { + return overflowMatter; + } + + //Return - Should Explode + public boolean setOverflowMatter(float overflowMatter) { + this.overflowMatter = overflowMatter; + return overflowMatter > overflowMax; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java index 34ef275fab..3549bc9cb3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java @@ -503,14 +503,15 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } else if (moveAt == Tick && eSafeVoid) { for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { - if (voider.overflowMax < voider.overflowMatter) continue; - float remaining = voider.overflowMax - voider.overflowMatter; + if (voider.overflowMax < voider.getOverflowMatter()) continue; + float remaining = voider.overflowMax - voider.getOverflowMatter(); for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { for (cElementalInstanceStack instance : in.getContainerHandler().values()) { int qty = (int) Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - voider.overflowMatter += instance.definition.getMass() * qty; + if(voider.addOverflowMatter(instance.definition.getMass() * qty)) + voider.setOverflowMatter(voider.overflowMax); in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } } @@ -520,13 +521,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt int qty = (int) Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - voider.overflowMatter += instance.definition.getMass() * qty; + if(voider.addOverflowMatter(instance.definition.getMass() * qty)) + voider.setOverflowMatter(voider.overflowMax); out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } } } - //in case some weird shit happened here, it will still be safe - if (voider.overflowMatter > voider.overflowMax) voider.overflowMatter = voider.overflowMax; } } @@ -840,8 +840,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (eMufflerHatches.size() < 1) explodeMultiblock(); mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + if (dump.addOverflowMatter(mass)) explodeMultiblock(); } } outputEM = null; @@ -881,8 +880,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + if (dump.addOverflowMatter(mass)) explodeMultiblock(); } } } @@ -894,8 +892,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (eMufflerHatches.size() < 1) explodeMultiblock(); mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + if (dump.addOverflowMatter(mass)) explodeMultiblock(); } } } @@ -907,8 +904,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (eMufflerHatches.size() < 1) explodeMultiblock(); mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + if (dump.addOverflowMatter(mass)) explodeMultiblock(); } } } @@ -926,8 +922,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + if (dump.addOverflowMatter(mass)) explodeMultiblock(); } } outputEM = null; |