Jump to content

Sleep until?


H0rn

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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