static
This commit is contained in:
parent
e81d0a0b1b
commit
903b1b16a4
@ -59,15 +59,26 @@ public enum Baritone implements IBaritone {
|
|||||||
*/
|
*/
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
private static ThreadPoolExecutor threadPool;
|
||||||
|
private static File dir;
|
||||||
|
|
||||||
|
static {
|
||||||
|
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||||
|
|
||||||
|
dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||||
|
if (!Files.exists(dir.toPath())) {
|
||||||
|
try {
|
||||||
|
Files.createDirectories(dir.toPath());
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not {@link Baritone#init()} has been called yet
|
* Whether or not {@link Baritone#init()} has been called yet
|
||||||
*/
|
*/
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
private GameEventHandler gameEventHandler;
|
private GameEventHandler gameEventHandler;
|
||||||
private Settings settings;
|
|
||||||
private File dir;
|
|
||||||
|
|
||||||
|
|
||||||
private List<Behavior> behaviors;
|
private List<Behavior> behaviors;
|
||||||
private PathingBehavior pathingBehavior;
|
private PathingBehavior pathingBehavior;
|
||||||
@ -84,8 +95,6 @@ public enum Baritone implements IBaritone {
|
|||||||
|
|
||||||
private WorldProvider worldProvider;
|
private WorldProvider worldProvider;
|
||||||
|
|
||||||
private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
|
||||||
|
|
||||||
Baritone() {
|
Baritone() {
|
||||||
this.gameEventHandler = new GameEventHandler(this);
|
this.gameEventHandler = new GameEventHandler(this);
|
||||||
}
|
}
|
||||||
@ -95,10 +104,6 @@ public enum Baritone implements IBaritone {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire the "singleton" instance of the settings directly from the API
|
|
||||||
// We might want to change this...
|
|
||||||
this.settings = BaritoneAPI.getSettings();
|
|
||||||
|
|
||||||
this.behaviors = new ArrayList<>();
|
this.behaviors = new ArrayList<>();
|
||||||
{
|
{
|
||||||
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
||||||
@ -122,12 +127,6 @@ public enum Baritone implements IBaritone {
|
|||||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||||
registerEventListener(BaritoneAutoTest.INSTANCE);
|
registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||||
}
|
}
|
||||||
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
|
||||||
if (!Files.exists(dir.toPath())) {
|
|
||||||
try {
|
|
||||||
Files.createDirectories(dir.toPath());
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
}
|
}
|
||||||
@ -136,10 +135,6 @@ public enum Baritone implements IBaritone {
|
|||||||
return pathingControlManager;
|
return pathingControlManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInitialized() {
|
|
||||||
return this.initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IGameEventListener getGameEventHandler() {
|
public IGameEventListener getGameEventHandler() {
|
||||||
return this.gameEventHandler;
|
return this.gameEventHandler;
|
||||||
}
|
}
|
||||||
@ -152,22 +147,18 @@ public enum Baritone implements IBaritone {
|
|||||||
return this.behaviors;
|
return this.behaviors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Executor getExecutor() {
|
|
||||||
return threadPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerBehavior(Behavior behavior) {
|
public void registerBehavior(Behavior behavior) {
|
||||||
this.behaviors.add(behavior);
|
this.behaviors.add(behavior);
|
||||||
this.registerEventListener(behavior);
|
this.registerEventListener(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomGoalProcess getCustomGoalProcess() {
|
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
||||||
return customGoalProcess;
|
return customGoalProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GetToBlockProcess getGetToBlockProcess() { // very very high iq
|
public GetToBlockProcess getGetToBlockProcess() { // Iffy
|
||||||
return getToBlockProcess;
|
return getToBlockProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,15 +202,15 @@ public enum Baritone implements IBaritone {
|
|||||||
this.gameEventHandler.registerEventListener(listener);
|
this.gameEventHandler.registerEventListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings getSettings() {
|
|
||||||
return this.settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Settings settings() {
|
public static Settings settings() {
|
||||||
return Baritone.INSTANCE.settings; // yolo
|
return BaritoneAPI.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getDir() {
|
public static File getDir() {
|
||||||
return Baritone.INSTANCE.dir; // should be static I guess
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Executor getExecutor() {
|
||||||
|
return threadPool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user