Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.uselessness.namechange.screen;
- import net.minecraft.client.*;
- import net.minecraft.client.gui.*;
- import net.minecraft.util.*;
- import net.minecraft.client.multiplayer.*;
- import java.lang.reflect.*;
- public class ChangeScreen extends GuiScreen
- {
- private GuiTextField hack;
- private ServerData server;
- public void initGui() {
- this.server = this.mc.getCurrentServerData();
- (this.hack = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, this.width / 2 - 110, this.height / 2 - 10, 220, 20)).setMaxStringLength(500);
- }
- public boolean doesGuiPauseGame() {
- return false;
- }
- public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
- this.drawDefaultBackground();
- this.drawCenteredString(this.mc.fontRendererObj, "Name Change Mod by Lemon, ported by Uselessness", this.width / 2, this.height / 2 - 40, -1);
- this.drawCenteredString(this.mc.fontRendererObj, "Type a name then press enter key", this.width / 2, this.height / 2 - 30, -1);
- this.drawCenteredString(this.mc.fontRendererObj, "(Most servers only allow case changes)", this.width / 2, this.height / 2 - 20, -1);
- this.hack.drawTextBox();
- this.hack.setFocused(true);
- }
- public void updateScreen() {
- this.hack.updateCursorCounter();
- }
- public void keyTyped(final char typedChar, final int key) {
- if (key == 28) {
- final Session s = this.mc.getSession();
- if (!StringUtils.isNullOrEmpty(this.hack.getText())) {
- this.mc.theWorld.sendQuittingDisconnectingPacket();
- this.mc.loadWorld((WorldClient)null);
- this.mc.displayGuiScreen((GuiScreen)new GuiMainMenu());
- this.mc.session = new Session(this.hack.getText(), s.getPlayerID(), s.getToken(), s.getSessionType().name().toLowerCase());
- this.mc.displayGuiScreen((GuiScreen)new GuiConnecting((GuiScreen)this, this.mc, this.server));
- }
- }
- else {
- this.hack.textboxKeyTyped(typedChar, key);
- }
- if (key == 1) {
- this.mc.displayGuiScreen((GuiScreen)null);
- }
- }
- public class ReflectionUtil
- {
- public Field getField(final Class clazz, final String fieldName) throws NoSuchFieldException {
- try {
- return clazz.getDeclaredField(fieldName);
- }
- catch (NoSuchFieldException e) {
- final Class superClass = clazz.getSuperclass();
- if (superClass == null) {
- throw e;
- }
- return this.getField(superClass, fieldName);
- }
- }
- public void makeAccessible(final Field field) {
- if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) {
- field.setAccessible(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement