From 9353aa711b1d750ff945acdfed2d3b956291b615 Mon Sep 17 00:00:00 2001 From: Shawn Buckley Date: Wed, 21 Oct 2015 22:06:25 -0400 Subject: Reformat code --- .../java/gregtech/common/covers/GT_Cover_Arm.java | 173 ++++++------ .../common/covers/GT_Cover_Blastproof.java | 32 +-- .../common/covers/GT_Cover_ControlsWork.java | 125 ++++----- .../gregtech/common/covers/GT_Cover_Conveyor.java | 200 +++++++------- .../gregtech/common/covers/GT_Cover_Crafting.java | 35 +-- .../gregtech/common/covers/GT_Cover_DoesWork.java | 134 ++++----- .../gregtech/common/covers/GT_Cover_Drain.java | 152 +++++------ .../gregtech/common/covers/GT_Cover_EUMeter.java | 300 ++++++++++----------- .../common/covers/GT_Cover_EnergyOnly.java | 153 +++++------ .../gregtech/common/covers/GT_Cover_ItemMeter.java | 143 +++++----- .../java/gregtech/common/covers/GT_Cover_Lens.java | 23 +- .../common/covers/GT_Cover_LiquidMeter.java | 142 +++++----- .../common/covers/GT_Cover_NeedMaintainance.java | 211 +++++++-------- .../common/covers/GT_Cover_PlayerDetector.java | 201 +++++++------- .../java/gregtech/common/covers/GT_Cover_Pump.java | 285 +++++++++----------- .../common/covers/GT_Cover_RedstoneConductor.java | 138 +++++----- .../covers/GT_Cover_RedstoneReceiverExternal.java | 31 +-- .../covers/GT_Cover_RedstoneReceiverInternal.java | 29 +- .../common/covers/GT_Cover_RedstoneSignalizer.java | 119 ++++---- .../GT_Cover_RedstoneTransmitterExternal.java | 31 +-- .../GT_Cover_RedstoneTransmitterInternal.java | 39 ++- .../covers/GT_Cover_RedstoneWirelessBase.java | 153 +++++------ .../gregtech/common/covers/GT_Cover_Screen.java | 127 ++++----- .../gregtech/common/covers/GT_Cover_Shutter.java | 113 ++++---- .../common/covers/GT_Cover_SolarPanel.java | 53 ++-- .../java/gregtech/common/covers/GT_Cover_Vent.java | 54 ++-- 26 files changed, 1446 insertions(+), 1750 deletions(-) (limited to 'src/main/java/gregtech/common/covers') diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java index 3212ce92af..80f957e58c 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java @@ -9,104 +9,87 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; public class GT_Cover_Arm - extends GT_CoverBehavior -{ - public final int mTickRate; - - public GT_Cover_Arm(int aTickRate) - { - this.mTickRate = aTickRate; - } - - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - if ((aCoverVariable == 0) || (((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress)aTileEntity).isAllowedToWork()))) { - return aCoverVariable; + extends GT_CoverBehavior { + public final int mTickRate; + + public GT_Cover_Arm(int aTickRate) { + this.mTickRate = aTickRate; + } + + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if ((aCoverVariable == 0) || (((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress) aTileEntity).isAllowedToWork()))) { + return aCoverVariable; + } + TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); + aTileEntity.decreaseStoredEnergyUnits(1L, true); + if (aTileEntity.getUniversalEnergyCapacity() >= 128L) { + if (aTileEntity.isUniversalEnergyStored(256L)) { + aTileEntity.decreaseStoredEnergyUnits(4 * GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1), true); + } + } else { + GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + 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 += 16; + } else { + aCoverVariable -= 16; + } + GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? "Puts out into adjacent Slot #" : "Grabs in for own Slot #") + (Math.abs(aCoverVariable) - 1)); + return aCoverVariable; + } + + public boolean onCoverRightclick(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++; + } else { + aCoverVariable--; + } + GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? "Puts out into adjacent Slot #" : "Grabs in for own Slot #") + (Math.abs(aCoverVariable) - 1)); + aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + return true; + } + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); - aTileEntity.decreaseStoredEnergyUnits(1L, true); - if (aTileEntity.getUniversalEnergyCapacity() >= 128L) - { - if (aTileEntity.isUniversalEnergyStored(256L)) { - aTileEntity.decreaseStoredEnergyUnits(4 * GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte)64, (byte)1, (byte)64, (byte)1), true); - } + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - else { - GT_Utility.moveOneItemStackIntoSlot(aCoverVariable > 0 ? aTileEntity : tTileEntity, aCoverVariable > 0 ? tTileEntity : aTileEntity, aCoverVariable > 0 ? aSide : GT_Utility.getOppositeSide(aSide), Math.abs(aCoverVariable) - 1, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - 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 += 16; - } else { - aCoverVariable -= 16; + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? "Puts out into adjacent Slot #" : "Grabs in for own Slot #") + (Math.abs(aCoverVariable) - 1)); - return aCoverVariable; - } - - public boolean onCoverRightclick(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++; - } else { - aCoverVariable--; + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return this.mTickRate; } - GT_Utility.sendChatToPlayer(aPlayer, (aCoverVariable > 0 ? "Puts out into adjacent Slot #" : "Grabs in for own Slot #") + (Math.abs(aCoverVariable) - 1)); - 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 letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return true; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return this.mTickRate; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Blastproof.java b/src/main/java/gregtech/common/covers/GT_Cover_Blastproof.java index 8c92eb9175..684ce9f3c0 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Blastproof.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Blastproof.java @@ -4,22 +4,18 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; public class GT_Cover_Blastproof - extends GT_CoverBehavior -{ - private final float mLevel; - - public GT_Cover_Blastproof(float aLevel) - { - this.mLevel = aLevel; - } - - public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return this.mLevel; - } - - public boolean isSimpleCover() - { - return true; - } + extends GT_CoverBehavior { + private final float mLevel; + + public GT_Cover_Blastproof(float aLevel) { + this.mLevel = aLevel; + } + + public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return this.mLevel; + } + + public boolean isSimpleCover() { + return true; + } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java index ee06b47f51..ed53f29865 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -8,78 +8,65 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_ControlsWork - extends GT_CoverBehavior -{ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - if(aTileEntity instanceof IMachineProgress) - { - if((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) - ((IMachineProgress)aTileEntity).enableWorking(); - else - ((IMachineProgress)aTileEntity).disableWorking(); - ((IMachineProgress)aTileEntity).setWorkDataValue(aInputRedstone); + extends GT_CoverBehavior { + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if (aTileEntity instanceof IMachineProgress) { + if ((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) + ((IMachineProgress) aTileEntity).enableWorking(); + else + ((IMachineProgress) aTileEntity).disableWorking(); + ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); + } + return aCoverVariable; } - return aCoverVariable; -} - - 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 letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) - { - if ((aTileEntity instanceof IMachineProgress)) - { - ((IMachineProgress)aTileEntity).enableWorking(); - ((IMachineProgress)aTileEntity).setWorkDataValue((byte)0); + + 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; } - return true; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 3; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal"); + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, "No Work at all"); + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { + if ((aTileEntity instanceof IMachineProgress)) { + ((IMachineProgress) aTileEntity).enableWorking(); + ((IMachineProgress) aTileEntity).setWorkDataValue((byte) 0); + } + return true; + } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 3; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal"); + } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); + } + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "No Work at all"); + } + return aCoverVariable; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 1; } - return aCoverVariable; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return 1; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java index 10d2eb8008..746b11a59d 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java @@ -9,125 +9,109 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; public class GT_Cover_Conveyor - extends GT_CoverBehavior -{ - public final int mTickRate; - - public GT_Cover_Conveyor(int aTickRate) - { - this.mTickRate = aTickRate; - } - - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { - if (((IMachineProgress)aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { - return aCoverVariable; - } - } - TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); - aTileEntity.decreaseStoredEnergyUnits(1L, true); - if (((aCoverVariable % 2 != 1) || (aSide != 1)) && ((aCoverVariable % 2 != 0) || (aSide != 0)) && (aTileEntity.getUniversalEnergyCapacity() >= 128L)) - { - if (aTileEntity.isUniversalEnergyStored(256L)) { - aTileEntity.decreaseStoredEnergyUnits(4 * GT_Utility.moveOneItemStack(aCoverVariable % 2 == 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? GT_Utility.getOppositeSide(aSide) : aSide, aCoverVariable % 2 == 0 ? GT_Utility.getOppositeSide(aSide) : aSide, null, false, (byte)64, (byte)1, (byte)64, (byte)1), true); - } - } - else { - GT_Utility.moveOneItemStack(aCoverVariable % 2 == 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? GT_Utility.getOppositeSide(aSide) : aSide, aCoverVariable % 2 == 0 ? GT_Utility.getOppositeSide(aSide) : aSide, null, false, (byte)64, (byte)1, (byte)64, (byte)1); + extends GT_CoverBehavior { + public final int mTickRate; + + public GT_Cover_Conveyor(int aTickRate) { + this.mTickRate = aTickRate; } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 12; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Export"); + + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { + if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 6 < 4) { + return aCoverVariable; + } + } + TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); + aTileEntity.decreaseStoredEnergyUnits(1L, true); + if (((aCoverVariable % 2 != 1) || (aSide != 1)) && ((aCoverVariable % 2 != 0) || (aSide != 0)) && (aTileEntity.getUniversalEnergyCapacity() >= 128L)) { + if (aTileEntity.isUniversalEnergyStored(256L)) { + aTileEntity.decreaseStoredEnergyUnits(4 * GT_Utility.moveOneItemStack(aCoverVariable % 2 == 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? GT_Utility.getOppositeSide(aSide) : aSide, aCoverVariable % 2 == 0 ? GT_Utility.getOppositeSide(aSide) : aSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1), true); + } + } else { + GT_Utility.moveOneItemStack(aCoverVariable % 2 == 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? aTileEntity : tTileEntity, aCoverVariable % 2 != 0 ? GT_Utility.getOppositeSide(aSide) : aSide, aCoverVariable % 2 == 0 ? GT_Utility.getOppositeSide(aSide) : aSide, null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + return aCoverVariable; } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Import"); + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 12; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Export"); + } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Import"); + } + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)"); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); + } + if (aCoverVariable == 4) { + GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)"); + } + if (aCoverVariable == 5) { + GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); + } + if (aCoverVariable == 6) { + GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input"); + } + if (aCoverVariable == 7) { + GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output"); + } + if (aCoverVariable == 8) { + GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)"); + } + if (aCoverVariable == 9) { + GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)"); + } + if (aCoverVariable == 10) { + GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)"); + } + if (aCoverVariable == 11) { + GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)"); + } + return aCoverVariable; } - if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)"); + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 3) { - GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 4) { - GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)"); + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 5) { - GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 6) { - GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input"); + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 7) { - GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output"); + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 8) { - GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)"); + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return (aCoverVariable >= 6) || (aCoverVariable % 2 != 0); } - if (aCoverVariable == 9) { - GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)"); + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return (aCoverVariable >= 6) || (aCoverVariable % 2 == 0); } - if (aCoverVariable == 10) { - GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)"); + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 11) { - GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)"); + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return this.mTickRate; } - 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 letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) - { - return (aCoverVariable >= 6) || (aCoverVariable % 2 != 0); - } - - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) - { - return (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 this.mTickRate; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java index 0198146fc6..d7d78833bb 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java @@ -4,32 +4,23 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerWorkbench; -import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.play.server.S2DPacketOpenWindow; -import net.minecraft.world.World; public class GT_Cover_Crafting - extends GT_CoverBehavior -{ - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - if ((aPlayer instanceof EntityPlayerMP)) - { - ((EntityPlayerMP)aPlayer).getNextWindowId(); - ((EntityPlayerMP)aPlayer).playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(((EntityPlayerMP)aPlayer).currentWindowId, 1, "Crafting", 9, true)); - ((EntityPlayerMP)aPlayer).openContainer = new ContainerWorkbench(((EntityPlayerMP)aPlayer).inventory, ((EntityPlayerMP)aPlayer).worldObj, aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()) - { - public boolean canInteractWith(EntityPlayer par1EntityPlayer) - { - return true; + extends GT_CoverBehavior { + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if ((aPlayer instanceof EntityPlayerMP)) { + ((EntityPlayerMP) aPlayer).getNextWindowId(); + ((EntityPlayerMP) aPlayer).playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(((EntityPlayerMP) aPlayer).currentWindowId, 1, "Crafting", 9, true)); + ((EntityPlayerMP) aPlayer).openContainer = new ContainerWorkbench(((EntityPlayerMP) aPlayer).inventory, ((EntityPlayerMP) aPlayer).worldObj, aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()) { + public boolean canInteractWith(EntityPlayer par1EntityPlayer) { + return true; + } + }; + ((EntityPlayerMP) aPlayer).openContainer.windowId = ((EntityPlayerMP) aPlayer).currentWindowId; + ((EntityPlayerMP) aPlayer).openContainer.addCraftingToCrafters((EntityPlayerMP) aPlayer); } - }; - ((EntityPlayerMP)aPlayer).openContainer.windowId = ((EntityPlayerMP)aPlayer).currentWindowId; - ((EntityPlayerMP)aPlayer).openContainer.addCraftingToCrafters((EntityPlayerMP)aPlayer); + return true; } - return true; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java index 119e054b54..cd1f095396 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java @@ -8,87 +8,71 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_DoesWork - extends GT_CoverBehavior -{ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - if ((aTileEntity instanceof IMachineProgress)) - { - if (aCoverVariable < 2) - { - int tScale = ((IMachineProgress)aTileEntity).getMaxProgress() / 15; - if ((tScale > 0) && (((IMachineProgress)aTileEntity).hasThingsToDo())) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(((IMachineProgress)aTileEntity).getProgress() / tScale) : (byte)(15 - ((IMachineProgress)aTileEntity).getProgress() / tScale)); + extends GT_CoverBehavior { + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if ((aTileEntity instanceof IMachineProgress)) { + if (aCoverVariable < 2) { + int tScale = ((IMachineProgress) aTileEntity).getMaxProgress() / 15; + if ((tScale > 0) && (((IMachineProgress) aTileEntity).hasThingsToDo())) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (((IMachineProgress) aTileEntity).getProgress() / tScale) : (byte) (15 - ((IMachineProgress) aTileEntity).getProgress() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) ((aCoverVariable % 2 == 0 ? 1 : 0) != (((IMachineProgress) aTileEntity).getMaxProgress() == 0 ? 1 : 0) ? 0 : 15)); + } } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); + aTileEntity.setOutputRedstoneSignal(aSide, (byte) 0); } - } - else - { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)((aCoverVariable % 2 == 0 ? 1 : 0) != (((IMachineProgress)aTileEntity).getMaxProgress() == 0 ? 1 : 0) ? 0 : 15)); - } + return aCoverVariable; } - else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)0); + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 4; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal"); + } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); + } + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "Ready to work"); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, "Not ready to work"); + } + return aCoverVariable; } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 4; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal"); + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, "Ready to work"); + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 3) { - GT_Utility.sendChatToPlayer(aPlayer, "Not ready to work"); + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; } - return aCoverVariable; - } - - 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 letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return true; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return 5; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java index a17098e8b2..e27346e776 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java @@ -8,8 +8,6 @@ import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -17,92 +15,82 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidHandler; public class GT_Cover_Drain - extends GT_CoverBehavior -{ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - if ((aCoverVariable % 3 > 1) && ((aTileEntity instanceof IMachineProgress))) { - if (((IMachineProgress)aTileEntity).isAllowedToWork() != aCoverVariable % 3 < 2) { + extends GT_CoverBehavior { + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if ((aCoverVariable % 3 > 1) && ((aTileEntity instanceof IMachineProgress))) { + if (((IMachineProgress) aTileEntity).isAllowedToWork() != aCoverVariable % 3 < 2) { + return aCoverVariable; + } + } + if (aSide != 6) { + Block tBlock = aTileEntity.getBlockAtSide(aSide); + if ((aCoverVariable < 3) && ((aTileEntity instanceof IFluidHandler))) { + if ((aSide == 1) && + (aTileEntity.getWorld().isRaining()) && + (aTileEntity.getWorld().getPrecipitationHeight(aTileEntity.getXCoord(), aTileEntity.getZCoord()) - 2 < aTileEntity.getYCoord())) { + int tAmount = (int) (aTileEntity.getBiome().rainfall * 10.0F); + if (tAmount > 0) { + ((IFluidHandler) aTileEntity).fill(ForgeDirection.getOrientation(aSide), Materials.Water.getFluid(aTileEntity.getWorld().isThundering() ? tAmount * 2 : tAmount), true); + } + } + FluidStack tLiquid = null; + if (tBlock != null) { + if (((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water)) && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { + tLiquid = Materials.Water.getFluid(1000L); + } else if (((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { + tLiquid = Materials.Lava.getFluid(1000L); + } else if ((tBlock instanceof IFluidBlock)) { + tLiquid = ((IFluidBlock) tBlock).drain(aTileEntity.getWorld(), aTileEntity.getOffsetX(aSide, 1), aTileEntity.getOffsetY(aSide, 1), aTileEntity.getOffsetZ(aSide, 1), false); + } + if ((tLiquid != null) && (tLiquid.getFluid() != null) && ((aSide > 1) || ((aSide == 0) && (tLiquid.getFluid().getDensity() <= 0)) || ((aSide == 1) && (tLiquid.getFluid().getDensity() >= 0))) && + (((IFluidHandler) aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, false) == tLiquid.amount)) { + ((IFluidHandler) aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, true); + aTileEntity.getWorld().setBlockToAir(aTileEntity.getXCoord() + ForgeDirection.getOrientation(aSide).offsetX, aTileEntity.getYCoord() + ForgeDirection.getOrientation(aSide).offsetY, aTileEntity.getZCoord() + ForgeDirection.getOrientation(aSide).offsetZ); + } + } + } + if ((aCoverVariable >= 3) && (tBlock != null) && ( + (tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava) || (tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock)))) { + aTileEntity.getWorld().setBlock(aTileEntity.getOffsetX(aSide, 1), aTileEntity.getOffsetY(aSide, 1), aTileEntity.getOffsetZ(aSide, 1), Blocks.air, 0, 0); + } + } return aCoverVariable; - } } - if (aSide != 6) - { - Block tBlock = aTileEntity.getBlockAtSide(aSide); - if ((aCoverVariable < 3) && ((aTileEntity instanceof IFluidHandler))) - { - if ((aSide == 1) && - (aTileEntity.getWorld().isRaining()) && - (aTileEntity.getWorld().getPrecipitationHeight(aTileEntity.getXCoord(), aTileEntity.getZCoord()) - 2 < aTileEntity.getYCoord())) - { - int tAmount = (int)(aTileEntity.getBiome().rainfall * 10.0F); - if (tAmount > 0) { - ((IFluidHandler)aTileEntity).fill(ForgeDirection.getOrientation(aSide), Materials.Water.getFluid(aTileEntity.getWorld().isThundering() ? tAmount * 2 : tAmount), true); - } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 6; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Import"); } - FluidStack tLiquid = null; - if (tBlock != null) - { - if (((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water)) && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { - tLiquid = Materials.Water.getFluid(1000L); - } else if (((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) && (aTileEntity.getMetaIDAtSide(aSide) == 0)) { - tLiquid = Materials.Lava.getFluid(1000L); - } else if ((tBlock instanceof IFluidBlock)) { - tLiquid = ((IFluidBlock)tBlock).drain(aTileEntity.getWorld(), aTileEntity.getOffsetX(aSide, 1), aTileEntity.getOffsetY(aSide, 1), aTileEntity.getOffsetZ(aSide, 1), false); - } - if ((tLiquid != null) && (tLiquid.getFluid() != null) && ((aSide > 1) || ((aSide == 0) && (tLiquid.getFluid().getDensity() <= 0)) || ((aSide == 1) && (tLiquid.getFluid().getDensity() >= 0))) && - (((IFluidHandler)aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, false) == tLiquid.amount)) - { - ((IFluidHandler)aTileEntity).fill(ForgeDirection.getOrientation(aSide), tLiquid, true); - aTileEntity.getWorld().setBlockToAir(aTileEntity.getXCoord() + ForgeDirection.getOrientation(aSide).offsetX, aTileEntity.getYCoord() + ForgeDirection.getOrientation(aSide).offsetY, aTileEntity.getZCoord() + ForgeDirection.getOrientation(aSide).offsetZ); - } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); } - } - if ((aCoverVariable >= 3) && (tBlock != null) && ( - (tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava) || (tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock)))) { - aTileEntity.getWorld().setBlock(aTileEntity.getOffsetX(aSide, 1), aTileEntity.getOffsetY(aSide, 1), aTileEntity.getOffsetZ(aSide, 1), Blocks.air, 0, 0); - } - } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 6; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Import"); - } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); - } - if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away"); + } + if (aCoverVariable == 4) { + GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (conditional)"); + } + if (aCoverVariable == 5) { + GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (invert cond)"); + } + return aCoverVariable; } - if (aCoverVariable == 3) { - GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away"); + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + if ((aCoverVariable > 1) && ((aTileEntity instanceof IMachineProgress))) { + } + return ((IMachineProgress) aTileEntity).isAllowedToWork() == aCoverVariable < 2; } - if (aCoverVariable == 4) { - GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (conditional)"); + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 5) { - GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (invert cond)"); + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return aCoverVariable < 3 ? 50 : 1; } - return aCoverVariable; - } - - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - if ((aCoverVariable > 1) && ((aTileEntity instanceof IMachineProgress))) {} - return ((IMachineProgress)aTileEntity).isAllowedToWork() == aCoverVariable < 2; - } - - 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 aCoverVariable < 3 ? 50 : 1; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java index 6917e6bf0a..d723721b63 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java @@ -1,187 +1,165 @@ package gregtech.common.covers; -import ic2.api.item.IElectricItem; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.util.GT_BaseCrop; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; +import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; public class GT_Cover_EUMeter - extends GT_CoverBehavior -{ - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) - { - long tScale = 0L; - if (aCoverVariable < 2) - { - tScale = aTileEntity.getUniversalEnergyCapacity() / 15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(aTileEntity.getUniversalEnergyStored() / tScale) : (byte)(int)(15L - aTileEntity.getUniversalEnergyStored() / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - else if (aCoverVariable < 4) - { - tScale = aTileEntity.getEUCapacity() / 15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(aTileEntity.getStoredEU() / tScale) : (byte)(int)(15L - aTileEntity.getStoredEU() / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - else if (aCoverVariable < 6) - { - tScale = aTileEntity.getSteamCapacity() / 15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(aTileEntity.getStoredSteam() / tScale) : (byte)(int)(15L - aTileEntity.getStoredSteam() / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - else if (aCoverVariable < 8) - { - tScale = aTileEntity.getInputVoltage() * aTileEntity.getInputAmperage() / 15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(aTileEntity.getAverageElectricInput() / tScale) : (byte)(int)(15L - aTileEntity.getAverageElectricInput() / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - else if (aCoverVariable < 10) - { - tScale = aTileEntity.getOutputVoltage() * aTileEntity.getOutputAmperage() / 15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(aTileEntity.getAverageElectricOutput() / tScale) : (byte)(int)(15L - aTileEntity.getAverageElectricOutput() / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - else if (aCoverVariable < 12) - { - tScale = aTileEntity.getEUCapacity(); - long tStored = aTileEntity.getStoredEU(); - if(aTileEntity instanceof IGregTechTileEntity){ - IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aTileEntity; - IMetaTileEntity mTileEntity = tTileEntity.getMetaTileEntity(); - if(mTileEntity instanceof GT_MetaTileEntity_BasicBatteryBuffer){ - GT_MetaTileEntity_BasicBatteryBuffer buffer = (GT_MetaTileEntity_BasicBatteryBuffer) mTileEntity; - if(buffer.mInventory!=null){ - for(ItemStack aStack : buffer.mInventory){ - if (GT_ModHandler.isElectricItem(aStack)) { - - if(aStack.getItem() instanceof GT_MetaBase_Item){ - Long[] stats = ((GT_MetaBase_Item)aStack.getItem()).getElectricStats(aStack); - if(stats!=null){ - tScale = tScale + stats[0]; - tStored = tStored + ((GT_MetaBase_Item)aStack.getItem()).getRealCharge(aStack); - } - }else if(aStack.getItem() instanceof IElectricItem){ - tStored = tStored + (long)ic2.api.item.ElectricItem.manager.getCharge(aStack); - tScale = tScale + (long)((IElectricItem)aStack.getItem()).getMaxCharge(aStack); - } - } - } - - }}} - tScale = tScale/15L; - if (tScale > 0L) { - aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte)(int)(tStored / tScale) : (byte)(int)(15L - tStored / tScale)); - } else { - aTileEntity.setOutputRedstoneSignal(aSide, (byte)(aCoverVariable % 2 == 0 ? 0 : 15)); - } - } - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 12; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Universal Storage"); + extends GT_CoverBehavior { + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + long tScale = 0L; + if (aCoverVariable < 2) { + tScale = aTileEntity.getUniversalEnergyCapacity() / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (aTileEntity.getUniversalEnergyStored() / tScale) : (byte) (int) (15L - aTileEntity.getUniversalEnergyStored() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else if (aCoverVariable < 4) { + tScale = aTileEntity.getEUCapacity() / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (aTileEntity.getStoredEU() / tScale) : (byte) (int) (15L - aTileEntity.getStoredEU() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else if (aCoverVariable < 6) { + tScale = aTileEntity.getSteamCapacity() / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (aTileEntity.getStoredSteam() / tScale) : (byte) (int) (15L - aTileEntity.getStoredSteam() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else if (aCoverVariable < 8) { + tScale = aTileEntity.getInputVoltage() * aTileEntity.getInputAmperage() / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (aTileEntity.getAverageElectricInput() / tScale) : (byte) (int) (15L - aTileEntity.getAverageElectricInput() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else if (aCoverVariable < 10) { + tScale = aTileEntity.getOutputVoltage() * aTileEntity.getOutputAmperage() / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (aTileEntity.getAverageElectricOutput() / tScale) : (byte) (int) (15L - aTileEntity.getAverageElectricOutput() / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } else if (aCoverVariable < 12) { + tScale = aTileEntity.getEUCapacity(); + long tStored = aTileEntity.getStoredEU(); + if (aTileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aTileEntity; + IMetaTileEntity mTileEntity = tTileEntity.getMetaTileEntity(); + if (mTileEntity instanceof GT_MetaTileEntity_BasicBatteryBuffer) { + GT_MetaTileEntity_BasicBatteryBuffer buffer = (GT_MetaTileEntity_BasicBatteryBuffer) mTileEntity; + if (buffer.mInventory != null) { + for (ItemStack aStack : buffer.mInventory) { + if (GT_ModHandler.isElectricItem(aStack)) { + + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); + if (stats != null) { + tScale = tScale + stats[0]; + tStored = tStored + ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored = tStored + (long) ic2.api.item.ElectricItem.manager.getCharge(aStack); + tScale = tScale + (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); + } + } + } + + } + } + } + tScale = tScale / 15L; + if (tScale > 0L) { + aTileEntity.setOutputRedstoneSignal(aSide, aCoverVariable % 2 == 0 ? (byte) (int) (tStored / tScale) : (byte) (int) (15L - tStored / tScale)); + } else { + aTileEntity.setOutputRedstoneSignal(aSide, (byte) (aCoverVariable % 2 == 0 ? 0 : 15)); + } + } + return aCoverVariable; } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Universal Storage"); + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 12; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Universal Storage"); + } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Universal Storage"); + } + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage"); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage"); + } + if (aCoverVariable == 4) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Steam Storage"); + } + if (aCoverVariable == 5) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Steam Storage"); + } + if (aCoverVariable == 6) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Input"); + } + if (aCoverVariable == 7) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Input"); + } + if (aCoverVariable == 8) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Output"); + } + if (aCoverVariable == 9) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Output"); + } + if (aCoverVariable == 10) { + GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage(Including Batterys)"); + } + if (aCoverVariable == 11) { + GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage(Including Batterys)"); + } + return aCoverVariable; } - if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage"); + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 3) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage"); + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 4) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Steam Storage"); + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 5) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Steam Storage"); + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 6) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Input"); + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 7) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Input"); + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 8) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Output"); + + public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; } - if (aCoverVariable == 9) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Output"); + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 20; } - if (aCoverVariable == 10) { - GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage(Including Batterys)"); - } - if (aCoverVariable == 11) { - GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage(Including Batterys)"); - } - return aCoverVariable; - } - - 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 letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) - { - return true; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, 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 manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return true; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) - { - return 20; - } } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java b/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java index 4ffdcb9e1b..5c0f1ea001 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java @@ -8,95 +8,80 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_EnergyOnly - extends GT_CoverBehavior -{ - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) - { - aCoverVariable = (aCoverVariable + 1) % 3; - if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Allow"); + extends GT_CoverBehavior { + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aCoverVariable = (aCoverVariable + 1) % 3; + if (aCoverVariable == 0) { + GT_Utility.sendChatToPlayer(aPlayer, "Allow"); + } + if (aCoverVariable == 1) { + GT_Utility.sendChatToPlayer(aPlayer, "Allow (conditional)"); + } + if (aCoverVariable == 2) { + GT_Utility.sendChatToPlayer(aPlayer, "Disallow (conditional)"); + } + return aCoverVariable; } - if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, "Allow (conditional)"); + + public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 20.0F; } - if (aCoverVariable == 2) { - G