Guest User

Untitled

a guest
Jul 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.30 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.ArrayList;
  4. import net.minecraft.client.Minecraft;
  5. import org.lwjgl.input.Keyboard;
  6.  
  7. public class GuiConsole extends GuiScreen
  8. {
  9.     protected String message;
  10.     private int updateCounter;
  11.     public static int fcposX;
  12.     public static int fcposY;
  13.     public static int fcposZ;
  14.     public static int fcpitch;
  15.     public static int fcyaw;
  16.  
  17.     public GuiConsole()
  18.     {
  19.         message = "";
  20.         updateCounter = 0;
  21.     }
  22.  
  23.     /**
  24.      * Adds the buttons (and other controls) to the screen in question.
  25.      */
  26.     public void initGui()
  27.     {
  28.         Keyboard.enableRepeatEvents(true);
  29.     }
  30.  
  31.     /**
  32.      * Called when the screen is unloaded. Used to disable keyboard repeat events
  33.      */
  34.     public void onGuiClosed()
  35.     {
  36.         Keyboard.enableRepeatEvents(false);
  37.     }
  38.  
  39.     /**
  40.      * Called from the main game loop to update the screen.
  41.      */
  42.     public void updateScreen()
  43.     {
  44.         updateCounter++;
  45.     }
  46.  
  47.     /**
  48.      * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
  49.      */
  50.     protected void keyTyped(char c, int i)
  51.     {
  52.         if (i == 1)
  53.         {
  54.             mc.displayGuiScreen(null);
  55.             return;
  56.         }
  57.  
  58.         if (i == 28)
  59.         {
  60.             String s = message.trim();
  61.             Vars vars = new Vars();
  62.  
  63.             if (s.equals("xray"))
  64.             {
  65.                 Vars.xray = !Vars.xray;
  66.             }
  67.  
  68.             if (s.equals("fullb"))
  69.             {
  70.                 Vars.fullb = !Vars.fullb;
  71.             }
  72.  
  73.             if (s.equals("kill"))
  74.             {
  75.                 Vars.killAura = !Vars.killAura;
  76.             }
  77.  
  78.             if (s.equals("tracer"))
  79.             {
  80.                 Vars.tracer = !Vars.tracer;
  81.             }
  82.  
  83.             if (s.equals("step"))
  84.             {
  85.                 Vars.step = !Vars.step;
  86.             }
  87.  
  88.             if (s.equals("fly"))
  89.             {
  90.                 Vars.fly = !Vars.fly;
  91.             }
  92.  
  93.             if (s.startsWith("friend remove"))
  94.             {
  95.                 try
  96.                 {
  97.                     String as[] = s.split(" ");
  98.                     String s1 = as[2];
  99.  
  100.                     if (s1 != null)
  101.                     {
  102.                         if (Vars.friends.contains(s1))
  103.                         {
  104.                             Vars.friends.remove(Vars.friends.indexOf(s1));
  105.                             mc.thePlayer.addChatMessage((new StringBuilder()).append("\247b[Console]\247e Friend ").append(s1).append(" removed from the list!").toString());
  106.                         }
  107.                         else
  108.                         {
  109.                             mc.thePlayer.addChatMessage((new StringBuilder()).append("\247b[Console]\2474 Friend ").append(s1).append(" was already removed from the list.").toString());
  110.                         }
  111.                     }
  112.                 }
  113.                 catch (Exception exception)
  114.                 {
  115.                     mc.thePlayer.addChatMessage("\247b[Console]\2474 Could not remove the friend.");
  116.                 }
  117.             }
  118.  
  119.             if (s.startsWith("friend add"))
  120.             {
  121.                 try
  122.                 {
  123.                     String as1[] = s.split(" ");
  124.                     String s2 = as1[2];
  125.  
  126.                     if (s2 != null)
  127.                     {
  128.                         if (!Vars.friends.contains(s2))
  129.                         {
  130.                             Vars.friends.add(s2);
  131.                             mc.thePlayer.addChatMessage((new StringBuilder()).append("\247b[Console]\247e Friend ").append(s2).append(" added to the list!").toString());
  132.                         }
  133.                         else
  134.                         {
  135.                             mc.thePlayer.addChatMessage((new StringBuilder()).append("\247b[Console]\2474 Friend ").append(s2).append(" is already in the list.").toString());
  136.                         }
  137.                     }
  138.                 }
  139.                 catch (Exception exception1)
  140.                 {
  141.                     mc.thePlayer.addChatMessage("\247b[Console]\2474 Could not add the friend.");
  142.                 }
  143.             }
  144.  
  145.             if (s.startsWith("spawn"))
  146.             {
  147.                 try
  148.                 {
  149.                     String as2[] = s.split(" ");
  150.                     String s3 = as2[1];
  151.  
  152.                     if (s3 != null)
  153.                     {
  154.                         EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(mc.theWorld, s3);
  155.                         entityotherplayermp.setPosition(mc.thePlayer.posX, mc.thePlayer.posY - 1.5D, mc.thePlayer.posZ);
  156.                         mc.thePlayer.worldObj.spawnEntityInWorld(entityotherplayermp);
  157.                         mc.thePlayer.addChatMessage((new StringBuilder()).append("\247b[Console]\247e Spawned player: ").append(s3).append(" to your current position.").toString());
  158.                     }
  159.                 }
  160.                 catch (Exception exception2)
  161.                 {
  162.                     mc.thePlayer.addChatMessage("\247b[Console]\2474 Could not spawn player, try again.");
  163.                 }
  164.             }
  165.  
  166.             if (s.toLowerCase().startsWith("freecam"))
  167.             {
  168.                 Vars.freecam = !Vars.freecam;
  169.  
  170.                 if (Vars.freecam)
  171.                 {
  172.                     fcposX = (int)mc.thePlayer.posX;
  173.                     fcposY = (int)mc.thePlayer.posY;
  174.                     fcposZ = (int)mc.thePlayer.posZ;
  175.                     fcpitch = (int)mc.thePlayer.rotationPitch;
  176.                     fcyaw = (int)mc.thePlayer.rotationYaw;
  177.                     mc.thePlayer.addChatMessage((new StringBuilder()).append("Freecam enabled [Saved pos X: ").append(fcposX).append(", Y: ").append(fcposY).append(", Z: ").append(fcposZ).append("]").toString());
  178.                 }
  179.                 else
  180.                 {
  181.                     mc.thePlayer.setPositionAndRotation(fcposX, fcposY, fcposZ, fcpitch, fcyaw);
  182.                     mc.thePlayer.addChatMessage("Freecam disabled, returned to previous location");
  183.                 }
  184.             }
  185.  
  186.             mc.displayGuiScreen(null);
  187.             return;
  188.         }
  189.  
  190.         if (i == 14 && message.length() > 0)
  191.         {
  192.             message = message.substring(0, message.length() - 1);
  193.         }
  194.  
  195.         if (!(!ChatAllowedCharacters.isAllowedCharacter(c) || message.length() >= 100));
  196.         message += c;
  197.     }
  198.  
  199.     /**
  200.      * Draws the screen and all the components in it.
  201.      */
  202.     public void drawScreen(int i, int j, float f)
  203.     {
  204.         drawBorderedRect(2, height - 13, width - 2, height - 2, 1, 0xff000000, 0x80000000);
  205.         int k = height - 24;
  206.  
  207.         for (int l = 0; l < Vars.consoleText.length; l++)
  208.         {
  209.             if (!Vars.consoleText[l].startsWith(message))
  210.             {
  211.                 continue;
  212.             }
  213.  
  214.             String s = Vars.consoleText[l];
  215.  
  216.             if (message.length() > 0)
  217.             {
  218.                 drawBorderedRect(2, k - 2, width - 2, k + 10, 1, 0xff000000, 0x80000000);
  219.                 drawString(fontRenderer, s, 4, k, 0xffffff);
  220.             }
  221.  
  222.             k -= 14;
  223.         }
  224.  
  225.         drawString(fontRenderer, (new StringBuilder()).append("[CONSOLE]>").append(message).append((updateCounter / 6) % 2 == 0 ? "_" : "").toString(), 4, height - 11, 0xe0e0e0);
  226.         super.drawScreen(i, j, f);
  227.     }
  228.  
  229.     public void drawBorderedRect(int i, int j, int k, int l, int i1, int j1, int k1)
  230.     {
  231.         drawRect(i + i1, j + i1, k - i1, l - i1, k1);
  232.         drawRect(i + i1, j + i1, k, j, j1);
  233.         drawRect(i, j, i + i1, l, j1);
  234.         drawRect(k, l, k - i1, j + i1, j1);
  235.         drawRect(i, l - i1, k, l, j1);
  236.     }
  237.  
  238.     /**
  239.      * Called when the mouse is clicked.
  240.      */
  241.     protected void mouseClicked(int i, int j, int k)
  242.     {
  243.         if (k != 0)
  244.         {
  245.             return;
  246.         }
  247.  
  248.         if (mc.ingameGUI.field_933_a == null)
  249.         {
  250.             super.mouseClicked(i, j, k);
  251.             return;
  252.         }
  253.  
  254.         if (!(message.length() <= 0 || message.endsWith(" " ))) message += " ";
  255.         message += mc.ingameGUI.field_933_a;
  256.         byte byte0 = 100;
  257.  
  258.         if (message.length() > byte0)
  259.         {
  260.             message = message.substring(0, byte0);
  261.         }
  262.  
  263.         return;
  264.     }
  265. }
Add Comment
Please, Sign In to add comment