Creating a Gui / Base(Non-OOP) Without Touching GuiIngame
Most beginners have their clients coded mostly in GuiIngame at first. However, this is frowned upon. So here's a way to get around that while creating a manageable base.
If you're reading this, I assume you have MCP and Eclipse set up and running. So now, lets start.
Step 1: Create a few new packages. These will make updates a breeze. More on that later though.
Step 2: In com.example create the following classes. We will code these later. First, to call the files to start our client.
Step 3: Open Minecraft.java and EntityRenderer.java
import com.example.Variables ;
import com.example.ExampleLoader;
import com.example.gui.*;
import com.example.hacks.*;
//Find public GuiIngame ingameGUI; and then add this below:
public ExampleLoader el;
//Then find this.ingameGUI = new GuiIngame(this); and add this below:
this.el = new ExampleLoader(this);
import com.example.Variables ;
import com.example.ExampleLoader;
import com.example.gui.*;
import com.example.hacks.*;
//Find this if statement that declares the InGame gui render method. We will now add a new method.
//if (!this.mc.gameSettings.hideGUI || this.mc.currentScreen != null)
//{
//this.mc.ingameGUI.renderGameOverlay(par1, this.mc.currentScreen != null, var18, var20);
//Note the ExampleLoader's method is called. It's the same place in guiInggame that beginners modify. You can change the name but keep the constructor the same.
this.mc.el.renderGameOverlay(par1, this.mc.currentScreen != null, var18, var20);
Step 4: Now that our Loader is called, we can start coding in the files we made.
Step 5: Now that we have our base package complete, we'll move on to the Gui. Add these in com.example.gui
First create a utility class for the gui methods.
Now to draw our Gui. Handler called it before by calling the class's main method.
Step 6: We already called the fly() method in the class Fly. So now lets add that.
In com.example.hacks, add Fly.java
Done. How many base files have we touched? 2
You can build upon this to become less source file dependant. However, things such as Xray still require hard coding if you don't know extensive java skills.
If you're reading this, I assume you have MCP and Eclipse set up and running. So now, lets start.
Step 1: Create a few new packages. These will make updates a breeze. More on that later though.
- com.example
- com.example.hacks
- com.example.gui
Step 2: In com.example create the following classes. We will code these later. First, to call the files to start our client.
- CheckKeys (The normal checkkeys most people use)
- Variables (The class containing your booleans and such)
- Handler
- HackHandler
- ExampleKeys
- ExampleLoader
Step 3: Open Minecraft.java and EntityRenderer.java
In Minecraft
import com.example.Variables ;
import com.example.ExampleLoader;
import com.example.gui.*;
import com.example.hacks.*;
//Find public GuiIngame ingameGUI; and then add this below:
public ExampleLoader el;
//Then find this.ingameGUI = new GuiIngame(this); and add this below:
this.el = new ExampleLoader(this);
In EntityRenderer
import com.example.Variables ;
import com.example.ExampleLoader;
import com.example.gui.*;
import com.example.hacks.*;
//Find this if statement that declares the InGame gui render method. We will now add a new method.
//if (!this.mc.gameSettings.hideGUI || this.mc.currentScreen != null)
//{
//this.mc.ingameGUI.renderGameOverlay(par1, this.mc.currentScreen != null, var18, var20);
//Note the ExampleLoader's method is called. It's the same place in guiInggame that beginners modify. You can change the name but keep the constructor the same.
this.mc.el.renderGameOverlay(par1, this.mc.currentScreen != null, var18, var20);
Step 4: Now that our Loader is called, we can start coding in the files we made.
ExampleLoader
Code:
package com.example;
import java.awt.Color;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
public class ExampleLoader extends Gui
{
public static Minecraft mc = Minecraft.getMinecraft();
private Handler h;
public ExampleLoader (Minecraft par1Minecraft)
{
this.mc = par1Minecraft;
h = new Loader (mc);
}
public void renderGameOverlay(float par1, boolean par2, int par3, int par4)
{
FontRenderer var8 = this.mc.fontRenderer;
if(!mc.gameSettings.showDebugInfo )
{
h.drawGui(var8);
}
h.hh.CheckUpdate();
h.Keys.checkKeys();
}
}
CheckKeys
Code:
package com.example;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
public class CheckKeys
{
private Minecraft mc;
private boolean keyStates[] = new boolean[ 256 ];
public CheckKeys( Minecraft minecraft )
{
mc = minecraft;
}
public boolean checkKey( int i )
{
if ( mc.currentScreen != null )
{
return false;
}
if ( Keyboard.isKeyDown( i ) != keyStates [ i ] )
{
return keyStates [ i ] = !keyStates [ i ];
}
else
{
return false;
}
}
}
Variables
Code:
//Put in your generic hacks
Handler
Code:
package com.example;
import com.example.gui.ExampleGui;
import com.example.HackHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.src.FontRenderer;
public class Handler
{
public Keys ExampleKeys;
public static HackHandler hh;
public ExampleGui gui;
public Minecraft mc;
public Variables v;
public FontRenderer fr;
public Handler(Minecraft mc)
{
Keys = new ExampleKeys(mc, this);
}
public void drawGui(FontRenderer fr)
{
gui = new ExampleGui ();
}
public static void update(Minecraft minecraft)
{
hh = new HackHandler();
}
}
HackHandler
Code:
package com.example;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
import com.example.*;
import com.example.hacks.*;
public class HackHandler
{
public static Minecraft mc = Minecraft.getMinecraft();
public static Variables v;
public HackHandler()
{
}
public static void CheckUpdate()
{
//Just one example. But if your game crashes while activating a hack add " if(mc.inGameHasFocus) " around it. That usually fixes it if it's the calling that crashes your client
if(v.fly)
{
Fly.fly();
}
}
}
ExampleKeys
Code:
package com.example;
import org.lwjgl.input.Keyboard;
import com.example.*;
import com.example.gui.*;
import com.example.hacks.*;
import net.minecraft.client.Minecraft;
import net.minecraft.src.FontRenderer;
public class ExampleKeys
{
public static Minecraft mc = Minecraft.getMinecraft();
public CheckKeys ck;
private boolean keyStates[];
public ExampleKeys (Minecraft minecraft, Handler handler)
{
keyStates = new boolean[256];
ck = new CheckKeys( mc );
mc = Minecraft.getMinecraft();
}
public void checkKeys() //Each key is it's own void. I won't be making each one since they're pratically all the same. Just put in toggles or such in each one like you normally would
{
if (ck.checkKey(Keyboard.KEY_ESCAPE)) {KeyEscape();}
if (ck.checkKey(Keyboard.KEY_UP)) { KeyUp();}
if (ck.checkKey(Keyboard.KEY_DOWN)) { KeyDown();}
if (ck.checkKey(Keyboard.KEY_Z)) { pKeyZ();}
if (ck.checkKey(Keyboard.KEY_X)) { pKeyX();}
if (ck.checkKey(Keyboard.KEY_C)) { pKeyC();}
if (ck.checkKey(Keyboard.KEY_V)) { pKeyV();}
if (ck.checkKey(Keyboard.KEY_B)) { pKeyB();}
if (ck.checkKey(Keyboard.KEY_N)) { pKeyN();}
if (ck.checkKey(Keyboard.KEY_M)) { pKeyM();}
if (ck.checkKey(Keyboard.KEY_F)) { pKeyF();}
if (ck.checkKey(Keyboard.KEY_G)) { pKeyG();}
if (ck.checkKey(Keyboard.KEY_H)) { pKeyH();}
if (ck.checkKey(Keyboard.KEY_J)) { pKeyJ();}
if (ck.checkKey(Keyboard.KEY_K)) { pKeyK();}
if (ck.checkKey(Keyboard.KEY_L)) { pKeyL();}
if (ck.checkKey(Keyboard.KEY_R)) { pKeyR();}
if (ck.checkKey(Keyboard.KEY_Y)) { pKeyY();}
if (ck.checkKey(Keyboard.KEY_U)) { pKeyU();}
if (ck.checkKey(Keyboard.KEY_I)) { pKeyI();}
if (ck.checkKey(Keyboard.KEY_O)) { pKeyO();}
if (ck.checkKey(Keyboard.KEY_P)) { pKeyP();}
}
private void pKeyF()
{
Variables.fly = !Variables.fly;
}
}
Step 5: Now that we have our base package complete, we'll move on to the Gui. Add these in com.example.gui
First create a utility class for the gui methods.
Util
Code:
package com.example.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Entity;
import net.minecraft.src.FontRenderer;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.ScaledResolution;
import net.minecraft.src.Tessellator;
import org.lwjgl.opengl.GL11;
public class Util
{
public static Minecraft mc = Minecraft.getMinecraft();
protected static float zLevel = 0.0F;
public static int getWidth( )
{
ScaledResolution sr = new ScaledResolution( mc.gameSettings, mc.displayWidth, mc.displayHeight );
return sr.getScaledWidth( );
}
public static int getHeight( )
{
ScaledResolution sr = new ScaledResolution( mc.gameSettings, mc.displayWidth, mc.displayHeight );
return sr.getScaledHeight( );
}
protected static void drawHorizontalLine(int par1, int par2, int par3, int par4)
{
if (par2 < par1)
{
int var5 = par1;
par1 = par2;
par2 = var5;
}
drawRect(par1, par3, par2 + 1, par3 + 1, par4);
}
protected static void drawVerticalLine(int par1, int par2, int par3, int par4)
{
if (par3 < par2)
{
int var5 = par2;
par2 = par3;
par3 = var5;
}
drawRect(par1, par2 + 1, par1 + 1, par3, par4);
}
public static void drawRect(int par0, int par1, int par2, int par3, int par4)
{
int var5;
if (par0 < par2)
{
var5 = par0;
par0 = par2;
par2 = var5;
}
if (par1 < par3)
{
var5 = par1;
par1 = par3;
par3 = var5;
}
float var10 = (float)(par4 >> 24 & 255) / 255.0F;
float var6 = (float)(par4 >> 16 & 255) / 255.0F;
float var7 = (float)(par4 >> 8 & 255) / 255.0F;
float var8 = (float)(par4 & 255) / 255.0F;
Tessellator var9 = Tessellator.instance;
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(var6, var7, var8, var10);
var9.startDrawingQuads();
var9.addVertex((double)par0, (double)par3, 0.0D);
var9.addVertex((double)par2, (double)par3, 0.0D);
var9.addVertex((double)par2, (double)par1, 0.0D);
var9.addVertex((double)par0, (double)par1, 0.0D);
var9.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
public static void drawOutlinedRect(int par1, int par2, int par3, int par4, int par5, int par6, int color)
{
drawGradientRect(par1, par2, par3, par4, par5, par6);
drawHorizontalLine(par1, par3, par4, color);
drawHorizontalLine(par1, par3, par2, color);
drawVerticalLine(par1, par4, par2, color);
drawVerticalLine(par3, par4, par2, color);
}
public void drawCenteredString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
{
par1FontRenderer.drawStringWithShadow(par2Str, par3 - par1FontRenderer.getStringWidth(par2Str) / 2, par4, par5);
}
public void drawString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5)
{
par1FontRenderer.drawStringWithShadow(par2Str, par3, par4, par5);
}
}
Now to draw our Gui. Handler called it before by calling the class's main method.
ExampleGui
Code:
package com.example.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
import com.example.Variables;
import com.example.gui.Util;
public class ExampleGui extends GuiScreen
{
public static Minecraft mc = Minecraft.getMinecraft();
public Util u;
public Variables var;
public FontRenderer fr;
//Note how we have simple access to colors now.
static int white = 0xffffff;
static int dark = 0xaf000000;
static int grey = 0xaf444444;
static int red = 0xFF0000;//0xCC0000
static int green = 0x00FF00;
static String DarkBlue = "\2471";
static String Green = "\2472";
static String LighterBlue = "\2473";
static String Red = "\2474";
static String Purple = "\2475";
static String Orange = "\2476";
static String LightGrey = "\2477";
static String DarkGrey = "\2478";
static String Blue = "\2479";
static String Cyan = "\247b";
static String LightGreen = "\247a";
static String LightRed = "\247c";
static String Pink = "\247d";
static String Yellow = "\247e";
public ExampleGui()
{
DrawMenuText();
DrawMenubox();//comment out this line if you don't want a background.
}
private void DrawMenuBox()
{
u.drawRect(0, 15, 100, 200, grey);
//More detailed GuiMethods are posted publicly. Go look them up. It's a simple google search.
}
private void DrawMenuText()
{
FontRenderer fr = mc.fontRenderer;
//Again with only making one. They're all the same.
if(var.fly)
{
//Format: ( String For Key, String Name, xPos, yPos, string Color[Overwritten if a color in the String name is called])
fr.drawStringWithShadow("[" + "R" + "] " + Green + "Fly", 1, 26, white);
}
else
{
fr.drawStringWithShadow("[" + "R" + "] " + Red + "Fly", 1, 26, white);
}
}
}
Step 6: We already called the fly() method in the class Fly. So now lets add that.
In com.example.hacks, add Fly.java
Fly
Code:
package com.example.hacks;
import org.lwjgl.input.Keyboard;
import com.example.Variables;
import com.example.HackHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Session;
import net.minecraft.src.World;
//Most classes you will make will be normal public classes with no extensions. This is just an exception.
public abstract class Fly extends EntityPlayer
{
public Fly(World par2World)
{
super(par2World);
}
public static Minecraft mc = Minecraft.getMinecraft();
public static void fly()
{
mc.thePlayer.motionX = 0.0D;
mc.thePlayer.motionY = 0.0D;
mc.thePlayer.motionZ = 0.0D;
double yaw = mc.thePlayer****tationYaw + 90F;//90F
boolean inGame = mc.inGameHasFocus;
boolean space = Keyboard.isKeyDown(Keyboard.KEY_SPACE) && inGame;
boolean lcontrol = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && inGame;
boolean w = Keyboard.isKeyDown(Keyboard.KEY_W) && inGame;
boolean a = Keyboard.isKeyDown(Keyboard.KEY_A) && inGame;
boolean s = Keyboard.isKeyDown(Keyboard.KEY_S) && inGame;
boolean d = Keyboard.isKeyDown(Keyboard.KEY_D) && inGame;
boolean lshift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && inGame;
if(lshift)
{
mc.thePlayer.motionY -= (lcontrol ? 0.5D : 0.85D);//1.25D
if(s)
{
yaw += 180D;//180D
}
if(a)
{
yaw -= 65D;//65D
}
if(d)
{
yaw += 65D;//65D
}
}
else if(space)
{
mc.thePlayer.motionY += (lcontrol ? 0.5D : 0.85D);//1.25D
if(s)
{
yaw += 180D;//180D
}
if(a)
{
yaw -= 65D;//65D
}
if(d)
{
yaw += 65D;//65D
}
}
else if(w)
{
if(a)
{
yaw -= 65D;//65D
}
else if(d){
yaw += 65D;//65D
}
}
else if(s)
{
yaw += 180D;//180D
if(w)
{
yaw += 65D;//65D
}
else if(d)
{
yaw -= 65D;//65D
}
else if(a)
{
yaw += 65D;//65D
}
}
else if(a)
{
yaw -= 90D;//90D
}
else if(d)
{
yaw += 90D;//90D
}
if(w || a || s || d)
{
mc.thePlayer.motionX = Math.cos(Math.toRadians(yaw)) / 1.5;
mc.thePlayer.motionZ = Math.sin(Math.toRadians(yaw)) / 1.5;
}
if(lcontrol)
{
mc.thePlayer.motionX /= 4D;
mc.thePlayer.motionZ /= 4D;
}
}
}
Done. How many base files have we touched? 2
You can build upon this to become less source file dependant. However, things such as Xray still require hard coding if you don't know extensive java skills.

Good luck ^_^ Show us whatcha capable of ;P