KurtisAD / NoVa-SRC

Hacked client for Minecraft
6 stars 0 forks source link

Kurtis dev #54

Closed EmotionalLove closed 7 years ago

EmotionalLove commented 7 years ago

`package nova.modules;

import net.minecraft.client.Minecraft; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import nova.Command; import nova.events.EventHandler; import nova.events.PlayerTickEvent;

import java.util.Random;

/**

public class ModuleAntiAfk extends ModuleBase{

int timerchat = 0;

private BlockPos block;
private Random random;
private BlockPos nextBlock;

private Long currentMS;
private Long lastMs;

public ModuleAntiAfk(nova.Nova Nova, Minecraft mc) {
    // TODO: change code to implement yaw module
    super(Nova, mc);
    aliases.add("afk");
    aliases.add("aafk");
    this.command = new Command(Nova, this, aliases, "Walks randomly to prevent AFK detectors. From Wrust");

    currentMS = System.currentTimeMillis();
    lastMs = currentMS;
}

@Override
public void onEnable()
{
    try
    {
        block = new BlockPos(mc.player);
    }catch(Exception e)
    {
        e.printStackTrace();
    }
    random = new Random();

    this.isEnabled = true;
}

@EventHandler
public void onUpdate(PlayerTickEvent e)
{
    if (this.isEnabled) {
        timerchat++;
        currentMS = System.currentTimeMillis();

        if(currentMS >= lastMs + 3000|| nextBlock == null)
        {
            if(block == null)
                onEnable();
            nextBlock =
                    block.add(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
            lastMs = System.currentTimeMillis();
        }

        if (timerchat == 250) {
            mc.player.sendChatMessage("> AFK!");
            timerchat = 0;
        }

        faceBlockClientHorizontally(nextBlock);
        mc.gameSettings.keyBindForward.pressed = getHorizontalPlayerBlockDistance(nextBlock) > 0.75;
    }
}

@Override
public void onDisable()
{
    mc.gameSettings.keyBindForward.pressed = false;
    this.isEnabled = false;
}

private static void faceBlockClientHorizontally(BlockPos blockPos)
{
    double diffX =
            blockPos.getX() + 0.5 - Minecraft.getMinecraft().player.posX;
    double diffZ =
            blockPos.getZ() + 0.5 - Minecraft.getMinecraft().player.posZ;
    float yaw =
            (float)(Math.atan2(diffZ, diffX) * 180.0D / Math.PI) - 90.0F;
    Minecraft.getMinecraft().player.rotationYaw =
            Minecraft.getMinecraft().player.rotationYaw
                    + MathHelper.wrapDegrees(yaw
                    - Minecraft.getMinecraft().player.rotationYaw);
}

private static float getHorizontalPlayerBlockDistance(BlockPos blockPos)
{
    float xDiff =
            (float) (Minecraft.getMinecraft().player.posX - blockPos.getX());
    float zDiff =
            (float) (Minecraft.getMinecraft().player.posZ - blockPos.getZ());
    return MathHelper.sqrt((xDiff - 0.5F) * (xDiff - 0.5F)
            + (zDiff - 0.5F) * (zDiff - 0.5F));
}

}

Added an anti-afk chat message in onUpdate()

EmotionalLove commented 7 years ago

Dammit

KurtisAD commented 7 years ago

This doesn't match with the latest implementation I used, also announcing AFK isn't functionally useful