Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. package fr.Vekorax.macro;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.BufferedWriter;
  5. import java.io.File;
  6. import java.io.FileInputStream;
  7. import java.io.FileNotFoundException;
  8. import java.io.FileWriter;
  9. import java.io.IOException;
  10. import java.io.InputStream;
  11. import java.io.InputStreamReader;
  12. import java.io.UnsupportedEncodingException;
  13. import java.util.List;
  14. import net.minecraft.client.Minecraft;
  15. import net.minecraft.client.gui.GuiButton;
  16. import net.minecraft.client.gui.GuiScreen;
  17. import net.minecraft.client.gui.GuiTextField;
  18. import net.minecraft.client.resources.I18n;
  19. import net.minecraft.util.EnumChatFormatting;
  20. import org.lwjgl.input.Keyboard;
  21.  
  22. public class GUIMacroCustom
  23. extends GuiScreen
  24. {
  25. private GuiTextField textc1;
  26. private GuiTextField textc2;
  27. private GuiTextField textc3;
  28. private GuiButton c1;
  29. private GuiButton c2;
  30. private GuiButton c3;
  31. private GuiButton save;
  32. private GuiButton leave;
  33. private GuiScreen lastGui;
  34. private String m = "c1";
  35. private int nb = 0;
  36. private String info;
  37. private String info2;
  38. private String Macro1;
  39. private String Macro2;
  40. private String Macro3;
  41. private File saveFile;
  42. private static final String UTF8 = "UTF-8";
  43.  
  44. public GUIMacroCustom(GuiScreen gui)
  45. {
  46. this.info = (EnumChatFormatting.GOLD + "Vous n'avez pas besoin de rajoutez le " + EnumChatFormatting.RED + "/ " + EnumChatFormatting.GOLD + "!");
  47. this.lastGui = gui;
  48. }
  49.  
  50. public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
  51. {
  52. drawDefaultBackground();
  53. this.textc1.drawTextBox();
  54. this.textc2.drawTextBox();
  55. this.textc3.drawTextBox();
  56.  
  57. drawString(this.fontRendererObj, this.info2, width / 2 - 160, height / 2 - 50, 16777215);
  58. drawString(this.fontRendererObj, this.info, width / 2 - 100, height / 2 - 94, 16777215);
  59. drawString(this.fontRendererObj, this.Macro1, width / 2 - 150, height / 2 - 15, 16777215);
  60. drawString(this.fontRendererObj, this.Macro2, width / 2 - 42, height / 2 - 15, 16777215);
  61. drawString(this.fontRendererObj, this.Macro3, width / 2 + 63, height / 2 - 15, 16777215);
  62. super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
  63. this.Macro1 = "MacroCustom 1";
  64. this.Macro2 = "MacroCustom 2";
  65. this.Macro3 = "MacroCustom 3";
  66. }
  67.  
  68. public void onGuiClosed()
  69. {
  70. Keyboard.enableRepeatEvents(false);
  71. }
  72.  
  73. public void initGui()
  74. {
  75. Keyboard.enableRepeatEvents(true);
  76. this.buttonList.clear();
  77. this.textc1 = new GuiTextField(this.fontRendererObj, width / 2 - 155, height / 2, 100, 20);
  78. ////MACRO 1 ////
  79. FileInputStream var111 = null;
  80. try {
  81. var111 = new FileInputStream(Minecraft.Macro1);
  82. } catch (FileNotFoundException e1) {
  83. e1.printStackTrace();
  84. }
  85. BufferedReader var112 = new BufferedReader(new InputStreamReader(var111));
  86. String var113 = null;
  87. try {
  88. var113 = var112.readLine();
  89. } catch (IOException e) {
  90. e.printStackTrace();
  91. }
  92. this.textc1.setFocused(true);
  93. this.textc1.setText(var113);
  94. //this.textc1.func_146203_f(32767);
  95. this.textc2 = new GuiTextField(this.fontRendererObj, width / 2 - 50, height / 2, 100, 20);
  96. ////MACRO 2 ////
  97. FileInputStream var114 = null;
  98. try {
  99. var114 = new FileInputStream(Minecraft.Macro2);
  100. } catch (FileNotFoundException e1) {
  101. e1.printStackTrace();
  102. }
  103. BufferedReader var115 = new BufferedReader(new InputStreamReader(var114));
  104. String var116 = null;
  105. try {
  106. var116 = var115.readLine();
  107.  
  108. } catch (IOException e) {
  109. e.printStackTrace();
  110. }
  111. this.textc2.setText(var116);
  112. //this.textc2.func_146203_f(32767);
  113. this.textc2.setFocused(true);
  114.  
  115. this.textc3 = new GuiTextField(this.fontRendererObj, width / 2 + 55, height / 2, 100, 20);
  116. //// MACRO 3 ////
  117. FileInputStream var117 = null;
  118. try {
  119. var117 = new FileInputStream(Minecraft.Macro3);
  120. } catch (FileNotFoundException e3) {
  121. e3.printStackTrace();
  122. }
  123. BufferedReader var118 = new BufferedReader(new InputStreamReader(var117));
  124. String var119 = null;
  125. try {
  126. var119 = var118.readLine();
  127. } catch (IOException e) {
  128. e.printStackTrace();
  129. }
  130. this.textc3.setText(var119);
  131. //this.textc3.func_146203_f(32767);
  132. this.textc3.setFocused(true);
  133. this.buttonList.add(new GuiButton(3, width / 2, height / 2 + 50, 98, 20, I18n.format(EnumChatFormatting.RED + "Sauvegarder!", new Object[0])));
  134. this.buttonList.add(new GuiButton(4, width / 2 - 100, height / 2 + 50, 98, 20, I18n.format(EnumChatFormatting.RED + "Retour", new Object[0])));
  135. }
  136.  
  137. public void mouseClicked(int i, int j, int k)
  138. {
  139. super.mouseClicked(i, j, k);
  140. this.textc1.mouseClicked(i, j, k);
  141. this.textc2.mouseClicked(i, j, k);
  142. this.textc3.mouseClicked(i, j, k);
  143. }
  144.  
  145. protected void keyTyped(char c, int i)
  146. {
  147. if (c != '/') {
  148. if (this.textc1.isFocused()) {
  149. this.textc1.textboxKeyTyped(c, i);
  150. } else if (this.textc2.isFocused()) {
  151. this.textc2.textboxKeyTyped(c, i);
  152. } else if (this.textc3.isFocused()) {
  153. this.textc3.textboxKeyTyped(c, i);
  154. }
  155. }
  156. }
  157.  
  158. protected void actionPerformed(GuiButton b)
  159. {
  160. switch (b.id)
  161. {
  162. case 3:
  163. if ((this.textc1.getText().isEmpty()) && (this.textc2.getText().isEmpty()) && (this.textc3.getText().isEmpty())) {
  164. this.info2 = "�2�3Erreur, veuillez rentrez les commandes voulu pour vos macros...";
  165. } else {
  166. try
  167. {
  168. this.mc.displayGuiScreen(this.lastGui);
  169. if ((!this.textc1.getText().isEmpty())) {
  170. FileWriter e1 = new FileWriter(Minecraft.Macro1);
  171. BufferedWriter bw1 = new BufferedWriter(e1);
  172. bw1.write(this.textc1.getText());
  173. bw1.close();
  174. }
  175. if ((!this.textc2.getText().isEmpty())) {
  176. FileWriter e2 = new FileWriter(Minecraft.Macro2);
  177. BufferedWriter bw2 = new BufferedWriter(e2);
  178. bw2.write(this.textc2.getText());
  179. bw2.close();
  180. }
  181. if ((!this.textc3.getText().isEmpty())) {
  182. FileWriter e3 = new FileWriter(Minecraft.Macro3);
  183. BufferedWriter bw3 = new BufferedWriter(e3);
  184. bw3.write(this.textc3.getText());
  185. bw3.close();
  186. }
  187. }
  188. catch (IOException var4)
  189. {
  190. var4.printStackTrace();
  191. }
  192. }
  193. break;
  194. case 4:
  195. this.mc.displayGuiScreen(this.lastGui);
  196. }
  197. }
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement