Jump to content

Sleep until?


Recommended Posts

Posted
6 minutes ago, OllieW said:

Sorry for noob question but how can I use sleep until for example sleep until my player hasnt animated in say 10 seconds?

 

isAnimating() isn't reliable for furnaces etc :(?

There's one of two ways to solve this: Either you get creative and look for something else to sleep for or create a method which sleeps until player hasnt animated for 10 seconds. Im pretty sure the first one would be easier for you. ex: check for items in inv or something

Posted (edited)
1 hour ago, Deceiver said:

sleepuntil() -> !getinv.contains(ore/bar), 30000

Do NOT do this. If anything goes wrong, you'll be sitting there for up to 30 seconds just doing nothing.

I normally use a Timer class for the following code, but this will still work and maintains the same jist.

Here is the pastebin because the forums won't let me post it:

https://pastebin.com/7H9GYHcK

 

Edit #2: For some reason, my last edit deleted everything I wrote (?) so I just rewrote it.

Edited by Team Cape
  • Like 3
  • Heart 1
Posted (edited)

For furnace, you would want to cond sleep when widget are null or no longer visible.

You want to interact with furnace if you been idle for x seconds 

  private boolean idleFor(int millis){

        if(myPlayer().isAnimating())
        {
            timeSinceAnimation = System.currentTimeMillis();
        }
        else
        {
            timeSinceIdle = System.currentTimeMillis();
        }

        return timeSinceAnimation + millis < timeSinceIdle;
    }

variables are global

Edited by dreameo

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...