Advertisement
Guest User

GuiAltLogin

a guest
Mar 25th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. import java.io.IOException;
  2. import net.minecraft.client.gui.GuiButton;
  3. import net.minecraft.client.gui.GuiScreen;
  4. import net.minecraft.client.gui.GuiTextField;
  5. import net.minecraft.util.EnumChatFormatting;
  6. import org.lwjgl.input.Keyboard;
  7.  
  8. public final class GuiAltLogin
  9. extends GuiScreen {
  10. private PasswordField password;
  11. private final GuiScreen previousScreen;
  12. private AltLoginThread thread;
  13. private GuiTextField username;
  14.  
  15. public GuiAltLogin(GuiScreen previousScreen) {
  16. this.previousScreen = previousScreen;
  17. }
  18.  
  19. @Override
  20. protected void actionPerformed(GuiButton button) {
  21. switch (button.id) {
  22. case 1: {
  23. this.mc.displayGuiScreen(this.previousScreen);
  24. break;
  25. }
  26. case 0: {
  27. this.thread = new AltLoginThread(this.username.getText(), this.password.getText());
  28. this.thread.start();
  29. }
  30. }
  31. }
  32.  
  33. @Override
  34. public void drawScreen(int x2, int y2, float z2) {
  35. this.drawDefaultBackground();
  36. this.username.drawTextBox();
  37. this.password.drawTextBox();
  38. this.drawCenteredString(this.mc.fontRendererObj, "Alt Login", width / 2, 20, -1);
  39. this.drawCenteredString(this.mc.fontRendererObj, this.thread == null ? (Object)((Object)EnumChatFormatting.GRAY) + "Idle..." : this.thread.getStatus(), width / 2, 29, -1);
  40. if (this.username.getText().isEmpty()) {
  41. this.drawString(this.mc.fontRendererObj, "Username / E-Mail", width / 2 - 96, 66, -7829368);
  42. }
  43. if (this.password.getText().isEmpty()) {
  44. this.drawString(this.mc.fontRendererObj, "Password", width / 2 - 96, 106, -7829368);
  45. }
  46. super.drawScreen(x2, y2, z2);
  47. }
  48.  
  49. @Override
  50. public void initGui() {
  51. int var3 = height / 4 + 24;
  52. this.buttonList.add(new GuiButton(0, width / 2 - 100, var3 + 72 + 12, "Login"));
  53. this.buttonList.add(new GuiButton(1, width / 2 - 100, var3 + 72 + 12 + 24, "Back"));
  54. this.username = new GuiTextField(var3, this.mc.fontRendererObj, width / 2 - 100, 60, 200, 20);
  55. this.password = new PasswordField(this.mc.fontRendererObj, width / 2 - 100, 100, 200, 20);
  56. this.username.setFocused(true);
  57. Keyboard.enableRepeatEvents(true);
  58. }
  59.  
  60. @Override
  61. protected void keyTyped(char character, int key) {
  62. try {
  63. super.keyTyped(character, key);
  64. }
  65. catch (IOException e) {
  66. e.printStackTrace();
  67. }
  68. if (character == '\t') {
  69. if (!this.username.isFocused() && !this.password.isFocused()) {
  70. this.username.setFocused(true);
  71. } else {
  72. this.username.setFocused(this.password.isFocused());
  73. this.password.setFocused(!this.username.isFocused());
  74. }
  75. }
  76. if (character == '\r') {
  77. this.actionPerformed((GuiButton)this.buttonList.get(0));
  78. }
  79. this.username.textboxKeyTyped(character, key);
  80. this.password.textboxKeyTyped(character, key);
  81. }
  82.  
  83. @Override
  84. protected void mouseClicked(int x2, int y2, int button) {
  85. try {
  86. super.mouseClicked(x2, y2, button);
  87. }
  88. catch (IOException e) {
  89. e.printStackTrace();
  90. }
  91. this.username.mouseClicked(x2, y2, button);
  92. this.password.mouseClicked(x2, y2, button);
  93. }
  94.  
  95. @Override
  96. public void onGuiClosed() {
  97. Keyboard.enableRepeatEvents(false);
  98. }
  99.  
  100. @Override
  101. public void updateScreen() {
  102. this.username.updateCursorCounter();
  103. this.password.updateCursorCounter();
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement