aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/common/covers
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2022-08-29 16:04:28 +0200
committerGitHub <noreply@github.com>2022-08-29 16:04:28 +0200
commit7d1f51a8937e0a86486267437d444696e81e8aa0 (patch)
treea5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/gregtech/common/covers
parent5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff)
downloadGT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz
GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2
GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip
Buildscript + Spotless (#318)
* Convert AES.java to readable class * Buildscript * Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/covers')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java198
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java488
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java342
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java349
4 files changed, 737 insertions, 640 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
index 2fba1b0448..9e507048ed 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java
@@ -15,88 +15,132 @@ import gtPlusPlus.xmod.gregtech.common.items.covers.MetaItemCoverCasings;
public class CoverManager {
- // ZTones
- public static MetaCustomCoverItem Cover_Agon;
- public static MetaCustomCoverItem Cover_Iszm;
- public static MetaCustomCoverItem Cover_Korp;
- public static MetaCustomCoverItem Cover_Jelt;
- public static MetaCustomCoverItem Cover_Bitt;
+ // ZTones
+ public static MetaCustomCoverItem Cover_Agon;
+ public static MetaCustomCoverItem Cover_Iszm;
+ public static MetaCustomCoverItem Cover_Korp;
+ public static MetaCustomCoverItem Cover_Jelt;
+ public static MetaCustomCoverItem Cover_Bitt;
- // GT
- public static MetaItemCoverCasings Cover_Gt_Machine_Casing;
+ // GT
+ public static MetaItemCoverCasings Cover_Gt_Machine_Casing;
- public static void generateCustomCovers() {
+ public static void generateCustomCovers() {
- // init textures
- TexturesGtCutomCovers.init();
+ // init textures
+ TexturesGtCutomCovers.init();
- // GT Machine Casings
- Cover_Gt_Machine_Casing = new MetaItemCoverCasings();
+ // GT Machine Casings
+ Cover_Gt_Machine_Casing = new MetaItemCoverCasings();
- if (Loader.isModLoaded("Ztones")) {
- String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" };
- MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp,
- Cover_Jelt, Cover_Bitt };
- CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP,
- TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT };
- short[][][] aRGB = new short[][][] { ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT,
- ZTONES.RGB_BITT };
- for (int y = 0; y < aZtoneCoverTextureNames.length; y++) {
- aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y],
- aRGB[y]);
- }
- }
+ if (Loader.isModLoaded("Ztones")) {
+ String[] aZtoneCoverTextureNames = new String[] {"agon", "iszm", "korp", "jelt", "bitt"};
+ MetaCustomCoverItem[] aZtoneCoverItems =
+ new MetaCustomCoverItem[] {Cover_Agon, Cover_Iszm, Cover_Korp, Cover_Jelt, Cover_Bitt};
+ CustomIcon[][] aArrays = new CustomIcon[][] {
+ TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT
+ };
+ short[][][] aRGB =
+ new short[][][] {ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT, ZTONES.RGB_BITT
+ };
+ for (int y = 0; y < aZtoneCoverTextureNames.length; y++) {
+ aZtoneCoverItems[y] =
+ new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y], aRGB[y]);
+ }
+ }
+ }
- }
-
- final static class ZTONES {
-
- private static final short[][] RGB_AGON = new short[][] { VanillaColours.DYE_WHITE.getAsShort(),
- VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_LIME.getAsShort(),
- VanillaColours.DYE_GREEN.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
- VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
- VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
- VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_BROWN.getAsShort(),
- VanillaColours.DYE_BLACK.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_LIGHT_GRAY.getAsShort(), };
- private static final short[][] RGB_ISZM = new short[][] { VanillaColours.DYE_LIGHT_GRAY.getAsShort(),
- VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
- VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(),
- VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
- VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
- VanillaColours.DYE_DARK_PURPLE.getAsShort(),
- };
- private static final short[][] RGB_KORP = new short[][] { new short[] { 125, 125, 125 },
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(),
- VanillaColours.DYE_DARK_GRAY.getAsShort(), new short[] { 22, 156, 156 }, new short[] { 22, 156, 156 },
- VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), };
- private static final short[][] RGB_JELT = new short[][] { VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_ORANGE.getAsShort(), };
- private static final short[][] RGB_BITT = new short[][] { VanillaColours.DYE_BLACK.getAsShort(),
- VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(),
- VanillaColours.DYE_LIME.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(),
- VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
- VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(),
- VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
- VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(),
- VanillaColours.DYE_RED.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(),
- VanillaColours.DYE_BROWN.getAsShort(), };
-
- }
+ static final class ZTONES {
+ private static final short[][] RGB_AGON = new short[][] {
+ VanillaColours.DYE_WHITE.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_LIME.getAsShort(),
+ VanillaColours.DYE_GREEN.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(),
+ VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
+ VanillaColours.DYE_PINK.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_BROWN.getAsShort(),
+ VanillaColours.DYE_BLACK.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_LIGHT_GRAY.getAsShort(),
+ };
+ private static final short[][] RGB_ISZM = new short[][] {
+ VanillaColours.DYE_LIGHT_GRAY.getAsShort(),
+ VanillaColours.DYE_WHITE.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_GREEN.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(),
+ };
+ private static final short[][] RGB_KORP = new short[][] {
+ new short[] {125, 125, 125},
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ new short[] {22, 156, 156},
+ new short[] {22, 156, 156},
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ VanillaColours.DYE_DARK_GRAY.getAsShort(),
+ };
+ private static final short[][] RGB_JELT = new short[][] {
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ };
+ private static final short[][] RGB_BITT = new short[][] {
+ VanillaColours.DYE_BLACK.getAsShort(),
+ VanillaColours.DYE_WHITE.getAsShort(),
+ VanillaColours.DYE_YELLOW.getAsShort(),
+ VanillaColours.DYE_LIME.getAsShort(),
+ VanillaColours.DYE_GREEN.getAsShort(),
+ VanillaColours.DYE_CYAN.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_LIGHT_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_BLUE.getAsShort(),
+ VanillaColours.DYE_DARK_PURPLE.getAsShort(),
+ VanillaColours.DYE_LIGHT_PURPLE.getAsShort(),
+ VanillaColours.DYE_PINK.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_RED.getAsShort(),
+ VanillaColours.DYE_ORANGE.getAsShort(),
+ VanillaColours.DYE_BROWN.getAsShort(),
+ };
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java
index 072cf78c90..001b840df7 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java
@@ -1,7 +1,10 @@
package gtPlusPlus.xmod.gregtech.common.covers;
+import gregtech.api.enums.GT_Values;
import gregtech.api.gui.GT_GUICover;
+import gregtech.api.gui.widgets.GT_GuiIntegerTextBox;
import gregtech.api.interfaces.tileentity.ICoverable;
+import gregtech.api.net.GT_Packet_TileEntityCover;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.util.minecraft.LangUtils;
@@ -10,238 +13,261 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
-import gregtech.api.gui.widgets.GT_GuiIntegerTextBox;
-import gregtech.api.enums.GT_Values;
-import gregtech.api.net.GT_Packet_TileEntityCover;
-
public class GTPP_Cover_Overflow extends GT_CoverBehavior {
- public final int mTransferRate;
- public final int mInitialTransferRate;
- public final int mMaxTransferRate;
-
- public GTPP_Cover_Overflow(int aTransferRate) {
- this.mTransferRate = aTransferRate * 1000 / 10;
- this.mInitialTransferRate = aTransferRate;
- this.mMaxTransferRate = aTransferRate * 1000;
- }
-
- public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- long aTimer) {
- if (aCoverVariable == 0) {
- return aCoverVariable;
- }
- if ((aTileEntity instanceof IFluidHandler)) {
- //Logger.INFO("Trying to Void via Overflow.");
- IFluidHandler tTank1;
- ForgeDirection directionFrom;
- directionFrom = ForgeDirection.UNKNOWN;
- tTank1 = (IFluidHandler) aTileEntity;
- if (tTank1 != null) {
- //Logger.INFO("Found Self. "+aSide);
- //FluidStack aTankStack = tTank1.drain(ForgeDirection.UNKNOWN, 1, false);
- FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid;
- if (aTankStack != null) {
- //Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside.");
- if (aTankStack.amount > aCoverVariable) {
- int aAmountToDrain = aTankStack.amount - aCoverVariable;
- //Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like.");
- if (aAmountToDrain > 0) {
- FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true);
- if (tLiquid != null) {
- //Logger.INFO("Drained "+aAmountToDrain+"L.");
- }
- }
- }
- }
- else {
- //Logger.INFO("Could not simulate drain on self.");
- }
- }
- }
- return aCoverVariable;
- }
-
- public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
- aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f));
- } else {
- aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f));
- }
- if (aCoverVariable > mMaxTransferRate) {
- aCoverVariable = mInitialTransferRate;
- }
- if (aCoverVariable <= 0) {
- aCoverVariable = mMaxTransferRate;
- }
- GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L"));
- return aCoverVariable;
- }
-
- public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- EntityPlayer aPlayer, float aX, float aY, float aZ) {
- boolean aShift = aPlayer.isSneaking();
- int aAmount = aShift ? 128 : 8;
- if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
- aCoverVariable += aAmount;
- } else {
- aCoverVariable -= aAmount;
- }
- if (aCoverVariable > mMaxTransferRate) {
- aCoverVariable = mInitialTransferRate;
- }
- if (aCoverVariable <= 0) {
- aCoverVariable = mMaxTransferRate;
- }
- GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L"));
- aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
- return true;
- }
-
- 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 false;
- }
-
- public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
- return true;
- }
-
- 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 5;
- }
-
- //GUI
- @Override
- public boolean hasCoverGUI() {
- return true;
- }
-
- @Override
- public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) {
- return new GTPP_Cover_Overflow.GUI(aSide, aCoverID, coverData, aTileEntity);
- }
-
- private class GUI extends GT_GUICover {
- private final byte side;
- private final int coverID;
- private GT_GuiIntegerTextBox tBox;
- private int coverVariable;
-
- private static final int startX = 10;
- private static final int startY = 25;
- private static final int spaceX = 18;
- private static final int spaceY = 18;
-
- private boolean warn = false;
-
- public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
- super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID));
- this.side = aSide;
- this.coverID = aCoverID;
- this.coverVariable = aCoverVariable;
-
- tBox = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 0 + 8, spaceX * 4 - 3, 12);
- tBox.setText(String.valueOf(this.coverVariable));
- tBox.setMaxStringLength(10);
- }
-
- @Override
- protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) {
- tBox.setFocused(true);
- }
-
- @Override
- public void drawExtras(int mouseX, int mouseY, float parTicks) {
- super.drawExtras(mouseX, mouseY, parTicks);
- this.getFontRenderer().drawString(trans("323", "L"), startX + spaceX * 4, 4 + startY + spaceY * 0 + 8, 0xFF555555);
- if (warn)
- this.getFontRenderer().drawString(trans("325","Max")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("323", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xffff0000);
- else
- this.getFontRenderer().drawString(trans("324","Now")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("323", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xFF555555);
- }
- @Override
- public void onMouseWheel(int x, int y, int delta) {
- for (GT_GuiIntegerTextBox box : textBoxes){
- if (box.isFocused()) {
- int step = Math.max(1, Math.abs(delta / 120));
- step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step);
- long i;
- try {
- i = Long.parseLong(box.getText());
- } catch (NumberFormatException e) {
- return;
- }
- if (i > (Long.MAX_VALUE-1000))
- break;
-
- i = i + step;
- if (i <= 0)
- i = 0;
- box.setText(String.valueOf(i));
- break;
- }
- }
- }
-
- @Override
- public void applyTextBox(GT_GuiIntegerTextBox box) {
- long i;
- String s = box.getText().trim();
- try {
- i = Long.parseLong(s);
- } catch (NumberFormatException e) {
- resetTextBox(box);
- return;
- }
-
- warn = false;
- if (box.id == 2) {
- if (i > (long) mMaxTransferRate) {
- i = mMaxTransferRate;
- warn = true;
- } else if (i < 0) {
- i = 0;
- }
- coverVariable = (int) i;
- }
- box.setText(String.valueOf(i));
- GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile));
- }
-
- @Override
- public void resetTextBox(GT_GuiIntegerTextBox box) {
- if (box.id == 2)
- box.setText(String.valueOf(coverVariable));
- }
- }
+ public final int mTransferRate;
+ public final int mInitialTransferRate;
+ public final int mMaxTransferRate;
+
+ public GTPP_Cover_Overflow(int aTransferRate) {
+ this.mTransferRate = aTransferRate * 1000 / 10;
+ this.mInitialTransferRate = aTransferRate;
+ this.mMaxTransferRate = aTransferRate * 1000;
+ }
+
+ public int doCoverThings(
+ byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
+ if (aCoverVariable == 0) {
+ return aCoverVariable;
+ }
+ if ((aTileEntity instanceof IFluidHandler)) {
+ // Logger.INFO("Trying to Void via Overflow.");
+ IFluidHandler tTank1;
+ ForgeDirection directionFrom;
+ directionFrom = ForgeDirection.UNKNOWN;
+ tTank1 = (IFluidHandler) aTileEntity;
+ if (tTank1 != null) {
+ // Logger.INFO("Found Self. "+aSide);
+ // FluidStack aTankStack = tTank1.drain(ForgeDirection.UNKNOWN, 1, false);
+ FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid;
+ if (aTankStack != null) {
+ // Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at
+ // "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside.");
+ if (aTankStack.amount > aCoverVariable) {
+ int aAmountToDrain = aTankStack.amount - aCoverVariable;
+ // Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like.");
+ if (aAmountToDrain > 0) {
+ FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true);
+ if (tLiquid != null) {
+ // Logger.INFO("Drained "+aAmountToDrain+"L.");
+ }
+ }
+ }
+ } else {
+ // Logger.INFO("Could not simulate drain on self.");
+ }
+ }
+ }
+ return aCoverVariable;
+ }
+
+ public int onCoverScrewdriverclick(
+ byte aSide,
+ int aCoverID,
+ int aCoverVariable,
+ ICoverable aTileEntity,
+ EntityPlayer aPlayer,
+ float aX,
+ float aY,
+ float aZ) {
+ if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
+ aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f));
+ } else {
+ aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f));
+ }
+ if (aCoverVariable > mMaxTransferRate) {
+ aCoverVariable = mInitialTransferRate;
+ }
+ if (aCoverVariable <= 0) {
+ aCoverVariable = mMaxTransferRate;
+ }
+ GT_Utility.sendChatToPlayer(
+ aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L"));
+ return aCoverVariable;
+ }
+
+ public boolean onCoverRightclick(
+ byte aSide,
+ int aCoverID,
+ int aCoverVariable,
+ ICoverable aTileEntity,
+ EntityPlayer aPlayer,
+ float aX,
+ float aY,
+ float aZ) {
+ boolean aShift = aPlayer.isSneaking();
+ int aAmount = aShift ? 128 : 8;
+ if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) {
+ aCoverVariable += aAmount;
+ } else {
+ aCoverVariable -= aAmount;
+ }
+ if (aCoverVariable > mMaxTransferRate) {
+ aCoverVariable = mInitialTransferRate;
+ }
+ if (aCoverVariable <= 0) {
+ aCoverVariable = mMaxTransferRate;
+ }
+ GT_Utility.sendChatToPlayer(
+ aPlayer, LangUtils.trans("322", "Overflow point: ") + aCoverVariable + trans("323", "L"));
+ aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
+ return true;
+ }
+
+ 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 false;
+ }
+
+ public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
+ return true;
+ }
+
+ 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 5;
+ }
+
+ // GUI
+ @Override
+ public boolean hasCoverGUI() {
+ return true;
+ }
+
+ @Override
+ public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) {
+ return new GTPP_Cover_Overflow.GUI(aSide, aCoverID, coverData, aTileEntity);
+ }
+
+ private class GUI extends GT_GUICover {
+ private final byte side;
+ private final int coverID;
+ private GT_GuiIntegerTextBox tBox;
+ private int coverVariable;
+
+ private static final int startX = 10;
+ private static final int startY = 25;
+ private static final int spaceX = 18;
+ private static final int spaceY = 18;
+
+ private boolean warn = false;
+
+ public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
+ super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID));
+ this.side = aSide;
+ this.coverID = aCoverID;
+ this.coverVariable = aCoverVariable;
+
+ tBox = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 0 + 8, spaceX * 4 - 3, 12);
+ tBox.setText(String.valueOf(this.coverVariable));
+ tBox.setMaxStringLength(10);
+ }
+
+ @Override
+ protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) {
+ tBox.setFocused(true);
+ }
+
+ @Override
+ public void drawExtras(int mouseX, int mouseY, float parTicks) {
+ super.drawExtras(mouseX, mouseY, parTicks);
+ this.getFontRenderer()
+ .drawString(trans("323", "L"), startX + spaceX * 4, 4 + startY + spaceY * 0 + 8, 0xFF555555);
+ if (warn)
+ this.getFontRenderer()
+ .drawString(
+ trans("325", "Max") + ": " + coverVariable + "/" + mMaxTransferRate + " "
+ + trans("323", "L"),
+ startX + spaceX * 0,
+ 4 + startY + spaceY * 1 + 6,
+ 0xffff0000);
+ else
+ this.getFontRenderer()
+ .drawString(
+ trans("324", "Now") + ": " + coverVariable + "/" + mMaxTransferRate + " "
+ + trans("323", "L"),
+ startX + spaceX * 0,
+ 4 + startY + spaceY * 1 + 6,
+ 0xFF555555);
+ }
+
+ @Override
+ public void onMouseWheel(int x, int y, int delta) {
+ for (GT_GuiIntegerTextBox box : textBoxes) {
+ if (box.isFocused()) {
+ int step = Math.max(1, Math.abs(delta / 120));
+ step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step);
+ long i;
+ try {
+ i = Long.parseLong(box.getText());
+ } catch (NumberFormatException e) {
+ return;
+ }
+ if (i > (Long.MAX_VALUE - 1000)) break;
+
+ i = i + step;
+ if (i <= 0) i = 0;
+ box.setText(String.valueOf(i));
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void applyTextBox(GT_GuiIntegerTextBox box) {
+ long i;
+ String s = box.getText().trim();
+ try {
+ i = Long.parseLong(s);
+ } catch (NumberFormatException e) {
+ resetTextBox(box);
+ return;
+ }
+
+ warn = false;
+ if (box.id == 2) {
+ if (i > (long) mMaxTransferRate) {
+ i = mMaxTransferRate;
+ warn = true;
+ } else if (i < 0) {
+ i = 0;
+ }
+ coverVariable = (int) i;
+ }
+ box.setText(String.valueOf(i));
+ GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile));
+ }
+
+ @Override
+ public void resetTextBox(GT_GuiIntegerTextBox box) {
+ if (box.id == 2) box.setText(String.valueOf(coverVariable));
+ }
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java
index 0299447694..16369f570f 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java
@@ -1,8 +1,5 @@
package gtPlusPlus.xmod.gregtech.common.covers;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -11,172 +8,189 @@ import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.minecraft.LangUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import java.lang.reflect.Field;
+import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
public class GTPP_Cover_Overflow_Item extends GT_CoverBehavior {
- public final int mInitialCapacity;
- public final int mMaxItemCapacity;
-
- public static final Class sQuantumChest;
- public static final Class sSuperChestGTPP;
- public static final Class sSuperChestGTNH;
- public static HashMap<Integer, Field> mItemAmountFields = new HashMap<Integer, Field>();
- public static HashMap<Integer, Field> mItemTypeFields = new HashMap<Integer, Field>();
-
- static {
- sQuantumChest = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest");
- sSuperChestGTPP = ReflectionUtils.getClass("gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest");
- if (CORE.GTNH) {
- sSuperChestGTNH = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest");
- }
- else {
- sSuperChestGTNH = null;
- }
- if (sQuantumChest != null) {
- mItemAmountFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemCount"));
- mItemTypeFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemStack"));
- }
- if (sSuperChestGTPP != null) {
- mItemAmountFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemCount"));
- mItemTypeFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemStack"));
- }
- if (sSuperChestGTNH != null) {
- mItemAmountFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemCount"));
- mItemTypeFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemStack"));
- }
- }
-
- public GTPP_Cover_Overflow_Item(int aCapacity) {
- this.mInitialCapacity = aCapacity;
- this.mMaxItemCapacity = aCapacity * 1000;
- }
-
- public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
- long aTimer) {
- if (aCoverVariable == 0) {
- return aCoverVariable;
- }
-
- // Get the IGTTile
- IGregTechTileEntity aGtTileEntity = aTileEntity.getIGregTechTileEntity(aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord());
- if (aGtTileEntity == null) {
- return aCoverVariable;
- }
-
- // Get the MetaTile
- final IMetaTileEntity aMetaTileEntity = aGtTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return aCoverVariable;
- }
- boolean didHandle = false;
- // Special Case for everything I want to support. /facepalm
- if (sQuantumChest != null && sQuantumChest.isInstance(aMetaTileEntity)) {
- didHandle = handleDigitalChest(aMetaTileEntity, 0);
- }
- else if (sSuperChestGTPP.isInstance(aMetaTileEntity)) {
- didHandle = handleDigitalChest(aMetaTileEntity, 1);
-
- }
- else if (CORE.GTNH && sSuperChestGTNH != null && sSuperChestGTNH.isInstance(aMetaTileEntity)) {
- didHandle = handleDigitalChest(aMetaTileEntity, 2);
- }
-
+ public final int mInitialCapacity;
+ public final int mMaxItemCapacity;
+
+ public static final Class sQuantumChest;
+ public static final Class sSuperChestGTPP;
+ public static final Class sSuperChestGTNH;
+ public static HashMap<Integer, Field> mItemAmountFields = new HashMap<Integer, Field>();
+ public static HashMap<Integer, Field> mItemTypeFields = new HashMap<Integer, Field>();
+
+ static {
+ sQuantumChest = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest");
+ sSuperChestGTPP = ReflectionUtils.getClass(
+ "gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest");
+ if (CORE.GTNH) {
+ sSuperChestGTNH =
+ ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest");
+ } else {
+ sSuperChestGTNH = null;
+ }
+ if (sQuantumChest != null) {
+ mItemAmountFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemCount"));
+ mItemTypeFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemStack"));
+ }