Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. package me.uselessness.namechange.screen;
  2.  
  3. import net.minecraft.client.*;
  4. import net.minecraft.client.gui.*;
  5. import net.minecraft.util.*;
  6. import net.minecraft.client.multiplayer.*;
  7. import java.lang.reflect.*;
  8.  
  9.  
  10. public class ChangeScreen extends GuiScreen
  11. {
  12. private GuiTextField hack;
  13. private ServerData server;
  14.  
  15. public void initGui() {
  16. this.server = this.mc.getCurrentServerData();
  17. (this.hack = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, this.width / 2 - 110, this.height / 2 - 10, 220, 20)).setMaxStringLength(500);
  18. }
  19.  
  20. public boolean doesGuiPauseGame() {
  21. return false;
  22. }
  23.  
  24. public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
  25. this.drawDefaultBackground();
  26. this.drawCenteredString(this.mc.fontRendererObj, "Name Change Mod by Lemon, ported by Uselessness", this.width / 2, this.height / 2 - 40, -1);
  27. this.drawCenteredString(this.mc.fontRendererObj, "Type a name then press enter key", this.width / 2, this.height / 2 - 30, -1);
  28. this.drawCenteredString(this.mc.fontRendererObj, "(Most servers only allow case changes)", this.width / 2, this.height / 2 - 20, -1);
  29. this.hack.drawTextBox();
  30. this.hack.setFocused(true);
  31. }
  32.  
  33. public void updateScreen() {
  34. this.hack.updateCursorCounter();
  35. }
  36.  
  37. public void keyTyped(final char typedChar, final int key) {
  38. if (key == 28) {
  39. final Session s = this.mc.getSession();
  40. if (!StringUtils.isNullOrEmpty(this.hack.getText())) {
  41. this.mc.theWorld.sendQuittingDisconnectingPacket();
  42. this.mc.loadWorld((WorldClient)null);
  43. this.mc.displayGuiScreen((GuiScreen)new GuiMainMenu());
  44. this.mc.session = new Session(this.hack.getText(), s.getPlayerID(), s.getToken(), s.getSessionType().name().toLowerCase());
  45. this.mc.displayGuiScreen((GuiScreen)new GuiConnecting((GuiScreen)this, this.mc, this.server));
  46. }
  47. }
  48. else {
  49. this.hack.textboxKeyTyped(typedChar, key);
  50. }
  51. if (key == 1) {
  52. this.mc.displayGuiScreen((GuiScreen)null);
  53. }
  54. }
  55.  
  56. public class ReflectionUtil
  57. {
  58. public Field getField(final Class clazz, final String fieldName) throws NoSuchFieldException {
  59. try {
  60. return clazz.getDeclaredField(fieldName);
  61. }
  62. catch (NoSuchFieldException e) {
  63. final Class superClass = clazz.getSuperclass();
  64. if (superClass == null) {
  65. throw e;
  66. }
  67. return this.getField(superClass, fieldName);
  68. }
  69. }
  70.  
  71. public void makeAccessible(final Field field) {
  72. if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) {
  73. field.setAccessible(true);
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement