diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
25 files changed, 4771 insertions, 211 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 41bb0b0c26..068f47e0c4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -335,6 +335,19 @@ public enum GregtechItemList implements GregtechItemContainer { Hatch_Muffler_Adv_EV, Hatch_Muffler_Adv_IV, Hatch_Muffler_Adv_LuV, Hatch_Muffler_Adv_ZPM, Hatch_Muffler_Adv_UV, Hatch_Muffler_Adv_MAX, + //Super Input Busses + Hatch_SuperBus_Input_ULV, Hatch_SuperBus_Input_LV, Hatch_SuperBus_Input_MV, + Hatch_SuperBus_Input_HV, Hatch_SuperBus_Input_EV, Hatch_SuperBus_Input_IV, + Hatch_SuperBus_Input_LuV, Hatch_SuperBus_Input_ZPM, Hatch_SuperBus_Input_UV, + Hatch_SuperBus_Input_MAX, + + //Super Output Busses + Hatch_SuperBus_Output_ULV, Hatch_SuperBus_Output_LV, Hatch_SuperBus_Output_MV, + Hatch_SuperBus_Output_HV, Hatch_SuperBus_Output_EV, Hatch_SuperBus_Output_IV, + Hatch_SuperBus_Output_LuV, Hatch_SuperBus_Output_ZPM, Hatch_SuperBus_Output_UV, + Hatch_SuperBus_Output_MAX, + + //---------------------------------------------------------------------------- @@ -432,6 +445,12 @@ public enum GregtechItemList implements GregtechItemContainer { Machine_ZPM_Component_Maker, Machine_UV_Component_Maker, + //Breakers + BreakerBox_ULV, BreakerBox_LV, BreakerBox_MV, + BreakerBox_HV, BreakerBox_EV, BreakerBox_IV, + BreakerBox_LuV, BreakerBox_ZPM, BreakerBox_UV, + BreakerBox_MAX, + //Solar Generators GT_Solar_ULV, GT_Solar_LV, GT_Solar_MV, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java index 788fff4031..e3365935aa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import gregtech.api.gui.*; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -23,6 +24,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; + public int mReduction = 0; public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -37,72 +39,11 @@ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount) { - case 0: - break; - case 1: //Chemical Mixer - //Add 3 Item Slots - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); - //Add 6 Fluid Slots - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 17, 25)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 35, 25)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 17, 43)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 35, 43)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 43)); - - break; case 2: //Pollution Scrubber //Add 2 Item Slots addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 107, 25)); - break; - case 3: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); - break; - case 4: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); - break; - case 5: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); - break; - case 6: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 16)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 34)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 34)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 34)); - break; - case 7: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); - break; - case 8: - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 7)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 43)); - addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 43)); - break; + break; default: addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 17, 7)); addSlotToContainer(new Slot(mTileEntity, tStartIndex++, 35, 7)); @@ -121,68 +62,7 @@ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length) { case 0: break; - case 1: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - break; - case 2: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); - break; - case 3: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); - break; - case 4: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); - break; - case 5: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); - break; - case 6: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 16)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 34)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 34)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 34)); - break; - case 7: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); - break; - case 8: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 43)); - break; default: - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 7)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 25)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 107, 43)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 125, 43)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, tStartIndex++, 143, 43)); break; } @@ -215,6 +95,7 @@ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { mFluidTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mFluidTransfer; mItemTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer; mStuttering = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mStuttering; + mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; Iterator var2 = this.crafters.iterator(); while (var2.hasNext()) { @@ -222,6 +103,7 @@ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { var1.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0); var1.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0); var1.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0); + var1.sendProgressBarUpdate(this, 105, mReduction); } } @@ -244,6 +126,9 @@ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { case 104: mStuttering = (par2 != 0); break; + case 105: + mReduction = (par2); + break; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java index edc1ad4c8b..2c1601cee2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -6,15 +6,20 @@ import java.util.List; import net.minecraft.entity.player.InventoryPlayer; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - +import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { public final String mName; public final String mNEI; public final byte mProgressBarDirection; public final byte mProgressBarAmount; + public int mReduction; public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { @@ -50,6 +55,12 @@ public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { if (x3 >= 25 && x3 <= 42) { list.add("Item Auto-Output"); } + if (x3 >= 77 && x3 <= 95) { + //Do Dumb shit + CONTAINER_PollutionCleaner aContainerCast = (CONTAINER_PollutionCleaner) this.mContainer; + mReduction = aContainerCast.mReduction; + list.add("Reduction: "+mReduction); + } } if (!list.isEmpty()) { this.drawHoveringText(list, x3, y3, this.fontRendererObj); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index df71432663..ac2320afdb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -179,4 +179,6 @@ public interface IGregtech_RecipeAdder { public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); + + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java new file mode 100644 index 0000000000..214fcc6a3f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -0,0 +1,479 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity; + +import java.util.ArrayList; +import java.util.Arrays; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import ic2.api.Direction; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class BaseCustomTileEntity extends BaseMetaTileEntity { + + protected boolean mHasEnoughEnergy; + + protected short mID; + protected long oOutput; + + protected long mAcceptedAmperes; + protected NBTTagCompound mRecipeStuff; + + + + protected boolean[] mActiveEUInputs; + protected boolean[] mActiveEUOutputs; + + public BaseCustomTileEntity() { + super(); + } + + public void writeToNBT(NBTTagCompound aNBT) { + try { + super.writeToNBT(aNBT); + } catch (Throwable arg7) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg7.printStackTrace(GT_Log.err); + } + + try { + aNBT.setInteger("nbtVersion", GT_Mod.TOTAL_VERSION); + } catch (Throwable arg6) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg6.printStackTrace(GT_Log.err); + } + + } + + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.setInitialValuesAsNBT(aNBT, (short) 0); + } + + public void updateStatus() { + } + + public void chargeItem(ItemStack aStack) { + this.decreaseStoredEU( + (long) GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(2147483647L, this.getStoredEU()), + (int) Math.min(2147483647L, this.mMetaTileEntity.getOutputTier()), false, false), + true); + } + + public void dischargeItem(ItemStack aStack) { + this.increaseStoredEnergyUnits((long) GT_ModHandler.dischargeElectricItem(aStack, + (int) Math.min(2147483647L, this.getEUCapacity() - this.getStoredEU()), + (int) Math.min(2147483647L, this.mMetaTileEntity.getInputTier()), false, false, false), true); + } + + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + return !this.canAccessData() ? false + : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) + || this.decreaseStoredSteam(aEnergy, false) + || aIgnoreTooLessEnergy && this.decreaseStoredSteam(aEnergy, true)); + } + + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.getStoredEU() >= this.getEUCapacity() && !aIgnoreTooMuchEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy); + return true; + } + } + + public boolean inputEnergyFrom(byte aSide) { + return aSide == 6 ? true + : (!this.isServerSide() ? this.isEnergyInputSide(aSide) + : aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy); + } + + public boolean outputsEnergyTo(byte aSide) { + return aSide == 6 ? true + : (!this.isServerSide() ? this.isEnergyOutputSide(aSide) + : aSide >= 0 && aSide < 6 && this.mActiveEUOutputs[aSide] || this.mReleaseEnergy); + } + + public long getOutputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesOut() : 0L; + } + + public long getOutputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput() + ? this.mMetaTileEntity.maxEUOutput() + : 0L; + } + + public long getInputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesIn() : 0L; + } + + public long getInputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxEUInput() + : 2147483647L; + } + + public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.mMetaTileEntity.getSteamVar() >= this.getSteamCapacity() && !aIgnoreTooMuchEnergy) { + return false; + } else { + this.setStoredSteam(this.mMetaTileEntity.getSteamVar() + aEnergy); + return true; + } + } + + public long getUniversalEnergyStored() { + return Math.max(this.getStoredEU(), this.getStoredSteam()); + } + + public long getUniversalEnergyCapacity() { + return Math.max(this.getEUCapacity(), this.getSteamCapacity()); + } + + public long getStoredEU() { + return this.canAccessData() ? Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()) : 0L; + } + + public long getEUCapacity() { + return this.canAccessData() ? this.mMetaTileEntity.maxEUStore() : 0L; + } + + private boolean isEnergyInputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!this.getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getCoverIDAtSide(aSide), + this.getCoverDataAtSide(aSide), this)) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return false; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) { + return this.mMetaTileEntity.isInputFacing(aSide); + } + } + + return false; + } + + private boolean isEnergyOutputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!this.getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, this.getCoverIDAtSide(aSide), + this.getCoverDataAtSide(aSide), this)) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return this.mReleaseEnergy; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { + return this.mMetaTileEntity.isOutputFacing(aSide); + } + } + + return false; + } + + public boolean setStoredEU(long aEnergy) { + if (!this.canAccessData()) { + return false; + } else { + if (aEnergy < 0L) { + aEnergy = 0L; + } + + this.mMetaTileEntity.setEUVar(aEnergy); + return true; + } + } + + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.mMetaTileEntity.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy); + if (this.mMetaTileEntity.getEUVar() < 0L) { + this.setStoredEU(0L); + return false; + } else { + return true; + } + } + } + + public void doEnergyExplosion() { + if (this.getUniversalEnergyCapacity() > 0L + && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { + this.doExplosion( + this.oOutput * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4 + : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1))); + GT_Mod arg9999 = GT_Mod.instance; + GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.getOwnerName()), + "electricproblems"); + } + + } + + public void doExplosion(long aAmount) { + if (this.canAccessData()) { + if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { + try { + this.mReleaseEnergy = true; + Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); + } catch (Exception arg4) { + ; + } + } + + this.mReleaseEnergy = false; + this.mMetaTileEntity.onExplosion(); + int i; + if (GT_Mod.gregtechproxy.mExplosionItemDrop) { + for (i = 0; i < this.getSizeInventory(); ++i) { + ItemStack tItem = this.getStackInSlot(i); + if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { + this.dropItems(tItem); + this.setInventorySlotContents(i, (ItemStack) null); + } + } + } + + if (this.mRecipeStuff != null) { + for (i = 0; i < 9; ++i) { + if (this.getRandomNumber(100) < 50) { + this.dropItems(GT_Utility.loadItem(this.mRecipeStuff, "Ingredient." + i)); + } + } + } + + GT_Pollution.addPollution(this, 100000); + this.mMetaTileEntity.doExplosion(aAmount); + } + + } + + public ArrayList<ItemStack> getDrops() { + ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, this.mID); + NBTTagCompound aSuperNBT = super.getDrops().get(0).getTagCompound(); + NBTTagCompound tNBT = aSuperNBT; + if (this.hasValidMetaTileEntity()) { + this.mMetaTileEntity.setItemNBT(tNBT); + } + if (!tNBT.hasNoTags()) { + rStack.setTagCompound(tNBT); + } + + return new ArrayList<ItemStack>(Arrays.asList(new ItemStack[] { rStack })); + } + + public long getAverageElectricInput() { + int rEU = 0; + + for (int i = 0; i < this.mAverageEUInput.length; ++i) { + if (i != this.mAverageEUInputIndex) { + rEU += this.mAverageEUInput[i]; + } + } + + return (long) (rEU / (this.mAverageEUInput.length - 1)); + } + + public long getAverageElectricOutput() { + int rEU = 0; + + for (int i = 0; i < this.mAverageEUOutput.length; ++i) { + if (i != this.mAverageEUOutputIndex) { + rEU += this.mAverageEUOutput[i]; + } + } + + return (long) (rEU / (this.mAverageEUOutput.length - 1)); + } + + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.inputEnergyFrom(aSide) && aAmperage > 0L + && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity() + && this.mMetaTileEntity.maxAmperesIn() > this.mAcceptedAmperes) { + if (aVoltage > this.getInputVoltage()) { + this.doExplosion(aVoltage); + return 0L; + } else if (this + .increaseStoredEnergyUnits( + aVoltage * (aAmperage = Math + .min(aAmperage, + Math.min(this.mMetaTileEntity.maxAmperesIn() - this.mAcceptedAmperes, + 1L + (this.getEUCapacity() - this.getStoredEU()) / aVoltage))), + true)) { + this.mAverageEUInput[this.mAverageEUInputIndex] = (int) ((long) this.mAverageEUInput[this.mAverageEUInputIndex] + + aVoltage * aAmperage); + this.mAcceptedAmperes += aAmperage; + return aAmperage; + } else { + return 0L; + } + } else { + return 0L; + } + } + + public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.outputsEnergyTo(aSide) + && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { + if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { + this.mAverageEUOutput[this.mAverageEUOutputIndex] = (int) ((long) this.mAverageEUOutput[this.mAverageEUOutputIndex] + + aVoltage * aAmperage); + return true; + } else { + return false; + } + } else { + return false; + } + } + + public boolean acceptsRotationalEnergy(byte aSide) { + return this.canAccessData() && this.getCoverIDAtSide(aSide) == 0 + ? this.mMetaTileEntity.acceptsRotationalEnergy(aSide) + : false; + } + + public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { + return this.canAccessData() && this.getCoverIDAtSide(aSide) == 0 + ? this.mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy) + : false; + } + + public double getOutputEnergyUnitsPerTick() { + return (double) this.oOutput; + } + + public double demandedEnergyUnits() { + return !this.mReleaseEnergy && this.canAccessData() && this.mMetaTileEntity.isEnetInput() + ? (double) (this.getEUCapacity() - this.getStoredEU()) + : 0.0D; + } + + public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { + return this.injectEnergyUnits((byte) aDirection.ordinal(), (long) ((int) aAmount), 1L) > 0L ? 0.0D : aAmount; + } + + public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { + return this.inputEnergyFrom((byte) aDirection.ordinal()); + } + + public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { + return this.outputsEnergyTo((byte) aDirection.ordinal()); + } + + public double getOfferedEnergy() { + return this.canAccessData() && this.getStoredEU() - this.mMetaTileEntity.getMinimumStoredEU() >= this.oOutput + ? (double) Math.max(0L, this.oOutput) + : 0.0D; + } + + public void drawEnergy(double amount) { + this.mAverageEUOutput[this.mAverageEUOutputIndex] = (int) ((double) this.mAverageEUOutput[this.mAverageEUOutputIndex] + + amount); + this.decreaseStoredEU((long) ((int) amount), true); + } + + public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { + return this.injectEnergyUnits((byte) aForgeDirection.ordinal(), (long) aAmount, 1L) > 0L ? 0 : aAmount; + } + + public int addEnergy(i |
