#help with 1.8.9 mod

4 messages · Page 1 of 1 (latest)

dry field
#

So I am trying to make a mod to automate some tasks and for some fun really

import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

public class ExampleMod {
private static final int BUTTON_LEFT = 0;
private static final int KEY_W = Keyboard.KEY_W;
private static final int KEY_A = Keyboard.KEY_A;
private static final int KEY_S = Keyboard.KEY_S;
private static final int KEY_D = Keyboard.KEY_D;

public static void main(String[] args) {
    Random rand = new Random();
    for (int i = 0; i < 10; i++) {
        System.out.println(i);
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    Mouse.pressButton(BUTTON_LEFT);
    while (!Keyboard.isKeyDown(Keyboard.KEY_M)) {
        long start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 9300) {
            Keyboard.press(KEY_D);
        }
        Keyboard.release(KEY_D);

        start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 400) {
            Keyboard.press(KEY_W);
        }
        Keyboard.release(KEY_W);

        start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 9300) {
            Keyboard.press(KEY_S);
        }
        Keyboard.release(KEY_S);

        start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < 400) {
            Keyboard.press(KEY_A);
        }
        Keyboard.release(KEY_A);

        try {
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Mouse.releaseButton(BUTTON_LEFT);
        System.out.println(System.currentTimeMillis() + " going back to the island");
        Keyboard.sendKeys("/setspawn");
        try {
            TimeUnit.MILLISECONDS.sleep(rand.nextInt(50) + 50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Keyboard.press(Keyboard.KEY_RETURN);
        Keyboard.release(Keyboard.KEY_RETURN);
        Keyboard.sendKeys("/warp garden");
        try {
            TimeUnit.MILLISECONDS.sleep(rand.nextInt(50) + 50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Keyboard.press(Keyboard.KEY_RETURN);
        Keyboard.release(Keyboard.KEY_RETURN);

        try {
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Mouse.pressButton(BUTTON_LEFT);
    }
}

}
My issue is making the mod

grave plinthBOT
#

This post has been reserved for your question.

Hey @dry field! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

dry field
#

ok