diff options
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r-- | src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java | 63 |
1 files changed, 53 insertions, 10 deletions
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 d8f2c19c37..dbe9f7d9c0 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -1,30 +1,45 @@ package gregtech.common.covers; +import cpw.mods.fml.client.FMLClientHandler; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUICover; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiIconButton; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; +import net.minecraft.world.WorldServer; + +import static gregtech.GT_Mod.GT_FML_LOGGER; 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 (!((IMachineProgress) aTileEntity).wasShutdown()) { - if ((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) + if (aCoverVariable < 2) { + if ((aInputRedstone > 0) == (aCoverVariable == 0)) ((IMachineProgress) aTileEntity).enableWorking(); else ((IMachineProgress) aTileEntity).disableWorking(); ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); - } else { + } + else if (aCoverVariable == 2) { ((IMachineProgress) aTileEntity).disableWorking(); - return 2; + } else { + if (((IMachineProgress) aTileEntity).wasShutdown()) { + ((IMachineProgress) aTileEntity).disableWorking(); + // TODO: Notify lastPlayer the name and location of machine and that it stopped + return 2; + } else { + return 3 + doCoverThings(aSide,aInputRedstone, aCoverID, aCoverVariable - 3, aTileEntity, aTimer); + } } } return aCoverVariable; @@ -63,17 +78,24 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { } public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % 3; + aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % 5; if(aCoverVariable <0){aCoverVariable = 2;} if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, trans("003", "Normal")); + GT_Utility.sendChatToPlayer(aPlayer, trans("003", "Enable with Signal")); } if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, trans("004", "Inverted")); + GT_Utility.sendChatToPlayer(aPlayer, trans("004", "Disable with Signal")); } if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, trans("005", "No Work at all")); + GT_Utility.sendChatToPlayer(aPlayer, trans("005", "Disabled")); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, trans("505", "Enable with Signal (Safe)")); + } + if (aCoverVariable == 4) { + GT_Utility.sendChatToPlayer(aPlayer, trans("506", "Disable with Signal (Safe)")); } + // TODO: Set lastPlayer return aCoverVariable; } @@ -115,6 +137,8 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { b = new GT_GuiIconButton(this, 0, startX + spaceX * 0, startY + spaceY * 0, GT_GuiIcon.REDSTONE_ON); b = new GT_GuiIconButton(this, 1, startX + spaceX * 0, startY + spaceY * 1, GT_GuiIcon.REDSTONE_OFF); b = new GT_GuiIconButton(this, 2, startX + spaceX * 0, startY + spaceY * 2, GT_GuiIcon.CROSS); + + b = new GT_GuiIconCheckButton(this, 3, startX + spaceX * 0, startY + spaceY * 3, GT_GuiIcon.CHECKMARK, GT_GuiIcon.CROSS); } @Override @@ -123,6 +147,7 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { this.fontRendererObj.drawString(trans("243", "Enable with Redstone"), 3+startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); this.fontRendererObj.drawString(trans("244", "Disable with Redstone"),3+startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); this.fontRendererObj.drawString(trans("245", "Disable machine"), 3+startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString(trans("507", "Safe Mode"), 3+startX + spaceX*1, 4+startY+spaceY*3, 0xFF555555); } @Override @@ -132,7 +157,14 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { public void buttonClicked(GuiButton btn) { if (getClickable(btn.id)) { - coverVariable = getNewCoverVariable(btn.id); + int bID = btn.id; + if (bID == 3) { + ((GT_GuiIconCheckButton) btn).setChecked(!((GT_GuiIconCheckButton) btn).isChecked()); + } else { + coverVariable = getNewCoverVariable(bID); + } + adjustCoverVariable(); + // TODO: Set lastPlayer; GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); } updateButtons(); @@ -151,7 +183,18 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { } private boolean getClickable(int id) { - return id != coverVariable; + return ((id != coverVariable && id != coverVariable - 3) || id == 3); + } + + private void adjustCoverVariable() { + boolean safeMode = ((GT_GuiIconCheckButton) buttonList.get(3)).isChecked(); + if (safeMode && coverVariable < 2) { + coverVariable += 3; + } + if (!safeMode && coverVariable > 2) { + coverVariable -= 3; + } } + } } |