aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java9
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IChunkLoaderTile.java10
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java2
-rw-r--r--src/Java/gtPlusPlus/preloader/DevHelper.java1
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java213
5 files changed, 225 insertions, 10 deletions
diff --git a/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java b/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java
deleted file mode 100644
index e6aaabbba0..0000000000
--- a/src/Java/gtPlusPlus/api/interfaces/IChunkLoader.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package gtPlusPlus.api.interfaces;
-
-import net.minecraft.inventory.IInventory;
-
-public interface IChunkLoader extends IInventory, net.minecraft.world.chunk.storage.IChunkLoader{
-
- long getTicksRemaining();
-
-}
diff --git a/src/Java/gtPlusPlus/api/interfaces/IChunkLoaderTile.java b/src/Java/gtPlusPlus/api/interfaces/IChunkLoaderTile.java
new file mode 100644
index 0000000000..16152668fc
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/interfaces/IChunkLoaderTile.java
@@ -0,0 +1,10 @@
+package gtPlusPlus.api.interfaces;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.world.chunk.storage.IChunkLoader;
+
+public interface IChunkLoaderTile extends IInventory, IChunkLoader{
+
+ long getTicksRemaining();
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
index 56707db32b..fdc50bf269 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
@@ -774,7 +774,7 @@ public class ItemUtils {
if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name")) {
mLocaleCache.remove(mCacheKey);
String mNew = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName();
- Logger.INFO("Re-caching "+mNew+" into locale cache.");
+ //Logger.INFO("Re-caching "+mNew+" into locale cache.");
mLocaleCache.put(mCacheKey, mNew);
}
return mLocaleCache.get(mCacheKey);
diff --git a/src/Java/gtPlusPlus/preloader/DevHelper.java b/src/Java/gtPlusPlus/preloader/DevHelper.java
index 80830e869b..5b6a92b8f5 100644
--- a/src/Java/gtPlusPlus/preloader/DevHelper.java
+++ b/src/Java/gtPlusPlus/preloader/DevHelper.java
@@ -27,6 +27,7 @@ public class DevHelper {
}
+ @SuppressWarnings("rawtypes")
public Method getForgeMethod(Class c, String s, Class... varags) {
String s1, s2;
Method a, b;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java
new file mode 100644
index 0000000000..b220dd74e8
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java
@@ -0,0 +1,213 @@
+package gtPlusPlus.xmod.gregtech.common.covers;
+
+import java.util.HashMap;
+
+import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.interfaces.tileentity.IMachineProgress;
+import gregtech.api.util.GT_CoverBehavior;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.ObjMap;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class GTPP_Cover_Overflow extends GT_CoverBehavior {
+ public final int mMaxTransferRate;
+
+ public static final ObjMap<String, HashMap<String, Object>> mOverflowCache = new ObjMap<String, HashMap<String, Object>>(10000, 0.5f);
+
+ public GTPP_Cover_Overflow(int aTransferRate) {
+ this.mMaxTransferRate = aTransferRate*1000;
+ }
+
+ public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ long aTimer) {
+
+ HashMap<String, Object> aCoverData = getCover(aSide, aCoverID, aCoverVariable, aTileEntity);
+ //Do things
+
+ if (aCoverData != null) {
+ if (aCoverData.containsKey("aCoverVariable"))
+ return (int) aCoverData.get("aCoverVariable");
+ }
+
+
+ if (aCoverVariable % 6 > 1 && aTileEntity instanceof IMachineProgress
+ && ((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) {
+ return aCoverVariable;
+ } else {
+ if (aTileEntity instanceof IFluidHandler) {
+ IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(aSide);
+ if (tTank2 != null) {
+ IFluidHandler tTank1 = (IFluidHandler) aTileEntity;
+ FluidStack tLiquid;
+ if (aCoverVariable % 2 == 0) {
+ tLiquid = tTank1.drain(ForgeDirection.getOrientation(aSide), this.mMaxTransferRate, false);
+ if (tLiquid != null) {
+ tLiquid = tLiquid.copy();
+ tLiquid.amount = tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid,
+ false);
+ if (tLiquid.amount > 0) {
+ if ((aCoverVariable % 2 == 0 || aSide != 1) && (aCoverVariable % 2 != 0 || aSide != 0)
+ && aTileEntity.getUniversalEnergyCapacity() >= (long) Math.min(1,
+ tLiquid.amount / 10)) {
+ if (aTileEntity.isUniversalEnergyStored((long) Math.min(1, tLiquid.amount / 10))) {
+ aTileEntity.decreaseStoredEnergyUnits((long) Math.min(1, tLiquid.amount / 10),
+ true);
+ tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(
+ ForgeDirection.getOrientation(aSide), tLiquid.amount, true), true);
+ }
+ } else {
+ tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(),
+ tTank1.drain(ForgeDirection.getOrientation(aSide), tLiquid.amount, true),
+ true);
+ }
+ }
+ }
+ } else {
+ tLiquid = tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), this.mMaxTransferRate,
+ false);
+ if (tLiquid != null) {
+ tLiquid = tLiquid.copy();
+ tLiquid.amount = tTank1.fill(ForgeDirection.getOrientation(aSide), tLiquid, false);
+ if (tLiquid.amount > 0) {
+ if ((aCoverVariable % 2 == 0 || aSide != 1) && (aCoverVariable % 2 != 0 || aSide != 0)
+ && aTileEntity.getUniversalEnergyCapacity() >= (long) Math.min(1,
+ tLiquid.amount / 10)) {
+ if (aTileEntity.isUniversalEnergyStored((long) Math.min(1, tLiquid.amount / 10))) {
+ aTileEntity.decreaseStoredEnergyUnits((long) Math.min(1, tLiquid.amount / 10),
+ true);
+ tTank1.fill(ForgeDirection.getOrientation(aSide),
+ tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(),
+ tLiquid.amount, true),
+ true);
+ }
+ } else {
+ tTank1.fill(ForgeDirection.getOrientation(aSide),
+ tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(),
+ tLiquid.amount, true),
+ true);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return aCoverVariable;
+ }
+ }
+
+ public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
+ EntityPlayer aPlayer, float aX, float aY, float aZ) {
+
+
+ if ((double) aX > 0.375D && (double) aX < 0.625D || aSide <= 3 || (double) aY > 0.375D && (double) aY < 0.625D
+ || (double) aZ <= 0.375D || (double) aZ >= 0.625D) {
+ HashMap<String, Object> aCoverData = getCover(aSide, aCoverID, aCoverVariable, aTileEntity);
+ float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ);
+ switch ((byte) ((byte) ((int) (tCoords[0] * 2.0F)) + 2 * (byte) ((int) (tCoords[1] * 2.0F)))) {
+ case 0 :
+ aCoverVariable -= 1000;
+ break;
+ case 1 :
+ aCoverVariable += 1000;
+ break;
+ case 2 :
+ aCoverVariable -= 32000;
+ break;
+ case 3 :
+ aCoverVariable += 32000;
+ }
+ aCoverData.remove("aCoverVariable");
+ aCoverData.put("aCoverVariable", aCoverVariable);
+ updateCoverMap(aCoverData);
+
+ }
+ GT_Utility.sendChatToPlayer(aPlayer, "Overflow Limit: " + aCoverVariable);
+
+ return aCoverVariable;
+ }
+
+ public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return aCoverVariable > 1 && aTileEntity instanceof IMachineProgress
+ && ((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4
+ ? false
+ : aCoverVariable >= 6 || aCoverVariable % 2 != 0;
+ }
+
+ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return aCoverVariable > 1 && aTileEntity instanceof IMachineProgress
+ && ((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4
+ ? false
+ : aCoverVariable >= 6 || aCoverVariable % 2 == 0;
+ }
+
+ public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return true;
+ }
+
+ public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ return 1;
+ }
+
+ public HashMap<String, Object> getCover(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity){
+ //Map this cover
+ String aTileDataKey = "|"+aTileEntity.getXCoord()+"|"+aTileEntity.getYCoord()+"|"+aTileEntity.getZCoord()+"|"+aTileEntity.getWorld().provider.dimensionId+"|"+aSide+"|";
+ HashMap<String, Object> aTileData;
+ long aCurrentTime = System.currentTimeMillis();
+ if (mOverflowCache.get(aTileDataKey) != null) {
+ aTileData = mOverflowCache.get(aTileDataKey);
+ aTileData.remove("aLastUpdatedTime");
+ aTileData.put("aLastUpdateTime", aCurrentTime);
+ //Logger.INFO("Found Existing Cover in Cache.");
+ }
+ else {
+ aTileData = new HashMap<String, Object>();
+ aTileData.put("aCoverKey", aTileDataKey);
+ aTileData.put("aSide", aSide);
+ aTileData.put("aCoverID", aCoverID);
+ aTileData.put("aCoverVariable", aCoverVariable);
+ aTileData.put("aLastUpdateTime", aCurrentTime);
+ mOverflowCache.put(aTileDataKey, aTileData);
+ Logger.INFO("Adding new Cover to Cache. Storing under key: "+aTileDataKey);
+ }
+ return aTileData;
+ }
+
+ public void updateCoverMap(HashMap<String, Object> aCoverData) {
+ String mAccessKey = (String) aCoverData.get("aCoverKey");
+ if (mOverflowCache.get(mAccessKey) != null) {
+ mOverflowCache.remove(mAccessKey);
+ }
+ mOverflowCache.put(mAccessKey, aCoverData);
+ return;
+ }
+} \ No newline at end of file