aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-11-15 05:28:56 +1000
committerAlkalus <draknyte1@hotmail.com>2017-11-15 05:28:56 +1000
commit04118a76458b4e6c886454081dd3695b62660f80 (patch)
treee1811dac86275d3b20f1744c3af7f6285fb4f4a2 /src/Java/gtPlusPlus/xmod/gregtech/api
parentf5f5d246723fce0aaa01bf72d47bb2120d9eb5d1 (diff)
downloadGT5-Unofficial-04118a76458b4e6c886454081dd3695b62660f80.tar.gz
GT5-Unofficial-04118a76458b4e6c886454081dd3695b62660f80.tar.bz2
GT5-Unofficial-04118a76458b4e6c886454081dd3695b62660f80.zip
$ Fixed Charge Hatches not having the correct amount of inputs.
$ Fixed Charge Hatches correctly handling electric items.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java99
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java85
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java9
3 files changed, 172 insertions, 21 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java
index d0201c64d1..24a92fd628 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java
@@ -1,5 +1,8 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+import static gregtech.api.enums.GT_Values.V;
+
+import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -7,7 +10,9 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.CONTAINER_Electric_2by2;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.CONTAINER_Electric_4by4;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.GUI_Electric_2by2;
@@ -18,8 +23,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Hatch_InputBattery
- extends
- GT_MetaTileEntity_Hatch {
+extends
+GT_MetaTileEntity_Hatch {
public GT_Recipe_Map mRecipeMap = null;
public GT_MetaTileEntity_Hatch_InputBattery(int aID, String aName,
@@ -34,17 +39,48 @@ public class GT_MetaTileEntity_Hatch_InputBattery
String aDescription, ITexture[][][] aTextures) {
super(aName, aTier,
aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 4 : 16,
- aDescription, aTextures);
+ aDescription, aTextures);
}
public GT_MetaTileEntity_Hatch_InputBattery(String aName, int aTier,
String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier,
aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 4 : 16,
- aDescription, aTextures);
+ aDescription, aTextures);
}
@Override
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ @Override
+ public boolean isInputFacing(byte aSide) {
+ return aSide == getBaseMetaTileEntity().getFrontFacing();
+ }
+
+
+ @Override
+ public long getMinimumStoredEU() {
+ return 0;
+ }
+
+ @Override
+ public long maxEUInput() {
+ return V[mTier];
+ }
+
+ @Override
+ public long maxEUStore() {
+ return 512 + V[mTier + 1] * 16;
+ }
+
+ @Override
+ public long maxAmperesIn() {
+ return 4;
+ }
+
+ @Override
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
return new ITexture[]{aBaseTexture,
new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)};
@@ -110,7 +146,7 @@ public class GT_MetaTileEntity_Hatch_InputBattery
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory,
IGregTechTileEntity aBaseMetaTileEntity) {
- switch (mInventory.length) {
+ switch (mTier) {
case 2 :
return new GUI_Electric_2by2(aPlayerInventory,
aBaseMetaTileEntity, "Charging Bus");
@@ -124,12 +160,34 @@ public class GT_MetaTileEntity_Hatch_InputBattery
}
@Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity,
- long aTimer) {
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (aBaseMetaTileEntity.isServerSide()
&& aBaseMetaTileEntity.hasInventoryBeenModified()) {
fillStacksIntoFirstSlots();
}
+ if (aBaseMetaTileEntity.isServerSide()){
+ if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) {
+ MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity();
+ if (mMetaTileEntity.rechargerSlotCount() > 0 && aBaseMetaTileEntity.getStoredEU() > 0) {
+ for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) {
+ if (aBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
+ for (int u=0;u<10;u++){
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(GT_ModHandler.chargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[this.mTier] * 15, aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, GT_Values.V[u]), false, false), true);
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0){
+ mMetaTileEntity.mInventory[i] = null;
+ }
+ }
+ }
+ }
+ }
+ else {
+ //Utils.LOG_INFO("reCharger Slot Count = "+mMetaTileEntity.rechargerSlotCount());
+ //Utils.LOG_INFO("getStoredEU = "+aBaseMetaTileEntity.getStoredEU());
+ //Utils.LOG_INFO("getEUVar = "+mMetaTileEntity.getEUVar());
+ }
+ }
+ }
+ super.onPostTick(aBaseMetaTileEntity, aTimer);
}
public void updateSlots() {
@@ -143,8 +201,8 @@ public class GT_MetaTileEntity_Hatch_InputBattery
for (int i = 0; i < mInventory.length; i++)
for (int j = i + 1; j < mInventory.length; j++)
if (mInventory[j] != null
- && (mInventory[i] == null || GT_Utility.areStacksEqual(
- mInventory[i], mInventory[j]))) {
+ && (mInventory[i] == null || GT_Utility.areStacksEqual(
+ mInventory[i], mInventory[j]))) {
GT_Utility.moveStackFromSlotAToSlotB(
getBaseMetaTileEntity(), getBaseMetaTileEntity(), j,
i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
@@ -164,4 +222,27 @@ public class GT_MetaTileEntity_Hatch_InputBattery
return aSide == getBaseMetaTileEntity().getFrontFacing()
&& (mRecipeMap == null || mRecipeMap.containsInput(aStack));
}
+
+ public int rechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int rechargerSlotCount() {
+ switch (mTier) {
+ case 2 :
+ return 4;
+ case 4 :
+ return 16;
+ default :
+ return 16;
+ }
+ }
+
+ public int dechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int dechargerSlotCount() {
+ return 0;
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java
index 62fef4dac3..5dd333e2fa 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java
@@ -1,12 +1,16 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+import static gregtech.api.enums.GT_Values.V;
+
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.CONTAINER_Electric_2by2;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.CONTAINER_Electric_4by4;
import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.GUI_Electric_2by2;
@@ -17,8 +21,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Hatch_OutputBattery
- extends
- GT_MetaTileEntity_Hatch {
+extends
+GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_OutputBattery(int aID, String aName,
String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, getSlots(aTier),
@@ -31,14 +35,39 @@ public class GT_MetaTileEntity_Hatch_OutputBattery
String aDescription, ITexture[][][] aTextures) {
super(aName, aTier,
aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16,
- aDescription, aTextures);
+ aDescription, aTextures);
}
public GT_MetaTileEntity_Hatch_OutputBattery(String aName, int aTier,
String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier,
aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16,
- aDescription, aTextures);
+ aDescription, aTextures);
+ }
+
+ @Override
+ public boolean isEnetOutput() {
+ return true;
+ }
+
+ @Override
+ public boolean isOutputFacing(byte aSide) {
+ return aSide == getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ @Override
+ public long getMinimumStoredEU() {
+ return 0;
+ }
+
+ @Override
+ public long maxEUOutput() {
+ return V[mTier];
+ }
+
+ @Override
+ public long maxEUStore() {
+ return 512 + V[mTier + 1] * 8;
}
@Override
@@ -143,11 +172,55 @@ public class GT_MetaTileEntity_Hatch_OutputBattery
for (int i = 0; i < mInventory.length; i++)
for (int j = i + 1; j < mInventory.length; j++)
if (mInventory[j] != null
- && (mInventory[i] == null || GT_Utility.areStacksEqual(
- mInventory[i], mInventory[j]))) {
+ && (mInventory[i] == null || GT_Utility.areStacksEqual(
+ mInventory[i], mInventory[j]))) {
GT_Utility.moveStackFromSlotAToSlotB(
getBaseMetaTileEntity(), getBaseMetaTileEntity(), j,
i, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
}
}
+
+ public int rechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int rechargerSlotCount() {
+ return 0;
+ }
+
+ public int dechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int dechargerSlotCount() {
+ return mTier == 2 ? 4 : 16;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
+ if (aBaseMetaTileEntity.isServerSide()
+ && aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ fillStacksIntoFirstSlots();
+ }
+
+ if (aBaseMetaTileEntity.isServerSide()){
+ if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) {
+ MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity();
+ if (mMetaTileEntity.dechargerSlotCount() > 0 && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) {
+ Utils.LOG_INFO("3");
+ for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) {
+ if (mMetaTileEntity.mInventory[i] != null && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) {
+ aBaseMetaTileEntity.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[mTier] * 15, aBaseMetaTileEntity.getEUCapacity() - aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), true, false, false), true);
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0)
+ mMetaTileEntity.mInventory[i] = null;
+ }
+ }
+ }
+ }
+ }
+ super.onPostTick(aBaseMetaTileEntity, aTimer);
+ }
+
+
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index df86584a69..e9831d96e0 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -164,9 +164,9 @@ public abstract class GregtechMeta_MultiBlockBase
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity,
long aTick) {
- this.mChargeHatches.clear();
- this.mDischargeHatches.clear();
super.onPostTick(aBaseMetaTileEntity, aTick);
+ //this.mChargeHatches.clear();
+ //this.mDischargeHatches.clear();
}
@Override
@@ -203,10 +203,7 @@ public abstract class GregtechMeta_MultiBlockBase
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null)
return false;
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity)
- .updateTexture(aBaseCasingIndex);
- }
+
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery)
return this.mChargeHatches.add(
(GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity);