aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java19
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java131
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java13
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java479
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java291
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java872
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java264
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java105
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java76
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java288
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java216
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java182
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java30
14 files changed, 2844 insertions, 124 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(int aEnergy) {
+ if (!this.canAccessData()) {
+ return 0;
+ } else {
+ if (aEnergy > 0) {
+ this.increaseStoredEnergyUnits((long) aEnergy, true);
+ } else {
+ this.decreaseStoredEU((long) (-aEnergy), true);
+ }
+
+ return (int) Math.min(2147483647L, this.mMetaTileEntity.getEUVar());
+ }
+ }
+
+ public boolean isAddedToEnergyNet() {
+ return false;
+ }
+
+ public int demandsEnergy() {
+ return !this.mReleaseEnergy && this.canAccessData() && this.mMetaTileEntity.isEnetInput()
+ ? this.getCapacity() - this.getStored()
+ : 0;
+ }
+
+ public int getCapacity() {
+ return (int) Math.min(2147483647L, this.getEUCapacity());
+ }
+
+ public int getStored() {
+ return (int) Math.min(2147483647L, Math.min(this.getStoredEU(), (long) this.getCapacity()));
+ }
+
+ public void setStored(int aEU) {
+ if (this.canAccessData()) {
+ this.setStoredEU((long) aEU);
+ }
+
+ }
+
+ public int getMaxSafeInput() {
+ return (int) Math.min(2147483647L, this.getInputVoltage());
+ }
+
+ public int getMaxEnergyOutput() {
+ return this.mReleaseEnergy ? Integer.MAX_VALUE : this.getOutput();
+ }
+
+ public int getOutput() {
+ return (int) Math.min(2147483647L, this.oOutput);
+ }
+
+ public int injectEnergy(Direction aDirection, int aAmount) {
+ return this.injectEnergyUnits((byte) aDirection.toSideValue(), (long) aAmount, 1L) > 0L ? 0 : aAmount;
+ }
+
+ public boolean isTeleporterCompatible(Direction aSide) {
+ return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible();
+ }
+
+ public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) {
+ return this.inputEnergyFrom((byte) aDirection.toSideValue());
+ }
+
+ public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) {
+ return this.outputsEnergyTo((byte) aDirection.toSideValue());
+ }
+
+ public boolean isUniversalEnergyStored(long aEnergyAmount) {
+ if (this.getUniversalEnergyStored() >= aEnergyAmount) {
+ return true;
+ } else {
+ this.mHasEnoughEnergy = false;
+ return false;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java
new file mode 100644
index 0000000000..e39c65b82f
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java
@@ -0,0 +1,291 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity;
+import ic2.api.Direction;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class BaseCustomPower_MTE extends BaseCustomTileEntity {
+
+ public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ //Logger.INFO("Injecting Energy Units");
+
+ if (mMetaTileEntity == null) {
+ Logger.INFO("Bad Tile");
+
+ }
+
+ if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.inputEnergyFrom(aSide) && aAmperage > 0L
+ && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity()
+ && this.mMetaTileEntity.maxAmperesIn() > this.mAcceptedAmperes) {
+ Logger.INFO("Injecting Energy Units");
+ 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)) {
+ Logger.INFO("Injecting Energy Units");
+ this.mAverageEUInput[this.mAverageEUInputIndex] = (int) ((long) this.mAverageEUInput[this.mAverageEUInputIndex]
+ + aVoltage * aAmperage);
+ this.mAcceptedAmperes += aAmperage;
+ return aAmperage;
+ } else {
+ return 0L;
+ }
+ } else {
+ Logger.INFO("canAccessData(): "+canAccessData());
+ Logger.INFO("isElectric(): "+this.mMetaTileEntity.isElectric());
+ Logger.INFO("InputEnergyFromSide("+aSide+"): "+this.inputEnergyFrom(aSide));
+ Logger.INFO("aAmperage: "+aAmperage);
+ Logger.INFO("aVoltage: "+aVoltage);
+ Logger.INFO("this.getStoredEU() < this.getEUCapacity(): "+(this.getStoredEU() < this.getEUCapacity()));
+ Logger.INFO("this.mMetaTileEntity.maxAmperesIn() > this.mAcceptedAmperes: "+(this.mMetaTileEntity.maxAmperesIn() > this.mAcceptedAmperes));
+ return 0L;
+ }
+ }
+
+ public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
+ Logger.INFO("Draining Energy Units");
+ 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;
+ }
+ }
+
+ @Override
+ public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ // TODO Auto-generated method stub
+ return super.decreaseStoredEnergyUnits(aEnergy, aIgnoreTooLessEnergy);
+ }
+
+ @Override
+ public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) {
+ // TODO Auto-generated method stub
+ return super.increaseStoredEnergyUnits(aEnergy, aIgnoreTooMuchEnergy);
+ }
+
+ @Override
+ public boolean inputEnergyFrom(byte aSide) {
+ // TODO Auto-generated method stub
+ return super.inputEnergyFrom(aSide);
+ }
+
+ @Override
+ public boolean outputsEnergyTo(byte aSide) {
+ // TODO Auto-generated method stub
+ return super.outputsEnergyTo(aSide);
+ }
+
+ @Override
+ public long getOutputAmperage() {
+ // TODO Auto-generated method stub
+ return super.getOutputAmperage();
+ }
+
+ @Override
+ public long getOutputVoltage() {
+ // TODO Auto-generated method stub
+ return super.getOutputVoltage();
+ }
+
+ @Override
+ public long getInputAmperage() {
+ // TODO Auto-generated method stub
+ return super.getInputAmperage();
+ }
+
+ @Override
+ public long getInputVoltage() {
+ // TODO Auto-generated method stub
+ return super.getInputVoltage();
+ }
+
+ @Override
+ public long getUniversalEnergyStored() {
+ // TODO Auto-generated method stub
+ return super.getUniversalEnergyStored();
+ }
+
+ @Override
+ public long getUniversalEnergyCapacity() {
+ // TODO Auto-generated method stub
+ return super.getUniversalEnergyCapacity();
+ }
+
+ @Override
+ public long getStoredEU() {
+ // TODO Auto-generated method stub
+ return super.getStoredEU();
+ }
+
+ @Override
+ public long getEUCapacity() {
+ // TODO Auto-generated method stub
+ return super.getEUCapacity();
+ }
+
+ @Override
+ public boolean setStoredEU(long aEnergy) {
+ // TODO Auto-generated method stub
+ return super.setStoredEU(aEnergy);
+ }
+
+ @Override
+ public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ // TODO Auto-generated method stub
+ return super.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy);
+ }
+
+ @Override
+ public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) {
+ // TODO Auto-generated method stub
+ return super.decreaseStoredSteam(aEnergy, aIgnoreTooLessEnergy);
+ }
+
+ @Override
+ public void doEnergyExplosion() {
+ // TODO Auto-generated method stub
+ super.doEnergyExplosion();
+ }
+
+ @Override
+ public void doExplosion(long aAmount) {
+ // TODO Auto-generated method stub
+ super.doExplosion(aAmount);
+ }
+
+ @Override
+ public byte getLightValue() {
+ // TODO Auto-generated method stub
+ return super.getLightValue();
+ }
+
+ @Override
+ public long getAverageElectricInput() {
+ // TODO Auto-generated method stub
+ return super.getAverageElectricInput();
+ }
+
+ @Override
+ public long getAverageElectricOutput() {
+ // TODO Auto-generated method stub
+ return super.getAverageElectricOutput();
+ }
+
+ @Override
+ public double getOutputEnergyUnitsPerTick() {
+ // TODO Auto-generated method stub
+ return super.getOutputEnergyUnitsPerTick();
+ }
+
+ @Override
+ public double demandedEnergyUnits() {
+ // TODO Auto-generated method stub
+ return super.demandedEnergyUnits();
+ }
+
+ @Override
+ public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) {
+ // TODO Auto-generated method stub
+ return super.injectEnergyUnits(aDirection, aAmount);
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) {
+ // TODO Auto-generated method stub
+ return super.acceptsEnergyFrom(aEmitter, aDirection);
+ }
+
+ @Override
+ public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) {
+ // TODO Auto-generated method stub
+ return super.emitsEnergyTo(aReceiver, aDirection);
+ }
+
+ @Override
+ public double getOfferedEnergy() {
+ // TODO Auto-generated method stub
+ return super.getOfferedEnergy();
+ }
+
+ @Override
+ public void drawEnergy(double amount) {
+ // TODO Auto-generated method stub
+ super.drawEnergy(amount);
+ }
+
+ @Override
+ public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) {
+ // TODO Auto-generated method stub
+ return super.injectEnergy(aForgeDirection, aAmount);
+ }
+
+ @Override
+ public int addEnergy(int aEnergy) {
+ // TODO Auto-generated method stub
+ return super.addEnergy(aEnergy);
+ }
+
+ @Override
+ public boolean isAddedToEnergyNet() {
+ // TODO Auto-generated method stub
+ return super.isAddedToEnergyNet();
+ }
+
+ @Override
+ public int demandsEnergy() {
+ // TODO Auto-generated method stub
+ return super.demandsEnergy();
+ }
+
+ @Override
+ public int getMaxSafeInput() {
+ // TODO Auto-generated method stub
+ return super.getMaxSafeInput();
+ }
+
+ @Override
+ public int getMaxEnergyOutput() {
+ // TODO Auto-generated method stub
+ return super.getMaxEnergyOutput();
+ }
+
+ @Override
+ public int injectEnergy(Direction aDirection, int aAmount) {
+ // TODO Auto-generated method stub
+ return super.injectEnergy(aDirection, aAmount);
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) {
+ // TODO Auto-generated method stub
+ return super.acceptsEnergyFrom(aReceiver, aDirection);
+ }
+
+ @Override
+ public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) {
+ // TODO Auto-generated method stub
+ return super.emitsEnergyTo(aReceiver, aDirection);
+ }
+
+ @Override
+ public boolean isUniversalEnergyStored(long aEnergyAmount) {
+ // TODO Auto-generated method stub
+ return super.isUniversalEnergyStored(aEnergyAmount);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java
new file mode 100644
index 0000000000..b0dc635aee
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java
@@ -0,0 +1,872 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power;
+
+import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Textures;
+import gregtech.api.gui.GT_Container_BasicMachine;
+import gregtech.api.gui.GT_GUIContainer_BasicMachine;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.objects.XSTR;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidHandler;
+
+import java.util.Arrays;
+
+import static gregtech.api.enums.GT_Values.V;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This is the main construct for my Basic Machines such as the Automatic Extractor
+ * Extend this class to make a simple Machine
+ */
+public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank {
+ /**
+ * return values for checkRecipe()
+ */
+ protected static final int
+ DID_NOT_FIND_RECIPE = 0,
+ FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1,
+ FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2;
+ public static final int OTHER_SLOT_COUNT = 4;
+ public final ItemStack[] mOutputItems;
+ public final int mInputSlotCount, mAmperage;
+ public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false;
+ public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0;
+ public FluidStack mOutputFluid;
+ public String mGUIName = "", mNEIName = "";
+ public GT_MetaTileEntity_MultiBlockBase mCleanroom;
+ /**
+ * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered
+ */
+ protected GT_Recipe mLastRecipe = null;
+ private FluidStack mFluidOut;
+
+ /**
+ * @param aOverlays 0 = SideFacingActive
+ * 1 = SideFacingInactive
+ * 2 = FrontFacingActive
+ * 3 = FrontFacingInactive
+ * 4 = TopFacingActive
+ * 5 = TopFacingInactive
+ * 6 = BottomFacingActive
+ * 7 = BottomFacingInactive
+ * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays -----
+ * 8 = BottomFacingPipeActive
+ * 9 = BottomFacingPipeInactive
+ * 10 = TopFacingPipeActive
+ * 11 = TopFacingPipeInactive
+ * 12 = SideFacingPipeActive
+ * 13 = SideFacingPipeInactive
+ */
+ public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) {
+ super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays);
+ mInputSlotCount = Math.max(0, aInputSlotCount);
+ mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
+ mAmperage = aAmperage;
+ mGUIName = aGUIName;
+ mNEIName = aNEIName;
+ }
+
+ public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) {
+ super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays);
+ mInputSlotCount = Math.max(0, aInputSlotCount);
+ mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
+ mAmperage = aAmperage;
+ mGUIName = aGUIName;
+ mNEIName = aNEIName;
+ }
+
+ public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) {
+ super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures);
+ mInputSlotCount = Math.max(0, aInputSlotCount);
+ mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
+ mAmperage = aAmperage;
+ mGUIName = aGUIName;
+ mNEIName = aNEIName;
+ }
+
+ public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) {
+ super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures);
+ mInputSlotCount = Math.max(0, aInputSlotCount);
+ mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
+ mAmperage = aAmperage;
+ mGUIName = aGUIName;
+ mNEIName = aNEIName;
+ }
+
+ protected boolean isValidMainFacing(byte aSide) {
+ return aSide > 1;
+ }
+
+ public boolean setMainFacing(byte aSide){
+ if (!isValidMainFacing(aSide)) return false;
+ mMainFacing = aSide;
+ if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){
+ getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide));
+ }
+ onFacingChange();
+ onMachineBlockUpdate();
+ return true;
+ }
+
+ @Override
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ ITexture[][][] rTextures = new ITexture[14][17][];
+ aTextures = Arrays.copyOf(aTextures, 14);
+
+ for (int i = 0; i < aTextures.length; i++)
+ if (aTextures[i] != null) for (byte c = -1; c < 16; c++) {
+ if (rTextures[i][c + 1] == null)
+ rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]};
+ }
+
+ for (byte c = -1; c < 16; c++) {
+ if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c);
+ if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c);
+ if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c);
+ if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c);
+ if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c);
+ if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c);
+ if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c);
+ if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c);
+ if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c);
+ if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c);
+ if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c);
+ if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c);
+ if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c);
+ if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c);
+ }
+ return rTextures;
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1];
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isOverclockerUpgradable() {
+ return false;
+ }
+
+ @Override
+ public boolean isTransformerUpgradable() {
+ return false;
+ }
+
+ @Override
+ public boolean isElectric() {
+ return true;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return mMainFacing > 1 || aFacing > 1;
+ }
+
+ @Override
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ @Override
+ public boolean isInputFacing(byte aSide) {
+ return aSide != mMainFacing;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return false;
+ }
+
+ @Override
+ public boolean isTeleporterCompatible() {
+ return false;
+ }
+
+ @Override
+ public boolean isLiquidInput(byte aSide) {
+ return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing());
+ }
+
+ @Override
+ public boolean isLiquidOutput(byte aSide) {
+ return aSide != mMainFacing;
+ }
+
+ @Override
+ public long getMinimumStoredEU() {
+ return V[mTier] * 16;
+ }
+
+ @Override
+ public long maxEUStore() {
+ return V[mTier] * 64;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return V[mTier];
+ }
+
+ @Override
+ public long maxSteamStore() {
+ return maxEUStore();
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return (mEUt * 2) / V[mTier] + 1;
+ }
+
+ @Override
+ public int getInputSlot() {
+ return OTHER_SLOT_COUNT;
+ }
+
+ @Override
+ public int getOutputSlot() {
+ return OTHER_SLOT_COUNT + mInputSlotCount;
+ }
+
+ @Override
+ public int getStackDisplaySlot() {
+ return 2;
+ }
+
+ @Override
+ public int rechargerSlotStartIndex() {
+ return 1;
+ }
+
+ @Override
+ public int dechargerSlotStartIndex() {
+ return 1;
+ }
+
+ @Override
+ public int rechargerSlotCount() {
+ return mCharge ? 1 : 0;
+ }
+
+ @Override
+ public int dechargerSlotCount() {
+ return mDecharge ? 1 : 0;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public int getProgresstime() {
+ return mProgresstime;
+ }
+
+ @Override
+ public int maxProgresstime() {
+ return mMaxProgresstime;
+ }
+
+ @Override
+ public int increaseProgress(int aProgress) {
+ mProgresstime += aProgress;
+ return mMaxProgresstime - mProgresstime;
+ }
+
+ @Override
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid));
+ }
+
+ @Override
+ public boolean isFluidChangingAllowed() {
+ return true;
+ }
+
+ @Override
+ public boolean doesFillContainers() {
+ return false;
+ }
+
+ @Override
+ public boolean doesEmptyContainers() {
+ return false;
+ }
+
+ @Override
+ public boolean canTankBeFilled() {
+ return true;
+ }
+
+ @Override
+ public boolean canTankBeEmptied() {
+ return true;
+ }
+
+ @Override
+ public boolean displaysItemStack() {
+ return true;
+ }
+
+ @Override
+ public boolean displaysStackSize() {
+ return true;
+ }
+
+ @Override
+ public FluidStack getDisplayedFluid() {
+ return displaysOutputFluid() ? getDrainableStack() : null;
+ }
+
+ @Override
+ public FluidStack getDrainableStack() {
+ return mFluidOut;
+ }
+
+ @Override
+ public FluidStack setDrainableStack(FluidStack aFluid) {
+ mFluidOut = aFluid;
+ return mFluidOut;
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ if(!GT_Mod.gregtechproxy.mForceFreeFace) {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ for(byte i=0;i < 6; i++){
+ if(aBaseMetaTileEntity.getAirAtSide(i)){
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ }
+ GT_Utility.sendChatToPlayer(aPlayer,"No free Side!");
+ return true;
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "");
+ }
+
+ @Override
+ public void initDefaultModes(NBTTagCompound aNBT) {
+ mMainFacing = -1;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("mFluidTransfer", mFluidTransfer);
+ aNBT.setBoolean("mItemTransfer", mItemTransfer);
+ aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated);
+ aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide);
+ aNBT.setInteger("mEUt", mEUt);
+ aNBT.setInteger("mMainFacing", mMainFacing);
+ aNBT.setInteger("mProgresstime", mProgresstime);
+ aNBT.setInteger("mMaxProgresstime", mMaxProgresstime);
+ if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound()));
+ if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound()));
+
+ for (int i = 0; i < mOutputItems.length; i++)
+ if (mOutputItems[i] != null)
+ aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound()));
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ mFluidTransfer = aNBT.getBoolean("mFluidTransfer");
+ mItemTransfer = aNBT.getBoolean("mItemTransfer");
+ mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated");
+ mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide");
+ mEUt = aNBT.getInteger("mEUt");
+ mMainFacing = aNBT.getInteger("mMainFacing");
+ mProgresstime = aNBT.getInteger("mProgresstime");
+ mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
+ mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid"));
+ mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut"));
+
+ for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+
+ if (aBaseMetaTileEntity.isServerSide()) {
+ mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3;
+ mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3;
+
+ doDisplayThings();
+
+ boolean tSucceeded = false;
+
+ if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) {
+ aBaseMetaTileEntity.setActive(true);
+ if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) {
+ if (++mProgresstime >= mMaxProgresstime) {
+ for (int i = 0; i < mOutputItems.length; i++)
+ for (int j = 0; j < mOutputItems.length; j++)
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i]))
+ break;
+ if (mOutputFluid != null)
+ if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy());
+ else if (mOutputFluid.isFluidEqual(getDrainableStack()))
+ getDrainableStack().amount += mOutputFluid.amount;
+ for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ mOutputFluid = null;
+ mEUt = 0;
+ mProgresstime = 0;
+ mMaxProgresstime = 0;
+ mStuttering = false;
+ tSucceeded = true;
+ endProcess();
+ }
+ if (mProgresstime > 5) mStuttering = false;
+ XSTR aXSTR = new XSTR();
+ if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord());
+ } else {
+ if (!mStuttering) {
+ stutterProcess();
+ if (canHaveInsufficientEnergy()) mProgresstime = -100;
+ mStuttering = true;
+ }
+ }
+ } else {
+ aBaseMetaTileEntity.setActive(false);
+ }
+
+ boolean tRemovedOutputFluid = false;
+
+ if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) {
+ IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing());
+ if (tTank != null) {
+ FluidStack tDrained = drain(1000, false);
+ if (tDrained != null) {
+ int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false);
+ if (tFilledAmount > 0)
+ tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true);
+ }
+ }
+ if (getDrainableStack() == null) tRemovedOutputFluid = true;
+ }
+
+ if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) {
+ TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing());
+ for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
+ tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
+ }
+ }
+
+ if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0;
+ else mOutputBlocked++;
+
+ if (allowToCheckRecipe()) {
+ if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) {
+ if (checkRecipe() == 2) {
+ if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null;
+ for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++)
+ if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null;
+ for (int i = 0; i < mOutputItems.length; i++) {
+ mOutputItems[i] = GT_Utility.copy(mOutputItems[i]);
+ if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64)
+ mOutputItems[i].stackSize = 64;
+ mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]);
+ }
+ if (mFluid != null && mFluid.amount <= 0) mFluid = null;
+ mMaxProgresstime = Math.max(1, mMaxProgresstime);
+ if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) {
+ mEUt = mMaxProgresstime = 1;
+ }
+ startProcess();
+ } else {
+ mMaxProgresstime = 0;
+ for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ mOutputFluid = null;
+ }
+ }
+ } else {
+ if (!mStuttering) {
+ stutterProcess();
+ mStuttering = true;
+ }
+ }
+ }
+ }
+
+ protected void doDisplayThings() {
+ if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) {
+ mMainFacing = getBaseMetaTileEntity().getFrontFacing();
+ }
+ if (mMainFacing >= 2 && !mHasBeenUpdated) {
+ mHasBeenUpdated = true;
+ getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing());
+ }
+
+ if (displaysInputFluid()) {
+ int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length;
+ if (getFillableStack() == null) {
+ if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true))
+ mInventory[tDisplayStackSlot] = null;
+ } else {
+ mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize());
+ }
+ }
+ }
+
+ protected boolean hasEnoughEnergyToCheckRecipe() {
+ return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2);
+ }
+
+ protected boolean drainEnergyForProcess(long aEUt) {
+ return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false);
+ }
+
+ protected void calculateOverclockedNess(GT_Recipe aRecipe) {
+ calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration);
+ }
+
+ protected void calculateOverclockedNess(int aEUt, int aDuration) {
+ if (aEUt <= 16) {
+ mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1));
+ mMaxProgresstime = aDuration / (1 << (mTier - 1));
+ } else {
+ mEUt = aEUt;
+ mMaxProgresstime = aDuration;
+ while (mEUt <= V[mTier - 1] * mAmperage) {
+ mEUt *= 4;
+ mMaxProgresstime /= 2;
+ }
+ }
+ }
+
+ protected ItemStack getSpecialSlot() {
+ return mInventory[3];
+ }
+
+ protected ItemStack getOutputAt(int aIndex) {
+ return mInventory[getOutputSlot() + aIndex];
+ }
+
+ protected ItemStack[] getAllOutputs() {
+ ItemStack[] rOutputs = new ItemStack[mOutputItems.length];
+ for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i);
+ return rOutputs;
+ }
+
+ protected boolean canOutput(GT_Recipe aRecipe) {
+ return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs));
+ }
+
+ protected boolean canOutput(ItemStack... aOutputs) {
+ if (aOutputs == null) return true;
+ ItemStack[] tOutputSlots = getAllOutputs();
+ for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++)
+ if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) {
+ mOutputBlocked++;
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean canOutput(FluidStack aOutput) {
+ return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity()));
+ }
+
+ protected ItemStack getInputAt(int aIndex) {
+ return mInventory[getInputSlot() + aIndex];
+ }
+
+ protected ItemStack[] getAllInputs() {
+ ItemStack[] rInputs = new ItemStack[mInputSlotCount];
+ for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i);
+ return rInputs;
+ }
+
+ protected boolean isOutputEmpty() {
+ boolean rIsEmpty = true;
+ for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false;
+ return rIsEmpty;
+ }
+
+ protected boolean displaysInputFluid() {
+ return true;
+ }
+
+ protected boolean displaysOutputFluid() {
+ return true;
+ }
+
+ @Override
+ public void onValueUpdate(byte aValue) {
+ mMainFacing = aValue;
+ }
+
+ @Override
+ public byte getUpdateData() {
+ return (byte) mMainFacing;
+ }
+
+ @Override
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {
+ super.doSound(aIndex, aX, aY, aZ);
+ if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ);
+ }
+
+ public boolean doesAutoOutput() {
+ return mItemTransfer;
+ }
+
+ public boolean doesAutoOutputFluids() {
+ return mFluidTransfer;
+ }
+
+ public boolean allowToCheckRecipe() {
+ return true;
+ }
+
+ public boolean showPipeFacing() {
+ return true;
+ }
+
+ /**
+ * Called whenever the Machine successfully started a Process, useful for Sound Effects
+ */
+ public void startProcess() {
+ //
+ }
+
+ /**
+ * Called whenever the Machine successfully finished a Process, useful for Sound Effects
+ */
+ public void endProcess() {
+ //
+ }
+
+ /**
+ * Called whenever the Machine aborted a Process, useful for Sound Effects
+ */
+ public void abortProcess() {
+ //
+ }
+
+ /**
+ * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects
+ */
+ public void stutterProcess() {
+ if (useStandardStutterSound()) sendSound((byte) 8);
+ }
+
+ /**
+ * If this Machine can have the Insufficient Energy Line Problem
+ */
+ public boolean canHaveInsufficientEnergy() {
+ return true;
+ }
+
+ public boolean useStandardStutterSound() {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[]{
+ mNEIName,
+ "Progress:", (mProgresstime / 20) + " secs",
+ (mMaxProgresstime / 20) + " secs",
+ "Stored Energy:",
+ getBaseMetaTileEntity().getStoredEU() + "EU",
+ getBaseMetaTileEntity().getEUCapacity() + "EU"};
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) {
+ mAllowInputFromOutputSide = !mAllowInputFromOutputSide;
+ GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden"));
+ }
+ }
+
+ @Override
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
+ return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity()));
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing()))
+ return false;
+ for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++)
+ if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex;
+ return true;
+ }
+
+ /**
+ * @return the Recipe List which is used for this Machine, this is a useful Default Handler
+ */
+ public GT_Recipe_Map getRecipeList() {
+ return null;
+ }
+
+ /**
+ * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case
+ * <p/>
+ * I thought about Enum too, but Enum doesn't add support for people adding other return Systems.
+ * <p/>
+ * Funny how Eclipse marks the word Enum as not correctly spelled.
+ *
+ * @return see constants above
+ */
+ public int checkRecipe() {
+ return checkRecipe(false);
+ }
+
+ public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){
+ return //TODO check or get a better solution
+ DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") ||
+ DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") ||
+ DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") ||
+ DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") ||
+ DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation");
+ }
+
+
+ /**
+ *
+ * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method...
+ * @return
+ */
+ public int checkRecipe(boolean skipOC){
+ GT_Recipe_Map tMap = getRecipeList();
+ if (tMap == null) return DID_NOT_FIND_RECIPE;
+ GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs());
+ if (tRecipe == null) return DID_NOT_FIND_RECIPE;
+
+ if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 &&
+ !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId))
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe;
+ if (!canOutput(tRecipe)) {
+ mOutputBlocked++;
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ }
+ if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0))
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs()))
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ for (int i = 0; i < mOutputItems.length; i++)
+ if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i))
+ mOutputItems[i] = tRecipe.getOutput(i);
+ if (tRecipe.mSpecialValue == -200)
+ for (int i = 0; i < mOutputItems.length; i++)
+ if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency)
+ mOutputItems[i] = null;
+ mOutputFluid = tRecipe.getFluidOutput(0);
+ calculateOverclockedNess(tRecipe);
+ return FOUND_AND_SUCCESSFULLY_USED_RECIPE;
+ }
+
+ public ITexture[] getSideFacingActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getSideFacingInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getFrontFacingActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getFrontFacingInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getTopFacingActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getTopFacingInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottomFacingActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottomFacingInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]};
+ }
+
+ public ITexture[] getBottomFacingPipeActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+
+ public ITexture[] getBottomFacingPipeInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+
+ public ITexture[] getTopFacingPipeActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+
+ public ITexture[] getTopFacingPipeInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+
+ public ITexture[] getSideFacingPipeActive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+
+ public ITexture[] getSideFacingPipeInactive(byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)};
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java
new file mode 100644
index 0000000000..03c8fadad4
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java
@@ -0,0 +1,264 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.gui.GT_Container_BasicTank;
+import gregtech.api.gui.GT_GUIContainer_BasicTank;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually
+ */
+public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock {
+
+ public FluidStack mFluid;
+
+ /**
+ * @param aInvSlotCount should be 3
+ */
+ public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aInvSlotCount, aDescription, aTextures);
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return aIndex != getStackDisplaySlot();
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound()));
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid"));
+ }
+
+ public abstract boolean doesFillContainers();
+
+ public abstract boolean doesEmptyContainers();
+
+ public abstract boolean canTankBeFilled();
+
+ public abstract boolean canTankBeEmptied();
+
+ public abstract boolean displaysItemStack();
+
+ public abstract boolean displaysStackSize();
+
+ public int getInputSlot() {
+ return 0;
+ }
+
+ public int getOutputSlot() {
+ return 1;
+ }
+
+ public int getStackDisplaySlot() {
+ return 2;
+ }
+
+ public boolean isFluidInputAllowed(FluidStack aFluid) {
+ return true;
+ }
+
+ public boolean isFluidChangingAllowed() {
+ return true;
+ }
+
+ public FluidStack getFillableStack() {
+ return mFluid;
+ }
+
+ public FluidStack setFillableStack(FluidStack aFluid) {
+ mFluid = aFluid;
+ return mFluid;
+ }
+
+ public FluidStack getDrainableStack() {
+ return mFluid;
+ }
+
+ public FluidStack setDrainableStack(FluidStack aFluid) {
+ mFluid = aFluid;
+ return mFluid;
+ }
+
+ public FluidStack getDisplayedFluid() {
+ return getDrainableStack();
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0)
+ setFillableStack(null);
+
+ if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) {
+ if (getDisplayedFluid() == null) {
+ if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true))
+ mInventory[getStackDisplaySlot()] = null;
+ } else {
+ mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize());
+ }
+ }
+
+ if (doesEmptyContainers()) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true);
+ if (tFluid != null && isFluidInputAllowed(tFluid)) {
+ if (getFillableStack() == null) {
+ if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) {
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) {
+ setFillableStack(tFluid.copy());
+ this.onEmptyingContainerWhenEmpty();
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
+ }
+ }
+ } else {
+ if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) {
+ if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) {
+ getFillableStack().amount += tFluid.amount;
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
+ }
+ }
+ }
+ }
+ }
+
+ if (doesFillContainers()) {
+ ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true);
+ if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true);
+ aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
+ if (tFluid != null) getDrainableStack().amount -= tFluid.amount;
+ if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null);
+ }
+ }
+ }
+ }
+
+ @Override
+ public FluidStack getFluid() {
+ return getDrainableStack();
+ }
+
+ @Override
+ public int getFluidAmount() {
+ return getDrainableStack() != null ? getDrainableStack().amount : 0;
+ }
+
+ @Override
+ public int fill(FluidStack aFluid, boolean doFill) {
+ if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid))
+ return 0;
+
+ if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) {
+ if (aFluid.amount <= getCapacity()) {
+ if (doFill) {
+ setFillableStack(aFluid.copy());
+ getBaseMetaTileEntity().markDirty();
+ }
+ return aFluid.amount;
+ }
+ if (doFill) {
+ setFillableStack(aFluid.copy());
+ getFillableStack().amount = getCapacity();
+ getBaseMetaTileEntity().markDirty();
+ }
+ return getCapacity();
+ }
+
+ if (!getFillableStack().isFluidEqual(aFluid))
+ return 0;
+
+ int space = getCapacity() - getFillableStack().amount;
+ if (aFluid.amount <= space) {
+ if (doFill) {
+ getFillableStack().amount += aFluid.amount;
+ getBaseMetaTileEntity().markDirty();
+ }
+ return aFluid.amount;
+ }
+ if (doFill)
+ getFillableStack().amount = getCapacity();
+ return space;
+ }
+
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ if (getDrainableStack() == null || !canTankBeEmptied()) return null;
+ if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) {
+ setDrainableStack(null);
+ getBaseMetaTileEntity().markDirty();
+ return null;
+ }
+
+ int used = maxDrain;
+ if (getDrainableStack().amount < used)
+ used = getDrainableStack().amount;
+
+ if (doDrain) {
+ getDrainableStack().amount -= used;
+ getBaseMetaTileEntity().markDirty();
+ }
+
+ FluidStack drained = getDrainableStack().copy();
+ drained.amount = used;
+
+ if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) {
+ setDrainableStack(null);
+ getBaseMetaTileEntity().markDirty();
+ }
+
+ return drained;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex == getOutputSlot();
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aIndex == getInputSlot();
+ }
+
+ protected void onEmptyingContainerWhenEmpty(){
+ //Do nothing
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java
new file mode 100644
index 0000000000..e3ab7915d2
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java
@@ -0,0 +1,105 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power;
+
+import static gregtech.api.enums.GT_Values.GT;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.interfaces.ITexture;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.lib.CORE;
+
+public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPower {
+ /**
+ * Value between [0 - 9] to describe the Tier of this Machine.
+ */
+ public final byte mTier;
+
+ @Deprecated
+ public final String mDescription;
+
+ /**
+ * A simple Description.
+ */
+ public final String[] mDescriptionArray;
+
+ /**
+ * Contains all Textures used by this Block.
+ */
+ public final ITexture[][][] mTextures;
+
+ public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aInvSlotCount);
+ mTier = (byte) Math.max(0, Math.min(aTier, 9));
+ mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription};
+ mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : "";
+ // must always be the last call!
+ if (GT.isClientSide()) mTextures = getTextureSet(aTextures);
+ else mTextures = null;
+ }
+
+ public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) {
+ super(aID, aName, aNameRegional, aInvSlotCount);
+ mTier = (byte) Math.max(0, Math.min(aTier, 9));
+ mDescriptionArray = aDescription == null ? new String[0] : aDescription;
+ mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : "";
+
+ // must always be the last call!
+ if (GT.isClientSide()) mTextures = getTextureSet(aTextures);
+ else mTextures = null;
+ }
+
+ public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aInvSlotCount);
+ mTier = (byte) aTier;
+ mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription};
+ mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : "";
+ mTextures = aTextures;
+ }
+
+ public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aInvSlotCount);
+ mTier = (byte) aTier;
+ mDescriptionArray = aDescription == null ? new String[0] : aDescription;
+ mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : "";
+ mTextures = aTextures;
+ }
+
+ @Override
+ public byte getTileEntityBaseType() {
+ return (byte) (Math.min(3, mTier <= 0 ? 0 : 1 + ((mTier - 1) / 4)));
+ }
+
+ @Override
+ public long getInputTier() {
+ return mTier;
+ }
+
+ @Override
+ public long getOutputTier() {
+ return mTier;
+ }
+
+ @Override
+ public String[] getDescription() {
+
+ AutoMap<String> aTooltip = new AutoMap<String>();
+ String []s1 = null;
+ aTooltip.put("Special GT++ Machine");
+ aTooltip.put(CORE.GT_Tooltip);
+ s1 = new String[aTooltip.size()];
+ int u = 0;
+ for (String s : aTooltip) {
+ s1[u] = s;
+ }
+ return s1;
+ }
+
+ /**
+ * Used Client Side to get a Texture Set for this Block.
+ * Called after setting the Tier and the Description so that those two are accessible.
+ *
+ * @param aTextures is the optional Array you can give to the Constructor.
+ */
+ public abstract ITexture[][][] getTextureSet(ITexture[] aTextures);
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java
new file mode 100644
index 0000000000..3824206d24
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java
@@ -0,0 +1,76 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.CustomMetaTileBase;
+import net.minecraft.entity.Entity;
+import net.minecraft.init.Blocks;
+import net.minecraft.world.World;
+
+public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase {
+
+ public MetaTileEntityCustomPower(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) {
+ super(aID, aBasicName, aRegionalName, aInvSlotCount);
+ }
+
+ public MetaTileEntityCustomPower(String aStack, int aInvSlotCount) {
+ super(aStack, aInvSlotCount);
+ }
+
+ public long getMinimumStoredEU() {
+ return 0L;
+ }
+
+ public void doExplosion(long aExplosionPower) {
+ float tStrength = aExplosionPower < GT_Values.V[0]
+ ? 1.0F
+ : (aExplosionPower < GT_Values.V[1]
+ ? 2.0F
+ : (aExplosionPower < GT_Values.V[2]
+ ? 3.0F
+ : (aExplosionPower < GT_Values.V[3]
+ ? 4.0F
+ : (aExplosionPower < GT_Values.V[4]
+ ? 5.0F
+ : (aExplosionPower < GT_Values.V[4] * 2L
+ ? 6.0F
+ : (aExplosionPower < GT_Values.V[5]
+ ? 7.0F
+ : (aExplosionPower < GT_Values.V[6]
+ ? 8.0F
+ : (aExplosionPower < GT_Values.V[7]
+ ? 9.0F
+ : 10.0F))))))));
+ int tX = this.getBaseMetaTileEntity().getXCoord();
+ short tY = this.getBaseMetaTileEntity().getYCoord();
+ int tZ = this.getBaseMetaTileEntity().getZCoord();
+ World tWorld = this.getBaseMetaTileEntity().getWorld();
+ GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(209)), 1.0F, -1.0F,
+ tX, tY, tZ);
+ tWorld.setBlock(tX, tY, tZ, Blocks.air);
+ if (GregTech_API.sMachineExplosions) {
+ tWorld.createExplosion((Entity) null, (double) tX + 0.5D, (double) tY + 0.5D, (double) tZ + 0.5D, tStrength,
+ true);
+ }
+
+ }
+
+ @Override
+ public void onExplosion() {
+ // TODO Auto-generated method stub
+ super.onExplosion();
+ }
+
+ @Override
+ public boolean isElectric() {
+ return true;
+ }
+
+ @Override
+ public long getEUVar() {
+ // TODO Auto-generated method stub
+ return super.getEUVar();
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java
new file mode 100644
index 0000000000..251deba6d4
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java
@@ -0,0 +1,288 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.Textures.BlockIcons;
+import gregtech.api.gui.GT_Container_4by4;
+import gregtech.api.gui.GT_GUIContainer_4by4;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.items.GT_MetaBase_Item;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.GTPP_MTE_TieredMachineBlock;
+import ic2.api.item.ElectricItem;
+import ic2.api.item.IElectricItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock {
+
+ public boolean mCharge = false;
+ public boolean mDecharge = false;
+ public int mBatteryCount = 0;
+ public int mChargeableCount = 0;
+ private long count = 0L;
+ private long mStored = 0L;
+ private long mMax = 0L;
+
+ public GT_MetaTileEntity_BasicBreaker(int aID, String aName, String aNameRegional, int aTier,
+ String aDescription, int aSlotCount) {
+ super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription, new ITexture[0]);
+ }
+
+ public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures,
+ int aSlotCount) {
+ super(aName, aTier, aSlotCount, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String[] aDescription,
+ ITexture[][][] aTextures, int aSlotCount) {
+ super(aName, aTier, aSlotCount, aDescription, aTextures);
+ }
+
+ public String[] getDescription() {
+ String []s1 = super.getDescription();
+ s1 = new String[0];
+ return s1;
+ }
+
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ ITexture[][][] rTextures = new ITexture[2][17][];
+
+ for (byte i = -1; i < 16; ++i) {
+ rTextures[0][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1]};
+ rTextures[1][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1],
+ this.mInventory.length > 4
+ ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]
+ : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]};
+ }
+
+ return rTextures;
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
+ boolean aActive, boolean aRedstone) {
+ return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1];
+ }
+
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_BasicBreaker(this.mName, this.mTier, this.mDescriptionArray, this.mTextures,
+ this.mInventory.length);
+ }
+
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ public boolean isElectric() {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ public boolean isInputFacing(byte aSide) {
+ return aSide != this.getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ public boolean isOutputFacing(byte aSide) {
+ return aSide == this.getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ public boolean isTeleporterCompatible() {
+ return false;
+ }
+
+ public long getMinimumStoredEU() {
+ return GT_Values.V[this.mTier] * 16L * 16;
+ }
+
+ public long maxEUStore() {
+ return GT_Values.V[this.mTier] * 64L * 16;
+ }
+
+ public long maxEUInput() {
+ return GT_Values.V[this.mTier] * 16;
+ }
+
+ public long maxEUOutput() {
+ return GT_Values.V[this.mTier];
+ }
+
+ public long maxAmperesIn() {
+ return (long) (1);
+ }
+
+ public long maxAmperesOut() {
+ return (long) 16;
+ }
+
+ public int rechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int dechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int rechargerSlotCount() {
+ return 0;
+ }
+
+ public int dechargerSlotCount() {
+ return 0;
+ }
+
+ public int getProgresstime() {
+ return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored();
+ }
+
+ public int maxProgresstime() {
+ return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity();
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public void saveNBTData(NBTTagCompound aNBT) {
+ }
+
+ public void loadNBTData(NBTTagCompound aNBT) {
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ aBaseMetaTileEntity.openGUI(aPlayer);
+ return true;
+ }
+ }
+
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
+ }
+
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+ /*this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L;
+ this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L;
+ this.mBatteryCount = 0;
+ this.mChargeableCount = 0;
+ ItemStack[] arg3 = this.mInventory;
+ int arg4 = arg3.length;
+
+ for (int arg5 = 0; arg5 < arg4; ++arg5) {
+ ItemStack tStack = arg3[arg5];
+ if (GT_ModHandler.isElectricItem(tStack, this.mTier)) {
+ if (GT_ModHandler.isChargerItem(tStack)) {
+ ++this.mBatteryCount;
+ }
+
+ ++this.mChargeableCount;
+ }
+ }*/
+ }
+
+ }
+
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return true;
+ }
+
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ public long[] getStoredEnergy() {
+ boolean scaleOverflow = false;
+ boolean storedOverflow = false;
+ long tScale = this.getBaseMetaTileEntity().getEUCapacity();
+ long tStored = this.getBaseMetaTileEntity().getStoredEU();
+ long tStep = 0L;
+ if (this.mInventory != null) {
+ ItemStack[] arg8 = this.mInventory;
+ int arg9 = arg8.length;
+
+ for (int arg10 = 0; arg10 < arg9; ++arg10) {
+ ItemStack aStack = arg8[arg10];
+ if (GT_ModHandler.isElectricItem(aStack)) {
+ if (aStack.getItem() instanceof GT_MetaBase_Item) {
+ Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack);
+ if (stats != null) {
+ if (stats[0].longValue() > 4611686018427387903L) {
+ scaleOverflow = true;
+ }
+
+ tScale += stats[0].longValue();
+ tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack);
+ if (tStep > 4611686018427387903L) {
+ storedOverflow = true;
+ }
+
+ tStored += tStep;
+ }
+ } else if (aStack.getItem() instanceof IElectricItem) {
+ tStored += (long) ElectricItem.manager.getCharge(aStack);
+ tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack);
+ }
+ }
+ }
+ }
+
+ if (scaleOverflow) {
+ tScale = Long.MAX_VALUE;
+ }
+
+ if (storedOverflow) {
+ tStored = Long.MAX_VALUE;
+ }
+
+ return new long[]{tStored, tScale};
+ }
+
+ public String[] getInfoData() {
+ ++this.count;
+ if (this.mMax == 0L || this.count % 20L == 0L) {
+ long[] tmp = this.getStoredEnergy();
+ this.mStored = tmp[0];
+ this.mMax = tmp[1];
+ }
+
+ return new String[]{this.getLocalName(), "Stored Items:", GT_Utility.formatNumbers(this.mStored) + " EU /",
+ GT_Utility.formatNumbers(this.mMax) + " EU", "Average input:",
+ this.getBaseMetaTileEntity().getAverageElectricInput() + "", "Average output:",
+ this.getBaseMetaTileEntity().getAverageElectricOutput() + ""};
+ }
+
+ public boolean isGivingInformation() {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java
new file mode 100644
index 0000000000..833c1bfcc0
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java
@@ -0,0 +1,216 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+
+import gregtech.api.enums.Textures.BlockIcons;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus {
+ public GT_Recipe_Map mRecipeMap = null;
+
+ public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier);
+ }
+
+ public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ /**
+ * Returns a factor of 16 based on tier.
+ * @param aTier The tier of this bus.
+ * @return (1+ aTier) * 16
+ */
+ public static int getSlots(int aTier) {
+ return (1+ aTier) * 16;
+ }
+
+ public ITexture[] getTexturesActive(ITexture aBaseTexture) {
+ return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)};
+ }
+
+ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
+ return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)};
+ }
+
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescriptionArray, this.mTextures);
+ }
+
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ this.fillStacksIntoFirstSlots();
+ }
+
+ }
+
+ public void updateSlots() {
+ for (int i = 0; i < this.mInventory.length; ++i) {
+ if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) {
+ this.mInventory[i] = null;
+ }
+ }
+
+ this.fillStacksIntoFirstSlots();
+ }
+
+ protected void fillStacksIntoFirstSlots() {
+ for (int i = 0; i < this.mInventory.length; ++i) {
+ for (int j = i + 1; j < this.mInventory.length; ++j) {
+ if (this.mInventory[j] != null && (this.mInventory[i] == null
+ || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) {
+ GT_Utility.moveStackFromSlotAToSlotB((IInventory) this.getBaseMetaTileEntity(), (IInventory) this.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+ }
+
+ }
+
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aSide == this.getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return aSide == this.getBaseMetaTileEntity().getFrontFacing()
+ && (this.mRecipeMap == null || this.mRecipeMap.containsInput(aStack));
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public String[] getDescription() {
+ String[] aDesc = new String[] {
+ "Item Input for Multiblocks",
+ "This bus has no GUI, but can have items extracted",
+ ""+this.getSlots(this.mTier)+" Slots",
+ };
+ return aDesc;
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX,
+ float aY, float aZ) {
+ return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ);
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ //Logger.INFO("Trying to display Super Input Bus contents.");
+ displayBusContents(aPlayer);
+ return true;
+ }
+ }
+
+ public void displayBusContents(EntityPlayer aPlayer) {
+ String STRIP = "Item Array: ";
+ String aNameString = ItemUtils.getArrayStackNames(getRealInventory());
+ aNameString = aNameString.replace(STRIP, "");
+
+ String[] aNames;
+ if (aNameString.length() < 1) {
+ aNames = null;
+ }
+ else {
+ aNames = aNameString.split(",");
+ }
+
+ if (aNames == null || aNames.length <= 0) {
+ PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: "+this.getSlots(this.mTier));
+ return;
+ }
+
+ PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) contains:");
+ for (String s : aNames) {
+ if (s.startsWith(" ")) {
+ s = s.substring(1);
+ }
+ //Logger.INFO("Trying to display Super Input Bus contents. "+s);
+ PlayerUtils.messagePlayer(aPlayer, s);
+ }
+ }
+
+ @Override
+ public int getMaxItemCount() {
+ // TODO Auto-generated method stub
+ return super.getMaxItemCount();
+ }
+
+ @Override
+ public int getSizeInventory() {
+ // TODO Auto-generated method stub
+ return super.getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ // TODO Auto-generated method stub
+ return super.getStackInSlot(aIndex);
+ }
+
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
+ // TODO Auto-generated method stub
+ return super.canInsertItem(aIndex, aStack, aSide);
+ }
+
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ // TODO Auto-generated method stub
+ return super.canExtractItem(aIndex, aStack, aSide);
+ }
+
+ @Override
+ public ItemStack[] getRealInventory() {
+ // TODO Auto-generated method stub
+ return super.getRealInventory();
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java
new file mode 100644
index 0000000000..d09b71ee35
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java
@@ -0,0 +1,182 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_OutputBus {
+ public GT_Recipe_Map mRecipeMap = null;
+
+ public GT_MetaTileEntity_SuperBus_Output(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier);
+ }
+
+ public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ /**
+ * Returns a factor of 16 based on tier.
+ * @param aTier The tier of this bus.
+ * @return (1+ aTier) * 16
+ */
+ public static int getSlots(int aTier) {
+ return (1+ aTier) * 16;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescriptionArray, this.mTextures);
+ }
+
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return null;
+ }
+
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ this.fillStacksIntoFirstSlots();
+ }
+
+ }
+
+ public void updateSlots() {
+ for (int i = 0; i < this.mInventory.length; ++i) {
+ if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) {
+ this.mInventory[i] = null;
+ }
+ }
+ this.fillStacksIntoFirstSlots();
+ }
+
+ protected void fillStacksIntoFirstSlots() {
+ for (int i = 0; i < this.mInventory.length; ++i) {
+ for (int j = i + 1; j < this.mInventory.length; ++j) {
+ if (this.mInventory[j] != null && (this.mInventory[i] == null
+ || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) {
+ GT_Utility.moveStackFromSlotAToSlotB((IInventory) this.getBaseMetaTileEntity(), (IInventory) this.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public String[] getDescription() {
+ String[] aDesc = new String[] {
+ "Item Output for Multiblocks",
+ "This bus has no GUI",
+ ""+this.getSlots(this.mTier)+" Slots",
+ };
+ return aDesc;
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX,
+ float aY, float aZ) {
+ return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ);
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()) {
+ return true;
+ } else {
+ displayBusContents(aPlayer);
+ return true;
+ }
+ }
+
+ public void displayBusContents(EntityPlayer aPlayer) {
+ String STRIP = "Item Array: ";
+ String aNameString = ItemUtils.getArrayStackNames(getRealInventory());
+ aNameString = aNameString.replace(STRIP, "");
+
+ String[] aNames;
+ if (aNameString.length() < 1) {
+ aNames = null;
+ }
+ else {
+ aNames = aNameString.split(",");
+ }
+
+ if (aNames == null || aNames.length <= 0) {
+ PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: "+this.getSlots(this.mTier));
+ return;
+ }
+
+ PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) contains:");
+ for (String s : aNames) {
+ if (s.startsWith(" ")) {
+ s = s.substring(1);
+ }
+ //Logger.INFO("Trying to display Super Output Bus contents. "+s);
+ PlayerUtils.messagePlayer(aPlayer, s);
+ }
+ }
+
+ @Override
+ public int getMaxItemCount() {
+ // TODO Auto-generated method stub
+ return super.getMaxItemCount();
+ }
+
+ @Override
+ public int getSizeInventory() {
+ // TODO Auto-generated method stub
+ return super.getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int aIndex) {
+ // TODO Auto-generated method stub
+ return super.getStackInSlot(aIndex);
+ }
+
+ @Override
+ public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
+ // TODO Auto-generated method stub
+ return super.canInsertItem(aIndex, aStack, aSide);
+ }
+
+ @Override
+ public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
+ // TODO Auto-generated method stub
+ return super.canExtractItem(aIndex, aStack, aSide);
+ }
+
+ @Override
+ public ItemStack[] getRealInventory() {
+ // TODO Auto-generated method stub
+ return super.getRealInventory();
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java
new file mode 100644
index 0000000000..1920b4a282
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java
@@ -0,0 +1,30 @@
+package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.util.GT_LanguageManager;
+import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
+import net.minecraft.item.ItemStack;
+
+public abstract class CustomMetaTileBase extends MetaTileEntity {
+ private IGregTechTileEntity mBaseMetaTileEntity;
+
+ public CustomMetaTileBase(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) {
+ super(aID, aBasicName, aRegionalName, aInvSlotCount);
+ this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity());
+ this.getBaseMetaTileEntity().setMetaTileID((short) aID);
+ }
+
+ public CustomMetaTileBase(String aName, int aInvSlotCount) {
+ super(aName, aInvSlotCount);
+ }
+
+ public ItemStack getStackForm(long aAmount) {
+ return new ItemStack(Meta_GT_Proxy.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID());
+ }
+
+ public String getLocalName() {
+ return GT_LanguageManager.getTranslation("gt.blockmachines." + this.mName + ".name");
+ }
+
+} \ No newline at end of file