Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.puja.gui.altman;
- import java.io.IOException;
- import java.net.Proxy;
- import com.mojang.authlib.Agent;
- import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
- import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiMainMenu;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.gui.GuiTextField;
- import net.minecraft.util.Session;
- public class AltLogin extends GuiScreen {
- public GuiTextField email;
- public GuiTextField passw;
- @Override
- public void initGui() {
- email = new GuiTextField(2, mc.fontRendererObj, width / 2 - 100, height / 4 + 30, 200, 20);
- passw = new GuiTextField(3, mc.fontRendererObj, width / 2 - 100, height / 4 + 90, 200, 20);
- }
- @Override
- public void updateScreen() {
- email.updateCursorCounter();
- passw.updateCursorCounter();
- }
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- email.mouseClicked(mouseX, mouseY, mouseButton);
- passw.mouseClicked(mouseX, mouseY, mouseButton);
- try {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- } catch(Exception e) {
- }
- }
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- email.textboxKeyTyped(typedChar, keyCode);
- passw.textboxKeyTyped(typedChar, keyCode);
- if(typedChar == '\t') {
- if(email.isFocused()) {
- email.setFocused(false);
- passw.setFocused(true);
- } else {
- email.setFocused(true);
- passw.setFocused(false);
- }
- }
- if(typedChar == '\r') {
- actionPerformed((GuiButton)buttonList.get(0));
- }
- }
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- drawDefaultBackground();
- email.drawTextBox();
- passw.drawTextBox();
- drawString(fontRendererObj, "Email/Username:", width / 2 - 100, height / 4 + 20, 0xFFFFFFFF);
- drawString(fontRendererObj, "Password:", width / 2 - 100, height / 4 + 80, 0xFFFFFFFF);
- buttonList.add(new GuiButton(0, width / 2 - 100, 250, "Login"));
- buttonList.add(new GuiButton(1, width / 2 - 100, 270, "Back"));
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
- @Override
- protected void actionPerformed(GuiButton button) throws IOException {
- if(button.id == 1) {
- mc.displayGuiScreen(new GuiMainMenu());
- }
- if(button.id == 0) {
- if(passw.getText().isEmpty()) {
- if(!email.getText().isEmpty()) {
- mc.session = new Session(email.getText().trim(), "-", "-", "Legacy");
- }
- } else {
- if(!email.getText().isEmpty()) {
- YggdrasilUserAuthentication g = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "").createUserAuthentication(Agent.MINECRAFT);
- g.setUsername(email.getText().trim());
- g.setPassword(passw.getText().trim());
- try {
- g.logIn();
- mc.session = new Session(g.getSelectedProfile().getName(), g.getSelectedProfile().getId().toString(), g.getAuthenticatedToken(), "mojang");
- } catch(Exception e) {
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement