-2

I want to create a java function, like a wait until this has passed in seconds, then they may preform the action.. Here is what I have:

    if(Minecraft.getMinecraft().gameSettings.keyBindJump.pressed)
        hasTimePassedS(2);
        Minecraft.getMinecraft().thePlayer.motionY = + 8;


    private boolean hasTimePassedS(int i) {
    long t0 = 0,t1 = 1;
     do{
     }
     while (t1-t0<1000);
    return false;

Note: These are two different samples, no correct { } format is used/regarded.

I want there to be a two second delay after the top code is activated before you can press it again.

Thanks!

Hobo
  • 1
  • 2

1 Answers1

0

You could create (and start) a Timer. Also, I'm pretty sure you meant += 8 (not = +8) Something like,

if (Minecraft.getMinecraft().gameSettings.keyBindJump.pressed) {
  Timer t = new Timer(2000, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Minecraft.getMinecraft().thePlayer.motionY += 8;
    }
  });
  t.start();
}
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249