Author Topic: [Java] Minecraft Criticals  (Read 984 times)

0 Members and 1 Guest are viewing this topic.

Offline HardCodedShadow

  • /dev/null
  • *
  • Posts: 18
  • Cookies: 0
    • View Profile
[Java] Minecraft Criticals
« on: July 09, 2015, 11:12:38 pm »
Hey, decided to post one of my (worse) exploits for the Minecraft game.
This is supposed to make you do criticals. One some servers you may need to jump once before it works.
If you know Java this will be very easy to implement, if not, this post is probably not for you.

This basically works on this principle:
To make a critical hit, you need to have some fall damage, which happens when you move down in the air, generally while jumping. When the player lands, the fall damage resets back to zero and you make normal hits again. To get around this we will need to modify outgoing packets to make the server think you didn't land - that means setting the C03PacketPlayer's onGround data to false.

I don't know how to make it more obvious so here's the code:

Code: [Select]
package me.hardcodedshadow.client.module.modules.combat;

import me.hardcodedshadow.client.Client
import me.hardcodedshadow.client.event.EventTarget;
import me.hardcodedshadow.client.event.Listener;
import me.hardcodedshadow.client.event.events.EventPlayerUpdate;
import me.hardcodedshadow.client.event.events.EventPostMotionUpdate;
import me.hardcodedshadow.client.event.events.EventPreMotionUpdate;
import me.hardcodedshadow.client.module.Module;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;

public class Criticals extends Module implements Listener
{

    boolean wasOnGround = true;
    double fallDistance = 0;
    double newFallDistance = 0;

    public Criticals()
    {
        super("Criticals", Category.COMBAT, "Always make a critical hit");
    }

    @Override
    public void onEnable()
    {
        registry.registerListener(this);

        if (Minecraft.getMinecraft().thePlayer != null)
        {
            newFallDistance = Minecraft.getMinecraft().thePlayer.fallDistance;

        }
        else
        {
            fallDistance = 0;
            newFallDistance = 0;
        }
    }

    @Override
    public void onDisable()
    {
        registry.unregisterListener(this);
        fallDistance = 0;
        newFallDistance = 0;
    }

    private boolean isSafe(final EntityPlayerSP entity)
    {
        return entity.inWater || entity.isOnLadder() || entity.isInsideOfMaterial(Material.lava);
    }
   
    @EventTarget
    public void onUpdate(final EventPlayerUpdate event)
    {
        if (event.thePlayer.onGround && fallDistance == 0){
            event.thePlayer.motionY = 0.1;
        }
    }
   
    @EventTarget
    public void onPreUpdate(final EventPreMotionUpdate event)
    {
        wasOnGround = event.thePlayer.onGround;

        if (!isSafe(event.thePlayer))
        {
            if (event.thePlayer.fallDistance > newFallDistance)
                newFallDistance = event.thePlayer.fallDistance;
           
            if (event.thePlayer.fallDistance == 0)
            {
                fallDistance += newFallDistance;
                newFallDistance = 0;
            }
        } else {
            fallDistance = 0;
            newFallDistance = 0;
        }

        if (fallDistance >= 3 && wasOnGround){
            fallDistance = 0;
            newFallDistance = 0;
        }
        else if (fallDistance > 0){
            event.thePlayer.onGround = false;
        }
    }

    @EventTarget
    public void onPostUpdate(final EventPostMotionUpdate event)
    {
        event.thePlayer.onGround = wasOnGround;
    }
}


I hope the code is readable and sorry for not commenting.
I use an EventManager, but I'm sure you guys will be able to hook it to the right place.
You may have seen me once, but you'll never forget who I am, even though I'm nobody.