Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.11 KB | None | 0 0
  1. //THE GUI
  2. package me.lordethan.cryton.utils;
  3.  
  4. import java.io.IOException;
  5. import java.util.List;
  6. import me.lordethan.cryton.ui.GuiMaskedTextField;
  7. import me.lordethan.cryton.utils.LoginThread;
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.client.gui.FontRenderer;
  10. import net.minecraft.client.gui.GuiButton;
  11. import net.minecraft.client.gui.GuiScreen;
  12. import net.minecraft.client.gui.GuiTextField;
  13. import net.minecraft.util.Session;
  14. import org.lwjgl.input.Keyboard;
  15.  
  16. public class GuiLogin
  17. extends GuiScreen {
  18. private GuiTextField username;
  19. private GuiMaskedTextField password;
  20. private LoginThread loginThread;
  21. private GuiScreen parent;
  22.  
  23. public GuiLogin(GuiScreen parent) {
  24. this.parent = parent;
  25. }
  26.  
  27. @Override
  28. public void initGui() {
  29. GuiLogin.drawString(this.fontRendererObj, "Welcome \u00a7c" + GuiLogin.mc.session.username, this.width / 2 - this.fontRendererObj.getStringWidth("Welcome " + GuiLogin.mc.session.username) / 2, this.height - 10, -1);
  30. Keyboard.enableRepeatEvents((boolean)true);
  31. this.buttonList.clear();
  32. this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 92 + 12, "Login"));
  33. this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 116 + 12, "Back"));
  34. this.username = new GuiTextField(0, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
  35. this.username.setMaxStringLength(Integer.MAX_VALUE);
  36. this.username.setFocused(true);
  37. this.password = new GuiMaskedTextField(0, this.fontRendererObj, this.width / 2 - 100, 100, 200, 20);
  38. this.password.setMaxStringLength(Integer.MAX_VALUE);
  39. }
  40.  
  41. @Override
  42. public void keyTyped(char character, int keyCode) {
  43. this.username.textboxKeyTyped(character, keyCode);
  44. this.password.textboxKeyTyped(character, keyCode);
  45. if (keyCode == 15) {
  46. this.username.setFocused(!this.username.isFocused());
  47. this.password.setFocused(!this.password.isFocused());
  48. }
  49. if (keyCode == 28) {
  50. this.actionPerformed((GuiButton)this.buttonList.get(0));
  51. }
  52. }
  53.  
  54. @Override
  55. protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
  56. super.mouseClicked(mouseX, mouseY, mouseButton);
  57. this.username.mouseClicked(mouseX, mouseY, mouseButton);
  58. this.password.mouseClicked(mouseX, mouseY, mouseButton);
  59. }
  60.  
  61. @Override
  62. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  63. this.drawDefaultBackground();
  64. GuiLogin.drawCenteredString(GuiLogin.mc.fontRendererObj, "Login", this.width / 2, 20, -1);
  65. if (this.username.getText().isEmpty()) {
  66. GuiLogin.drawString(GuiLogin.mc.fontRendererObj, "Username / E-Mail", this.width / 2 - 96, 66.0f, -7829368);
  67. }
  68. if (this.password.getText().isEmpty()) {
  69. GuiLogin.drawString(GuiLogin.mc.fontRendererObj, "Password", this.width / 2 - 96, 106.0f, -7829368);
  70. }
  71. this.username.drawTextBox();
  72. this.password.drawTextBox();
  73. GuiLogin.drawCenteredString(GuiLogin.mc.fontRendererObj, this.loginThread == null ? "Waiting" : this.loginThread.getStatus(), this.width / 2, 30, -1);
  74. GuiLogin.drawString(this.fontRendererObj, "Logged in As \u00a7c" + GuiLogin.mc.session.username, this.width / 2 - this.fontRendererObj.getStringWidth("Welcome " + GuiLogin.mc.session.username) / 2, this.height - 10, -1);
  75. super.drawScreen(mouseX, mouseY, partialTicks);
  76. }
  77.  
  78. @Override
  79. protected void actionPerformed(GuiButton button) {
  80. switch (button.id) {
  81. case 0: {
  82. if (this.username.getText().isEmpty()) break;
  83. this.loginThread = new LoginThread(this.username.getText(), this.password.getText());
  84. this.loginThread.start();
  85. break;
  86. }
  87. case 1: {
  88. mc.displayGuiScreen(this.parent);
  89. }
  90. }
  91. }
  92.  
  93. @Override
  94. public void onGuiClosed() {
  95. Keyboard.enableRepeatEvents((boolean)false);
  96. }
  97.  
  98. @Override
  99. public void updateScreen() {
  100. this.username.updateCursorCounter();
  101. this.password.updateCursorCounter();
  102. }
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. //TEXTFIELD FOR THE PASSWORT
  110. package me.lordethan.cryton.ui;
  111.  
  112. import com.google.common.base.Predicate;
  113. import com.google.common.base.Predicates;
  114. import net.minecraft.client.gui.FontRenderer;
  115. import net.minecraft.client.gui.Gui;
  116. import net.minecraft.client.gui.GuiPageButtonList;
  117. import net.minecraft.client.gui.GuiScreen;
  118. import net.minecraft.client.renderer.GlStateManager;
  119. import net.minecraft.client.renderer.Tessellator;
  120. import net.minecraft.client.renderer.WorldRenderer;
  121. import net.minecraft.util.ChatAllowedCharacters;
  122. import net.minecraft.util.MathHelper;
  123.  
  124. public class GuiMaskedTextField
  125. extends Gui {
  126. private final int field_175208_g;
  127. private final FontRenderer fontRendererInstance;
  128. public int xPosition;
  129. public int yPosition;
  130. private final int width;
  131. private final int height;
  132. private String text = "";
  133. private int maxStringLength = 32;
  134. private int cursorCounter;
  135. private boolean enableBackgroundDrawing = true;
  136. private boolean canLoseFocus = true;
  137. private boolean isFocused;
  138. private boolean isEnabled = true;
  139. private int lineScrollOffset;
  140. private int cursorPosition;
  141. private int selectionEnd;
  142. private int enabledColor = 14737632;
  143. private int disabledColor = 7368816;
  144. private boolean visible = true;
  145. private GuiPageButtonList.GuiResponder field_175210_x;
  146. private Predicate field_175209_y = Predicates.alwaysTrue();
  147. private static final String __OBFID = "CL_00000670";
  148.  
  149. public GuiMaskedTextField(int p_i45542_1_, FontRenderer p_i45542_2_, int p_i45542_3_, int p_i45542_4_, int p_i45542_5_, int p_i45542_6_) {
  150. this.field_175208_g = p_i45542_1_;
  151. this.fontRendererInstance = p_i45542_2_;
  152. this.xPosition = p_i45542_3_;
  153. this.yPosition = p_i45542_4_;
  154. this.width = p_i45542_5_;
  155. this.height = p_i45542_6_;
  156. }
  157.  
  158. public void func_175207_a(GuiPageButtonList.GuiResponder p_175207_1_) {
  159. this.field_175210_x = p_175207_1_;
  160. }
  161.  
  162. public void updateCursorCounter() {
  163. ++this.cursorCounter;
  164. }
  165.  
  166. public void setText(String p_146180_1_) {
  167. if (this.field_175209_y.apply((Object)p_146180_1_)) {
  168. this.text = p_146180_1_.length() > this.maxStringLength ? p_146180_1_.substring(0, this.maxStringLength) : p_146180_1_;
  169. this.setCursorPositionEnd();
  170. }
  171. }
  172.  
  173. public String getText() {
  174. return this.text;
  175. }
  176.  
  177. public String getSelectedText() {
  178. int var1 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
  179. int var2 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
  180. return this.text.substring(var1, var2);
  181. }
  182.  
  183. public void func_175205_a(Predicate p_175205_1_) {
  184. this.field_175209_y = p_175205_1_;
  185. }
  186.  
  187. public void writeText(String p_146191_1_) {
  188. int var8;
  189. String var2 = "";
  190. String var3 = ChatAllowedCharacters.filterAllowedCharacters(p_146191_1_);
  191. int var4 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
  192. int var5 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
  193. int var6 = this.maxStringLength - this.text.length() - (var4 - var5);
  194. boolean var7 = false;
  195. if (this.text.length() > 0) {
  196. var2 = var2 + this.text.substring(0, var4);
  197. }
  198. if (var6 < var3.length()) {
  199. var2 = var2 + var3.substring(0, var6);
  200. var8 = var6;
  201. } else {
  202. var2 = var2 + var3;
  203. var8 = var3.length();
  204. }
  205. if (this.text.length() > 0 && var5 < this.text.length()) {
  206. var2 = var2 + this.text.substring(var5);
  207. }
  208. if (this.field_175209_y.apply((Object)var2)) {
  209. this.text = var2;
  210. this.moveCursorBy(var4 - this.selectionEnd + var8);
  211. if (this.field_175210_x != null) {
  212. this.field_175210_x.func_175319_a(this.field_175208_g, this.text);
  213. }
  214. }
  215. }
  216.  
  217. public void deleteWords(int p_146177_1_) {
  218. if (this.text.length() != 0) {
  219. if (this.selectionEnd != this.cursorPosition) {
  220. this.writeText("");
  221. } else {
  222. this.deleteFromCursor(this.getNthWordFromCursor(p_146177_1_) - this.cursorPosition);
  223. }
  224. }
  225. }
  226.  
  227. public void deleteFromCursor(int p_146175_1_) {
  228. if (this.text.length() != 0) {
  229. if (this.selectionEnd != this.cursorPosition) {
  230. this.writeText("");
  231. } else {
  232. boolean var2 = p_146175_1_ < 0;
  233. int var3 = var2 ? this.cursorPosition + p_146175_1_ : this.cursorPosition;
  234. int var4 = var2 ? this.cursorPosition : this.cursorPosition + p_146175_1_;
  235. String var5 = "";
  236. if (var3 >= 0) {
  237. var5 = this.text.substring(0, var3);
  238. }
  239. if (var4 < this.text.length()) {
  240. var5 = var5 + this.text.substring(var4);
  241. }
  242. this.text = var5;
  243. if (var2) {
  244. this.moveCursorBy(p_146175_1_);
  245. }
  246. if (this.field_175210_x != null) {
  247. this.field_175210_x.func_175319_a(this.field_175208_g, this.text);
  248. }
  249. }
  250. }
  251. }
  252.  
  253. public int func_175206_d() {
  254. return this.field_175208_g;
  255. }
  256.  
  257. public int getNthWordFromCursor(int p_146187_1_) {
  258. return this.getNthWordFromPos(p_146187_1_, this.getCursorPosition());
  259. }
  260.  
  261. public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) {
  262. return this.func_146197_a(p_146183_1_, p_146183_2_, true);
  263. }
  264.  
  265. public int func_146197_a(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) {
  266. int var4 = p_146197_2_;
  267. boolean var5 = p_146197_1_ < 0;
  268. int var6 = Math.abs(p_146197_1_);
  269. for (int var7 = 0; var7 < var6; ++var7) {
  270. if (var5) {
  271. while (p_146197_3_ && var4 > 0 && this.text.charAt(var4 - 1) == ' ') {
  272. --var4;
  273. }
  274. while (var4 > 0 && this.text.charAt(var4 - 1) != ' ') {
  275. --var4;
  276. }
  277. continue;
  278. }
  279. int var8 = this.text.length();
  280. if ((var4 = this.text.indexOf(32, var4)) == -1) {
  281. var4 = var8;
  282. continue;
  283. }
  284. while (p_146197_3_ && var4 < var8 && this.text.charAt(var4) == ' ') {
  285. ++var4;
  286. }
  287. }
  288. return var4;
  289. }
  290.  
  291. public void moveCursorBy(int p_146182_1_) {
  292. this.setCursorPosition(this.selectionEnd + p_146182_1_);
  293. }
  294.  
  295. public void setCursorPosition(int p_146190_1_) {
  296. this.cursorPosition = p_146190_1_;
  297. int var2 = this.text.length();
  298. this.cursorPosition = MathHelper.clamp_int(this.cursorPosition, 0, var2);
  299. this.setSelectionPos(this.cursorPosition);
  300. }
  301.  
  302. public void setCursorPositionZero() {
  303. this.setCursorPosition(0);
  304. }
  305.  
  306. public void setCursorPositionEnd() {
  307. this.setCursorPosition(this.text.length());
  308. }
  309.  
  310. public boolean textboxKeyTyped(char p_146201_1_, int p_146201_2_) {
  311. if (!this.isFocused) {
  312. return false;
  313. }
  314. if (GuiScreen.func_175278_g(p_146201_2_)) {
  315. this.setCursorPositionEnd();
  316. this.setSelectionPos(0);
  317. return true;
  318. }
  319. if (GuiScreen.func_175280_f(p_146201_2_)) {
  320. GuiScreen.setClipboardString(this.getSelectedText());
  321. return true;
  322. }
  323. if (GuiScreen.func_175279_e(p_146201_2_)) {
  324. if (this.isEnabled) {
  325. this.writeText(GuiScreen.getClipboardString());
  326. }
  327. return true;
  328. }
  329. if (GuiScreen.func_175277_d(p_146201_2_)) {
  330. GuiScreen.setClipboardString(this.getSelectedText());
  331. if (this.isEnabled) {
  332. this.writeText("");
  333. }
  334. return true;
  335. }
  336. switch (p_146201_2_) {
  337. case 14: {
  338. if (GuiScreen.isCtrlKeyDown()) {
  339. if (this.isEnabled) {
  340. this.deleteWords(-1);
  341. }
  342. } else if (this.isEnabled) {
  343. this.deleteFromCursor(-1);
  344. }
  345. return true;
  346. }
  347. case 199: {
  348. if (GuiScreen.isShiftKeyDown()) {
  349. this.setSelectionPos(0);
  350. } else {
  351. this.setCursorPositionZero();
  352. }
  353. return true;
  354. }
  355. case 203: {
  356. if (GuiScreen.isShiftKeyDown()) {
  357. if (GuiScreen.isCtrlKeyDown()) {
  358. this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
  359. } else {
  360. this.setSelectionPos(this.getSelectionEnd() - 1);
  361. }
  362. } else if (GuiScreen.isCtrlKeyDown()) {
  363. this.setCursorPosition(this.getNthWordFromCursor(-1));
  364. } else {
  365. this.moveCursorBy(-1);
  366. }
  367. return true;
  368. }
  369. case 205: {
  370. if (GuiScreen.isShiftKeyDown()) {
  371. if (GuiScreen.isCtrlKeyDown()) {
  372. this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
  373. } else {
  374. this.setSelectionPos(this.getSelectionEnd() + 1);
  375. }
  376. } else if (GuiScreen.isCtrlKeyDown()) {
  377. this.setCursorPosition(this.getNthWordFromCursor(1));
  378. } else {
  379. this.moveCursorBy(1);
  380. }
  381. return true;
  382. }
  383. case 207: {
  384. if (GuiScreen.isShiftKeyDown()) {
  385. this.setSelectionPos(this.text.length());
  386. } else {
  387. this.setCursorPositionEnd();
  388. }
  389. return true;
  390. }
  391. case 211: {
  392. if (GuiScreen.isCtrlKeyDown()) {
  393. if (this.isEnabled) {
  394. this.deleteWords(1);
  395. }
  396. } else if (this.isEnabled) {
  397. this.deleteFromCursor(1);
  398. }
  399. return true;
  400. }
  401. }
  402. if (ChatAllowedCharacters.isAllowedCharacter(p_146201_1_)) {
  403. if (this.isEnabled) {
  404. this.writeText(Character.toString(p_146201_1_));
  405. }
  406. return true;
  407. }
  408. return false;
  409. }
  410.  
  411. public void mouseClicked(int p_146192_1_, int p_146192_2_, int p_146192_3_) {
  412. boolean var4;
  413. boolean bl = var4 = p_146192_1_ >= this.xPosition && p_146192_1_ < this.xPosition + this.width && p_146192_2_ >= this.yPosition && p_146192_2_ < this.yPosition + this.height;
  414. if (this.canLoseFocus) {
  415. this.setFocused(var4);
  416. }
  417. if (this.isFocused && var4 && p_146192_3_ == 0) {
  418. int var5 = p_146192_1_ - this.xPosition;
  419. if (this.enableBackgroundDrawing) {
  420. var5-=4;
  421. }
  422. String var6 = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
  423. this.setCursorPosition(this.fontRendererInstance.trimStringToWidth(var6, var5).length() + this.lineScrollOffset);
  424. }
  425. }
  426.  
  427. public void drawTextBox() {
  428. if (this.getVisible()) {
  429. if (this.getEnableBackgroundDrawing()) {
  430. GuiMaskedTextField.drawRect(this.xPosition - 1, this.yPosition - 1, this.xPosition + this.width + 1, this.yPosition + this.height + 1, -6250336);
  431. GuiMaskedTextField.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, -16777216);
  432. }
  433. int var1 = this.isEnabled ? this.enabledColor : this.disabledColor;
  434. int var2 = this.cursorPosition - this.lineScrollOffset;
  435. int var3 = this.selectionEnd - this.lineScrollOffset;
  436. StringBuilder sb = new StringBuilder();
  437. for (int i = 0; i < this.text.length(); ++i) {
  438. sb.append("*");
  439. }
  440. String text = sb.toString();
  441. String var4 = this.fontRendererInstance.trimStringToWidth(text.substring(this.lineScrollOffset), this.getWidth());
  442. boolean var5 = var2 >= 0 && var2 <= var4.length();
  443. boolean var6 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && var5;
  444. int var7 = this.enableBackgroundDrawing ? this.xPosition + 4 : this.xPosition;
  445. int var8 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition;
  446. int var9 = var7;
  447. if (var3 > var4.length()) {
  448. var3 = var4.length();
  449. }
  450. if (var4.length() > 0) {
  451. String var10 = var5 ? var4.substring(0, var2) : var4;
  452. var9 = this.fontRendererInstance.func_175063_a(var10, var7, var8, var1);
  453. }
  454. boolean var13 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
  455. int var11 = var9;
  456. if (!var5) {
  457. var11 = var2 > 0 ? var7 + this.width : var7;
  458. } else if (var13) {
  459. var11 = var9 - 1;
  460. --var9;
  461. }
  462. if (var4.length() > 0 && var5 && var2 < var4.length()) {
  463. var9 = this.fontRendererInstance.func_175063_a(var4.substring(var2), var9, var8, var1);
  464. }
  465. if (var6) {
  466. if (var13) {
  467. Gui.drawRect(var11, var8 - 1, var11 + 1, var8 + 1 + this.fontRendererInstance.FONT_HEIGHT, -3092272);
  468. } else {
  469. this.fontRendererInstance.func_175063_a("_", var11, var8, var1);
  470. }
  471. }
  472. if (var3 != var2) {
  473. int var12 = var7 + this.fontRendererInstance.getStringWidth(var4.substring(0, var3));
  474. this.drawCursorVertical(var11, var8 - 1, var12 - 1, var8 + 1 + this.fontRendererInstance.FONT_HEIGHT);
  475. }
  476. }
  477. }
  478.  
  479. private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) {
  480. int var5;
  481. if (p_146188_1_ < p_146188_3_) {
  482. var5 = p_146188_1_;
  483. p_146188_1_ = p_146188_3_;
  484. p_146188_3_ = var5;
  485. }
  486. if (p_146188_2_ < p_146188_4_) {
  487. var5 = p_146188_2_;
  488. p_146188_2_ = p_146188_4_;
  489. p_146188_4_ = var5;
  490. }
  491. if (p_146188_3_ > this.xPosition + this.width) {
  492. p_146188_3_ = this.xPosition + this.width;
  493. }
  494. if (p_146188_1_ > this.xPosition + this.width) {
  495. p_146188_1_ = this.xPosition + this.width;
  496. }
  497. Tessellator var7 = Tessellator.getInstance();
  498. WorldRenderer var6 = var7.getWorldRenderer();
  499. GlStateManager.color(0.0f, 0.0f, 255.0f, 255.0f);
  500. GlStateManager.func_179090_x();
  501. GlStateManager.enableColorLogic();
  502. GlStateManager.colorLogicOp(5387);
  503. var6.startDrawingQuads();
  504. var6.addVertex(p_146188_1_, p_146188_4_, 0.0);
  505. var6.addVertex(p_146188_3_, p_146188_4_, 0.0);
  506. var6.addVertex(p_146188_3_, p_146188_2_, 0.0);
  507. var6.addVertex(p_146188_1_, p_146188_2_, 0.0);
  508. var7.draw();
  509. GlStateManager.disableColorLogic();
  510. GlStateManager.func_179098_w();
  511. }
  512.  
  513. public void setMaxStringLength(int p_146203_1_) {
  514. this.maxStringLength = p_146203_1_;
  515. if (this.text.length() > p_146203_1_) {
  516. this.text = this.text.substring(0, p_146203_1_);
  517. }
  518. }
  519.  
  520. public int getMaxStringLength() {
  521. return this.maxStringLength;
  522. }
  523.  
  524. public int getCursorPosition() {
  525. return this.cursorPosition;
  526. }
  527.  
  528. public boolean getEnableBackgroundDrawing() {
  529. return this.enableBackgroundDrawing;
  530. }
  531.  
  532. public void setEnableBackgroundDrawing(boolean p_146185_1_) {
  533. this.enableBackgroundDrawing = p_146185_1_;
  534. }
  535.  
  536. public void setTextColor(int p_146193_1_) {
  537. this.enabledColor = p_146193_1_;
  538. }
  539.  
  540. public void setDisabledTextColour(int p_146204_1_) {
  541. this.disabledColor = p_146204_1_;
  542. }
  543.  
  544. public void setFocused(boolean p_146195_1_) {
  545. if (p_146195_1_ && !this.isFocused) {
  546. this.cursorCounter = 0;
  547. }
  548. this.isFocused = p_146195_1_;
  549. }
  550.  
  551. public boolean isFocused() {
  552. return this.isFocused;
  553. }
  554.  
  555. public void setEnabled(boolean p_146184_1_) {
  556. this.isEnabled = p_146184_1_;
  557. }
  558.  
  559. public int getSelectionEnd() {
  560. return this.selectionEnd;
  561. }
  562.  
  563. public int getWidth() {
  564. return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width;
  565. }
  566.  
  567. public void setSelectionPos(int p_146199_1_) {
  568. int var2 = this.text.length();
  569. if (p_146199_1_ > var2) {
  570. p_146199_1_ = var2;
  571. }
  572. if (p_146199_1_ < 0) {
  573. p_146199_1_ = 0;
  574. }
  575. this.selectionEnd = p_146199_1_;
  576. if (this.fontRendererInstance != null) {
  577. if (this.lineScrollOffset > var2) {
  578. this.lineScrollOffset = var2;
  579. }
  580. int var3 = this.getWidth();
  581. String var4 = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), var3);
  582. int var5 = var4.length() + this.lineScrollOffset;
  583. if (p_146199_1_ == this.lineScrollOffset) {
  584. this.lineScrollOffset-=this.fontRendererInstance.trimStringToWidth(this.text, var3, true).length();
  585. }
  586. if (p_146199_1_ > var5) {
  587. this.lineScrollOffset+=p_146199_1_ - var5;
  588. } else if (p_146199_1_ <= this.lineScrollOffset) {
  589. this.lineScrollOffset-=this.lineScrollOffset - p_146199_1_;
  590. }
  591. this.lineScrollOffset = MathHelper.clamp_int(this.lineScrollOffset, 0, var2);
  592. }
  593. }
  594.  
  595. public void setCanLoseFocus(boolean p_146205_1_) {
  596. this.canLoseFocus = p_146205_1_;
  597. }
  598.  
  599. public boolean getVisible() {
  600. return this.visible;
  601. }
  602.  
  603. public void setVisible(boolean p_146189_1_) {
  604. this.visible = p_146189_1_;
  605. }
  606. }
  607.  
  608.  
  609.  
  610.  
  611. /*
  612. * Decompiled with CFR 0_110.
  613. *
  614. * Could not load the following classes:
  615. * com.mojang.authlib.Agent
  616. * com.mojang.authlib.GameProfile
  617. * com.mojang.authlib.UserAuthentication
  618. * com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService
  619. * com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication
  620. */
  621. package me.lordethan.cryton.utils;
  622.  
  623. import com.mojang.authlib.Agent;
  624. import com.mojang.authlib.GameProfile;
  625. import com.mojang.authlib.UserAuthentication;
  626. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  627. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  628. import java.net.Proxy;
  629. import java.util.UUID;
  630. import me.lordethan.cryton.utils.ChatColor;
  631. import net.minecraft.client.Minecraft;
  632. import net.minecraft.util.Session;
  633.  
  634. public class LoginThread
  635. extends Thread {
  636. private final Minecraft mc = Minecraft.getMinecraft();
  637. private String status;
  638. private final String username;
  639. private final String password;
  640.  
  641. public LoginThread(String username, String password) {
  642. super("Login Thread");
  643. this.username = username;
  644. this.password = password;
  645. this.status = "Current Account :" + this.username;
  646. }
  647.  
  648. private final Session createSession(String username, String password) {
  649. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  650. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
  651. auth.setUsername(username);
  652. auth.setPassword(password);
  653. try {
  654. auth.logIn();
  655. return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
  656. }
  657. catch (Exception e) {
  658. return null;
  659. }
  660. }
  661.  
  662. public String getStatus() {
  663. return this.status;
  664. }
  665.  
  666. @Override
  667. public void run() {
  668. if (this.password.equals("")) {
  669. this.mc.session = new Session(this.username, "", "", "mojang");
  670. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. " + this.username + " - cracked";
  671. return;
  672. }
  673. this.status = (Object)((Object)ChatColor.YELLOW) + "Logging in";
  674. Session auth = this.createSession(this.username, this.password);
  675. if (auth == null) {
  676. this.status = (Object)((Object)ChatColor.RED) + "Login failed";
  677. } else {
  678. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. (" + auth.getUsername() + ")";
  679. this.mc.session = auth;
  680. }
  681. }
  682.  
  683. public void setStatus(String status) {
  684. this.status = status;
  685. }
  686. }
  687.  
  688.  
  689. package me.lordethan.cryton.utils;
  690.  
  691. import com.mojang.authlib.Agent;
  692. import com.mojang.authlib.GameProfile;
  693. import com.mojang.authlib.UserAuthentication;
  694. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  695. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  696. import java.net.Proxy;
  697. import java.util.UUID;
  698. import me.lordethan.cryton.utils.ChatColor;
  699. import net.minecraft.client.Minecraft;
  700. import net.minecraft.util.Session;
  701.  
  702. public class LoginThread
  703. extends Thread {
  704. private final Minecraft mc = Minecraft.getMinecraft();
  705. private String status;
  706. private final String username;
  707. private final String password;
  708.  
  709. public LoginThread(String username, String password) {
  710. super("Login Thread");
  711. this.username = username;
  712. this.password = password;
  713. this.status = "Current Account :" + this.username;
  714. }
  715.  
  716. private final Session createSession(String username, String password) {
  717. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  718. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
  719. auth.setUsername(username);
  720. auth.setPassword(password);
  721. try {
  722. auth.logIn();
  723. return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
  724. }
  725. catch (Exception e) {
  726. return null;
  727. }
  728. }
  729.  
  730. public String getStatus() {
  731. return this.status;
  732. }
  733.  
  734. @Override
  735. public void run() {
  736. if (this.password.equals("")) {
  737. this.mc.session = new Session(this.username, "", "", "mojang");
  738. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. " + this.username + " - cracked";
  739. return;
  740. }
  741. this.status = (Object)((Object)ChatColor.YELLOW) + "Logging in";
  742. Session auth = this.createSession(this.username, this.password);
  743. if (auth == null) {
  744. this.status = (Object)((Object)ChatColor.RED) + "Login failed";
  745. } else {
  746. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. (" + auth.getUsername() + ")";
  747. this.mc.session = auth;
  748. }
  749. }
  750.  
  751. public void setStatus(String status) {
  752. this.status = status;
  753. }
  754. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement