Created
July 30, 2012 14:12
-
-
Save pxpc2/3207174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.timer.powerminer; | |
import java.awt.Graphics; | |
import com.timer.powerminer.impl.DropOre; | |
import com.timer.powerminer.impl.MineRock; | |
import com.timer.powerminer.job.Node; | |
import com.timer.powerminer.job.Tree; | |
import org.powerbot.beta.core.script.BetaScript; | |
import org.powerbot.game.api.util.Random; | |
import org.powerbot.game.bot.event.listener.PaintListener; | |
public class SimpleMiner extends BetaScript implements PaintListener { | |
public static final int[] OBJECT_ID_ROCKS = {}; | |
private Tree mining_jobs = null; | |
@Override | |
public int loop() { | |
/* Create mining tree if not already created. */ | |
if (mining_jobs == null) { | |
mining_jobs = new Tree(new Node[]{new MineRock(), new DropOre()}); | |
} | |
/* Get the state of the tree. */ | |
final Node node = mining_jobs.state(); | |
if (node != null) { | |
/* Register the tree's state */ | |
mining_jobs.set(node); | |
/* Submit the state (node/task) */ | |
getContainer().submit(node); | |
/* Join it with the current thread (suspend thread until task is completed). */ | |
node.join(); | |
return 0; | |
} | |
/* Sleep as the tree did not provide a state */ | |
return Random.nextInt(100, 250); | |
} | |
@Override | |
public void onRepaint(final Graphics render) { | |
final Node node = mining_jobs == null ? null : mining_jobs.get(); | |
if (node != null && node instanceof PaintListener) { | |
((PaintListener) node).onRepaint(render); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment