You are viewing our Forum Archives. To view or take place in current topics click here.
[TUT] How To Make a Console + Use it With a Jump Hack!
Posted:

[TUT] How To Make a Console + Use it With a Jump Hack!Posted:

SC_Lotso
  • Powerhouse
Status: Offline
Joined: Mar 22, 200915Year Member
Posts: 456
Reputation Power: 19
Status: Offline
Joined: Mar 22, 200915Year Member
Posts: 456
Reputation Power: 19
Hello TTG,
As a coder myself I felt I should contribute to the modding community a bit more. So here's my first tutorial, this will teach you how to make a console and use it to make a adjustable jump hack!

What You Will Need
  • A standard brain
  • A bit of previous coding experience (Not much)
  • The Java JDK


Difficulty
This is reasonably simple for the average coder who has had a bit of previous experience.
5/10

For the tutorial I will assume you have MCP and the Java JDK installed. I will not explain those steps!

Step 1
Copy and paste GuiChat.java and rename the new file whatever you want. I recommend the name GuiConsole.java
If you right click the .java it comes up with the copy and paste options. Simple!

Step 2
Find this section of code;
if(!mc.lineIsCommand(s1))
                {
                    mc.thePlayer.sendChatMessage(s1);
                }

It is located in the keyTyped void/method. Remove the above section of code. This will mean that the message will not be sent to the rest of the server. The code above simply meant if the message is not a command send it to the server. You do not want other players to see the console use!

Step 3
We will now move the console to the top and change the text before the message. By default it is at the bottom and before the text appears is a > sign. We will position it add the top and before the text will appear the text 'Console -'. To do this we will find the drawScreen void/method.
Find this piece of code;
public void drawScreen(int i, int j, float f)
     {
   drawRect(2, height - 14, width - 2, height - 2, 0x800);
   drawString(fontRenderer, (new StringBuilder()).append("> ").append(message).append((updateCounter / 6) % 2 != 0 ? "" : "_").toString(), 4, height - 12, 0xe0e0e0);
   super.drawScreen(i, j, f);
     }

To place it at the top, chang the first line to say;
drawRect(2, 2, width -2, height -2

This will position the rect draw at the top.
Then find the code which contains the '>' and change it to 'Console - '. This part is up to you!

Step 4
Now we will add the part of the hack which identifies the command and argument(args).
Find this piece of code;
String s1 = message.trim();

Below that piece of code we want to add a try and catch statement to try all the possible commands then catch the exception if it is not found.
To do this we need to add;

try //Try the following
{
    if(s1.startsWith("jump")) //If s1(the message) starts with 'jump'
    {
        string args[] = s1.split(" ") //The string args[](Arguments) is the string of text after the ' ' in s1. You can change this to an equals if you want.
        GuiIngame.jumpControl = Float.parseFloat(args[1]); //The float is equal to args[1]
    }
}
catch(Exception exception3) //If none of these work catch the exception
{ //Do nothing
} //Do nothing again

The comments explain what the code means, read them please.

Step 5
You now need to create the float. We will do this in GuiIngame.java, the file the toggles will be in.
Put this piece of code in at the top;
public static float jumpControl = 3;


Step 6
Now we will create the toggle, I will be using the checkKey method (Explained in the first steps on a tutorial on HF.)
Use this piece of code;
if(checkKey(Keyboard.KEY_J)) //If J is pressed then...
{
    hackJump = !hackJump //Toggle the hack boolean.
}


Step 7
We will now create the boolean. At the top of GuiIngame put this piece of code;
public static boolean hackJump = false;


Step 8
Now navigate to the file EntityLiving.java. Once you have found that file search for the phrase 'jump' until you come to the 'protected void jump()'
Change this to say;
 protected void jump()
    {
        if(GuiIngame.hackJump) //If true then....
        {
           motionY = 0.41999998688697815D * GuiIngame.jumpControl; //The jump height ultiplied by the float
        } else //Or else
        {
           motionY = 0.41999998688697815D; //Normals stuffs
            if(isPotionActive(Potion.potionJump))
            {
                motionY += (float)(getActivePotionEffect(Potion.potionJump).getAmplifier() + 1) * 0.1F;
            }
            if(isSprinting())
            {
                float f = rotationYaw * 0.01745329F;
                motionX -= MathHelper.sin(f) * 0.2F;
                motionZ += MathHelper.cos(f) * 0.2F;
            }
            isAirBorne = true;
        }
    }

Check the comments again!

Thanks for reading this far, and problems just comment. I worked hard on this thread so a thank or rep would be appreciated.
MSC
#2. Posted:
smply
  • Resident Elite
Status: Offline
Joined: Nov 29, 201112Year Member
Posts: 275
Reputation Power: 12
Status: Offline
Joined: Nov 29, 201112Year Member
Posts: 275
Reputation Power: 12
Good Tutorial Man Helps A Lot

#smply
#3. Posted:
-Afro-
  • TTG Addict
Status: Offline
Joined: Aug 11, 201112Year Member
Posts: 2,028
Reputation Power: 111
Status: Offline
Joined: Aug 11, 201112Year Member
Posts: 2,028
Reputation Power: 111
Okay tutorial.

Nothing special.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.