Expose all possible Baritone instances
This commit is contained in:
parent
a8f09a7fe9
commit
d79d56c2f9
@ -17,16 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.behavior.ILookBehavior;
|
|
||||||
import baritone.api.behavior.IMemoryBehavior;
|
|
||||||
import baritone.api.behavior.IPathingBehavior;
|
|
||||||
import baritone.api.cache.IWorldProvider;
|
|
||||||
import baritone.api.cache.IWorldScanner;
|
|
||||||
import baritone.api.event.listener.IGameEventListener;
|
|
||||||
import baritone.api.process.ICustomGoalProcess;
|
|
||||||
import baritone.api.process.IFollowProcess;
|
|
||||||
import baritone.api.process.IGetToBlockProcess;
|
|
||||||
import baritone.api.process.IMineProcess;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -42,59 +32,23 @@ import java.util.ServiceLoader;
|
|||||||
*/
|
*/
|
||||||
public final class BaritoneAPI {
|
public final class BaritoneAPI {
|
||||||
|
|
||||||
private static final IBaritone baritone;
|
private static final IBaritoneProvider provider;
|
||||||
private static final Settings settings;
|
private static final Settings settings;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||||
baritone = instances.next().getBaritoneForPlayer(null); // PWNAGE
|
provider = instances.next();
|
||||||
|
|
||||||
settings = new Settings();
|
settings = new Settings();
|
||||||
SettingsUtil.readAndApply(settings);
|
SettingsUtil.readAndApply(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IFollowProcess getFollowProcess() {
|
public static IBaritoneProvider getProvider() {
|
||||||
return baritone.getFollowProcess();
|
return BaritoneAPI.provider;
|
||||||
}
|
|
||||||
|
|
||||||
public static ILookBehavior getLookBehavior() {
|
|
||||||
return baritone.getLookBehavior();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IMemoryBehavior getMemoryBehavior() {
|
|
||||||
return baritone.getMemoryBehavior();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IMineProcess getMineProcess() {
|
|
||||||
return baritone.getMineProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IPathingBehavior getPathingBehavior() {
|
|
||||||
return baritone.getPathingBehavior();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Settings getSettings() {
|
public static Settings getSettings() {
|
||||||
return settings;
|
return BaritoneAPI.settings;
|
||||||
}
|
|
||||||
|
|
||||||
public static IWorldProvider getWorldProvider() {
|
|
||||||
return baritone.getWorldProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IWorldScanner getWorldScanner() {
|
|
||||||
return baritone.getWorldScanner();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICustomGoalProcess getCustomGoalProcess() {
|
|
||||||
return baritone.getCustomGoalProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IGetToBlockProcess getGetToBlockProcess() {
|
|
||||||
return baritone.getGetToBlockProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerEventListener(IGameEventListener listener) {
|
|
||||||
baritone.registerEventListener(listener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,6 @@ public interface IBaritone {
|
|||||||
*/
|
*/
|
||||||
IWorldProvider getWorldProvider();
|
IWorldProvider getWorldProvider();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The {@link IWorldScanner} instance
|
|
||||||
* @see IWorldScanner
|
|
||||||
*/
|
|
||||||
IWorldScanner getWorldScanner();
|
|
||||||
|
|
||||||
IInputOverrideHandler getInputOverrideHandler();
|
IInputOverrideHandler getInputOverrideHandler();
|
||||||
|
|
||||||
ICustomGoalProcess getCustomGoalProcess();
|
ICustomGoalProcess getCustomGoalProcess();
|
||||||
|
@ -17,13 +17,35 @@
|
|||||||
|
|
||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
|
import baritone.api.cache.IWorldScanner;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Leijurv
|
* @author Leijurv
|
||||||
*/
|
*/
|
||||||
public interface IBaritoneProvider {
|
public interface IBaritoneProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the primary {@link IBaritone} instance. This instance is persistent, and
|
||||||
|
* is represented by the local player that is created by the game itself, not a "bot"
|
||||||
|
* player through Baritone.
|
||||||
|
*
|
||||||
|
* @return The primary {@link IBaritone} instance.
|
||||||
|
*/
|
||||||
|
IBaritone getPrimaryBaritone();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all of the active {@link IBaritone} instances. This includes the local one
|
||||||
|
* returned by {@link #getPrimaryBaritone()}.
|
||||||
|
*
|
||||||
|
* @see #getBaritoneForPlayer(EntityPlayerSP)
|
||||||
|
*
|
||||||
|
* @return All active {@link IBaritone} instances.
|
||||||
|
*/
|
||||||
|
List<IBaritone> getAllBaritones();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
* Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be
|
||||||
* replaced with {@code #getBaritoneForUser(IBaritoneUser)} when {@code bot-system} is merged.
|
* replaced with {@code #getBaritoneForUser(IBaritoneUser)} when {@code bot-system} is merged.
|
||||||
@ -32,4 +54,12 @@ public interface IBaritoneProvider {
|
|||||||
* @return The {@link IBaritone} instance.
|
* @return The {@link IBaritone} instance.
|
||||||
*/
|
*/
|
||||||
IBaritone getBaritoneForPlayer(EntityPlayerSP player);
|
IBaritone getBaritoneForPlayer(EntityPlayerSP player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link IWorldScanner} instance. This is not a type returned by
|
||||||
|
* {@link IBaritone} implementation, because it is not linked with {@link IBaritone}.
|
||||||
|
*
|
||||||
|
* @return The {@link IWorldScanner} instance.
|
||||||
|
*/
|
||||||
|
IWorldScanner getWorldScanner();
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ public enum Baritone implements IBaritone {
|
|||||||
|
|
||||||
private PathingControlManager pathingControlManager;
|
private PathingControlManager pathingControlManager;
|
||||||
|
|
||||||
|
private IPlayerContext playerContext;
|
||||||
private WorldProvider worldProvider;
|
private WorldProvider worldProvider;
|
||||||
|
|
||||||
Baritone() {
|
Baritone() {
|
||||||
@ -124,6 +125,7 @@ public enum Baritone implements IBaritone {
|
|||||||
getToBlockProcess = new GetToBlockProcess(this);
|
getToBlockProcess = new GetToBlockProcess(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.playerContext = LocalPlayerContext.INSTANCE;
|
||||||
this.worldProvider = new WorldProvider();
|
this.worldProvider = new WorldProvider();
|
||||||
|
|
||||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||||
@ -141,11 +143,6 @@ public enum Baritone implements IBaritone {
|
|||||||
return this.gameEventHandler;
|
return this.gameEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputOverrideHandler getInputOverrideHandler() {
|
|
||||||
return this.inputOverrideHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Behavior> getBehaviors() {
|
public List<Behavior> getBehaviors() {
|
||||||
return this.behaviors;
|
return this.behaviors;
|
||||||
}
|
}
|
||||||
@ -155,6 +152,11 @@ public enum Baritone implements IBaritone {
|
|||||||
this.registerEventListener(behavior);
|
this.registerEventListener(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputOverrideHandler getInputOverrideHandler() {
|
||||||
|
return this.inputOverrideHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
||||||
return customGoalProcess;
|
return customGoalProcess;
|
||||||
@ -167,7 +169,7 @@ public enum Baritone implements IBaritone {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPlayerContext getPlayerContext() {
|
public IPlayerContext getPlayerContext() {
|
||||||
return LocalPlayerContext.INSTANCE;
|
return playerContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -200,16 +202,6 @@ public enum Baritone implements IBaritone {
|
|||||||
return worldProvider;
|
return worldProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO-yeet This shouldn't be baritone-instance specific
|
|
||||||
*
|
|
||||||
* @return world scanner instance
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorldScanner getWorldScanner() {
|
|
||||||
return WorldScanner.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerEventListener(IGameEventListener listener) {
|
public void registerEventListener(IGameEventListener listener) {
|
||||||
this.gameEventHandler.registerEventListener(listener);
|
this.gameEventHandler.registerEventListener(listener);
|
||||||
|
@ -19,15 +19,36 @@ package baritone;
|
|||||||
|
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.IBaritoneProvider;
|
import baritone.api.IBaritoneProvider;
|
||||||
|
import baritone.api.cache.IWorldScanner;
|
||||||
|
import baritone.cache.WorldScanner;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 9/29/2018
|
* @since 9/29/2018
|
||||||
*/
|
*/
|
||||||
public final class BaritoneProvider implements IBaritoneProvider {
|
public final class BaritoneProvider implements IBaritoneProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBaritone getPrimaryBaritone() {
|
||||||
|
return Baritone.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IBaritone> getAllBaritones() {
|
||||||
|
return Collections.singletonList(Baritone.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
public IBaritone getBaritoneForPlayer(EntityPlayerSP player) {
|
||||||
return Baritone.INSTANCE; // pwnage
|
return Baritone.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWorldScanner getWorldScanner() {
|
||||||
|
return WorldScanner.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user