Expose all possible Baritone instances
This commit is contained in:
parent
a8f09a7fe9
commit
d79d56c2f9
@ -17,16 +17,6 @@
|
||||
|
||||
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 java.util.Iterator;
|
||||
@ -42,59 +32,23 @@ import java.util.ServiceLoader;
|
||||
*/
|
||||
public final class BaritoneAPI {
|
||||
|
||||
private static final IBaritone baritone;
|
||||
private static final IBaritoneProvider provider;
|
||||
private static final Settings settings;
|
||||
|
||||
static {
|
||||
ServiceLoader<IBaritoneProvider> baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
|
||||
Iterator<IBaritoneProvider> instances = baritoneLoader.iterator();
|
||||
baritone = instances.next().getBaritoneForPlayer(null); // PWNAGE
|
||||
provider = instances.next();
|
||||
|
||||
settings = new Settings();
|
||||
SettingsUtil.readAndApply(settings);
|
||||
}
|
||||
|
||||
public static IFollowProcess getFollowProcess() {
|
||||
return baritone.getFollowProcess();
|
||||
}
|
||||
|
||||
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 IBaritoneProvider getProvider() {
|
||||
return BaritoneAPI.provider;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return 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);
|
||||
return BaritoneAPI.settings;
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +72,6 @@ public interface IBaritone {
|
||||
*/
|
||||
IWorldProvider getWorldProvider();
|
||||
|
||||
/**
|
||||
* @return The {@link IWorldScanner} instance
|
||||
* @see IWorldScanner
|
||||
*/
|
||||
IWorldScanner getWorldScanner();
|
||||
|
||||
IInputOverrideHandler getInputOverrideHandler();
|
||||
|
||||
ICustomGoalProcess getCustomGoalProcess();
|
||||
|
@ -17,13 +17,35 @@
|
||||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Leijurv
|
||||
*/
|
||||
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
|
||||
* replaced with {@code #getBaritoneForUser(IBaritoneUser)} when {@code bot-system} is merged.
|
||||
@ -32,4 +54,12 @@ public interface IBaritoneProvider {
|
||||
* @return The {@link IBaritone} instance.
|
||||
*/
|
||||
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 IPlayerContext playerContext;
|
||||
private WorldProvider worldProvider;
|
||||
|
||||
Baritone() {
|
||||
@ -124,6 +125,7 @@ public enum Baritone implements IBaritone {
|
||||
getToBlockProcess = new GetToBlockProcess(this);
|
||||
}
|
||||
|
||||
this.playerContext = LocalPlayerContext.INSTANCE;
|
||||
this.worldProvider = new WorldProvider();
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
@ -141,11 +143,6 @@ public enum Baritone implements IBaritone {
|
||||
return this.gameEventHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
public List<Behavior> getBehaviors() {
|
||||
return this.behaviors;
|
||||
}
|
||||
@ -155,6 +152,11 @@ public enum Baritone implements IBaritone {
|
||||
this.registerEventListener(behavior);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputOverrideHandler getInputOverrideHandler() {
|
||||
return this.inputOverrideHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGoalProcess getCustomGoalProcess() { // Iffy
|
||||
return customGoalProcess;
|
||||
@ -167,7 +169,7 @@ public enum Baritone implements IBaritone {
|
||||
|
||||
@Override
|
||||
public IPlayerContext getPlayerContext() {
|
||||
return LocalPlayerContext.INSTANCE;
|
||||
return playerContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,16 +202,6 @@ public enum Baritone implements IBaritone {
|
||||
return worldProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO-yeet This shouldn't be baritone-instance specific
|
||||
*
|
||||
* @return world scanner instance
|
||||
*/
|
||||
@Override
|
||||
public WorldScanner getWorldScanner() {
|
||||
return WorldScanner.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEventListener(IGameEventListener listener) {
|
||||
this.gameEventHandler.registerEventListener(listener);
|
||||
|
@ -19,15 +19,36 @@ package baritone;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.IBaritoneProvider;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import baritone.cache.WorldScanner;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/29/2018
|
||||
*/
|
||||
public final class BaritoneProvider implements IBaritoneProvider {
|
||||
|
||||
@Override
|
||||
public IBaritone getPrimaryBaritone() {
|
||||
return Baritone.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IBaritone> getAllBaritones() {
|
||||
return Collections.singletonList(Baritone.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
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