beautiful settings
This commit is contained in:
parent
c67c9582c4
commit
bb453a94b9
@ -22,6 +22,7 @@ import baritone.bot.behavior.impl.LookBehavior;
|
|||||||
import baritone.bot.behavior.impl.MemoryBehavior;
|
import baritone.bot.behavior.impl.MemoryBehavior;
|
||||||
import baritone.bot.behavior.impl.PathingBehavior;
|
import baritone.bot.behavior.impl.PathingBehavior;
|
||||||
import baritone.bot.event.GameEventHandler;
|
import baritone.bot.event.GameEventHandler;
|
||||||
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,25 +17,98 @@
|
|||||||
|
|
||||||
package baritone.bot;
|
package baritone.bot;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Baritone's settings
|
* Baritone's settings
|
||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
public boolean allowBreak = true;
|
public Setting<Boolean> allowBreak = new Setting<>(true);
|
||||||
public boolean allowPlaceThrowaway = true;
|
public Setting<Boolean> allowPlaceThrowaway = new Setting<>(true);
|
||||||
public double costHeuristic = 4;
|
public Setting<Double> costHeuristic = new <Double>Setting<Double>(4D);
|
||||||
public boolean chuckCaching = false;
|
public Setting<Boolean> chuckCaching = new Setting<>(false);
|
||||||
public boolean allowWaterBucketFall = true;
|
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
|
||||||
public int planningTickLookAhead = 150;
|
public Setting<Integer> planningTickLookAhead = new Setting<>(150);
|
||||||
public boolean renderPath = true;
|
public Setting<Boolean> renderPath = new Setting<>(true);
|
||||||
public boolean chatDebug = true;
|
public Setting<Boolean> chatDebug = new Setting<>(true);
|
||||||
public boolean chatControl = true;
|
public Setting<Boolean> chatControl = new Setting<>(true); // probably false in impact
|
||||||
public boolean fadePath = true;
|
public Setting<Boolean> fadePath = new Setting<>(false); // give this a better name in the UI, like "better path fps" idk
|
||||||
public boolean slowPath = false;
|
public Setting<Boolean> slowPath = new Setting<>(false);
|
||||||
|
|
||||||
Settings() {
|
public final Map<String, Setting<?>> byName;
|
||||||
|
public final List<Setting<?>> allSettings;
|
||||||
|
|
||||||
|
public class Setting<T> {
|
||||||
|
public T value;
|
||||||
|
private String name;
|
||||||
|
private Class<? extends T> klass;
|
||||||
|
|
||||||
|
private <V extends T> Setting(V value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final T get() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return name + ": " + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// here be dragons
|
||||||
|
|
||||||
|
{
|
||||||
|
Field[] temp = getClass().getFields();
|
||||||
|
HashMap<String, Setting<?>> tmpByName = new HashMap<>();
|
||||||
|
List<Setting<?>> tmpAll = new ArrayList<>();
|
||||||
|
for (Field field : temp) {
|
||||||
|
if (field.getType().equals(Setting.class)) {
|
||||||
|
try {
|
||||||
|
ParameterizedType param = (ParameterizedType) field.getGenericType();
|
||||||
|
Class settingType = (Class<? extends Object>) param.getActualTypeArguments()[0];
|
||||||
|
// can't always do field.get(this).value.getClass() because default value might be null
|
||||||
|
Setting<?> setting = (Setting<? extends Object>) field.get(this);
|
||||||
|
if (setting.value != null) {
|
||||||
|
if (setting.value.getClass() != settingType) {
|
||||||
|
throw new IllegalStateException("Generic mismatch" + setting.value + " " + setting.value.getClass() + " " + settingType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String name = field.getName();
|
||||||
|
setting.name = name;
|
||||||
|
setting.klass = settingType;
|
||||||
|
if (tmpByName.containsKey(name)) {
|
||||||
|
throw new IllegalStateException("Duplicate setting name");
|
||||||
|
}
|
||||||
|
tmpByName.put(name, setting);
|
||||||
|
tmpAll.add(setting);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
byName = Collections.unmodifiableMap(tmpByName);
|
||||||
|
allSettings = Collections.unmodifiableList(tmpAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, V extends T> List<Setting<V>> getByValueType(Class<T> klass) {
|
||||||
|
ArrayList<Setting<V>> result = new ArrayList<>();
|
||||||
|
for (Setting<?> setting : allSettings) {
|
||||||
|
if (setting.klass.equals(klass)) {
|
||||||
|
result.add((Setting<V>) setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings() { }
|
||||||
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
// and this path dosen't get us all the way there
|
// and this path dosen't get us all the way there
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (current.getPath().ticksRemainingFrom(current.getPosition()) < Baritone.settings().planningTickLookAhead) {
|
if (current.getPath().ticksRemainingFrom(current.getPosition()) < Baritone.settings().planningTickLookAhead.get()) {
|
||||||
// and this path has 5 seconds or less left
|
// and this path has 5 seconds or less left
|
||||||
displayChatMessageRaw("Path almost over. Planning ahead...");
|
displayChatMessageRaw("Path almost over. Planning ahead...");
|
||||||
findPathInNewThread(current.getPath().getDest(), false);
|
findPathInNewThread(current.getPath().getDest(), false);
|
||||||
@ -231,7 +231,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderPass(RenderEvent event) {
|
public void onRenderPass(RenderEvent event) {
|
||||||
if (!Baritone.settings().renderPath) {
|
if (!Baritone.settings().renderPath.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// System.out.println("Render passing");
|
// System.out.println("Render passing");
|
||||||
@ -246,10 +246,10 @@ public class PathingBehavior extends Behavior {
|
|||||||
// Render the current path, if there is one
|
// Render the current path, if there is one
|
||||||
if (current != null && current.getPath() != null) {
|
if (current != null && current.getPath() != null) {
|
||||||
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
||||||
PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Color.RED, Baritone.settings().fadePath, 10, 20);
|
PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Color.RED, Baritone.settings().fadePath.get(), 10, 20);
|
||||||
}
|
}
|
||||||
if (next != null && next.getPath() != null) {
|
if (next != null && next.getPath() != null) {
|
||||||
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.GREEN, Baritone.settings().fadePath, 10, 20);
|
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.GREEN, Baritone.settings().fadePath.get(), 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
long split = System.nanoTime();
|
long split = System.nanoTime();
|
||||||
@ -262,10 +262,10 @@ public class PathingBehavior extends Behavior {
|
|||||||
// If there is a path calculation currently running, render the path calculation process
|
// If there is a path calculation currently running, render the path calculation process
|
||||||
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(currentlyRunning -> {
|
AbstractNodeCostSearch.getCurrentlyRunning().ifPresent(currentlyRunning -> {
|
||||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||||
PathRenderer.drawPath(p, 0, player(), partialTicks, Color.BLUE, Baritone.settings().fadePath, 10, 20);
|
PathRenderer.drawPath(p, 0, player(), partialTicks, Color.BLUE, Baritone.settings().fadePath.get(), 10, 20);
|
||||||
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
||||||
|
|
||||||
PathRenderer.drawPath(mr, 0, player(), partialTicks, Color.CYAN, Baritone.settings().fadePath, 10, 20);
|
PathRenderer.drawPath(mr, 0, player(), partialTicks, Color.CYAN, Baritone.settings().fadePath.get(), 10, 20);
|
||||||
PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Color.CYAN);
|
PathRenderer.drawManySelectionBoxes(player(), Collections.singletonList(mr.getDest()), partialTicks, Color.CYAN);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -35,15 +35,15 @@
|
|||||||
package baritone.bot.event;
|
package baritone.bot.event;
|
||||||
|
|
||||||
import baritone.bot.Baritone;
|
import baritone.bot.Baritone;
|
||||||
import baritone.bot.InputOverrideHandler;
|
|
||||||
import baritone.bot.behavior.Behavior;
|
import baritone.bot.behavior.Behavior;
|
||||||
import baritone.bot.chunk.CachedWorld;
|
import baritone.bot.chunk.CachedWorld;
|
||||||
import baritone.bot.chunk.CachedWorldProvider;
|
import baritone.bot.chunk.CachedWorldProvider;
|
||||||
import baritone.bot.chunk.ChunkPacker;
|
import baritone.bot.chunk.ChunkPacker;
|
||||||
import baritone.bot.event.listener.IGameEventListener;
|
|
||||||
import baritone.bot.event.events.*;
|
import baritone.bot.event.events.*;
|
||||||
import baritone.bot.event.events.type.EventState;
|
import baritone.bot.event.events.type.EventState;
|
||||||
|
import baritone.bot.event.listener.IGameEventListener;
|
||||||
import baritone.bot.utils.Helper;
|
import baritone.bot.utils.Helper;
|
||||||
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
@ -108,7 +108,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
&& type == ChunkEvent.Type.UNLOAD
|
&& type == ChunkEvent.Type.UNLOAD
|
||||||
&& mc.world.getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ());
|
&& mc.world.getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ());
|
||||||
|
|
||||||
if (Baritone.settings().chuckCaching) {
|
if (Baritone.settings().chuckCaching.get()) {
|
||||||
if (isPostPopulate || isPreUnload) {
|
if (isPostPopulate || isPreUnload) {
|
||||||
CachedWorldProvider.INSTANCE.ifWorldLoaded(world ->
|
CachedWorldProvider.INSTANCE.ifWorldLoaded(world ->
|
||||||
world.updateCachedChunk(event.getX(), event.getZ(),
|
world.updateCachedChunk(event.getX(), event.getZ(),
|
||||||
@ -132,7 +132,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWorldEvent(WorldEvent event) {
|
public void onWorldEvent(WorldEvent event) {
|
||||||
if (Baritone.settings().chuckCaching) {
|
if (Baritone.settings().chuckCaching.get()) {
|
||||||
CachedWorldProvider cache = CachedWorldProvider.INSTANCE;
|
CachedWorldProvider cache = CachedWorldProvider.INSTANCE;
|
||||||
|
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
|
@ -81,14 +81,15 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
}
|
}
|
||||||
currentlyRunning = this;
|
currentlyRunning = this;
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
long timeoutTime = startTime + (Baritone.settings().slowPath ? 40000 : 4000);
|
boolean slowPath = Baritone.settings().slowPath.get();
|
||||||
|
long timeoutTime = startTime + (slowPath ? 40000 : 4000);
|
||||||
long lastPrintout = 0;
|
long lastPrintout = 0;
|
||||||
int numNodes = 0;
|
int numNodes = 0;
|
||||||
CalculationContext calcContext = new CalculationContext();
|
CalculationContext calcContext = new CalculationContext();
|
||||||
int numEmptyChunk = 0;
|
int numEmptyChunk = 0;
|
||||||
boolean cache = Baritone.settings().chuckCaching;
|
boolean cache = Baritone.settings().chuckCaching.get();
|
||||||
while (!openSet.isEmpty() && numEmptyChunk < 50 && System.currentTimeMillis() < timeoutTime) {
|
while (!openSet.isEmpty() && numEmptyChunk < 50 && System.currentTimeMillis() < timeoutTime) {
|
||||||
if (Baritone.settings().slowPath) {
|
if (slowPath) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
@ -99,7 +99,7 @@ public class GoalXZ implements Goal {
|
|||||||
diagonal = z;
|
diagonal = z;
|
||||||
}
|
}
|
||||||
diagonal *= SQRT_2;
|
diagonal *= SQRT_2;
|
||||||
return (diagonal + straight) * Baritone.settings().costHeuristic; // big TODO tune
|
return (diagonal + straight) * Baritone.settings().costHeuristic.get(); // big TODO tune
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {
|
||||||
|
@ -42,8 +42,8 @@ public class CalculationContext implements Helper {
|
|||||||
|
|
||||||
public CalculationContext(ToolSet toolSet) {
|
public CalculationContext(ToolSet toolSet) {
|
||||||
this.toolSet = toolSet;
|
this.toolSet = toolSet;
|
||||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
||||||
this.hasThrowaway = Baritone.settings().allowPlaceThrowaway && MovementHelper.throwaway(false);
|
this.hasThrowaway = Baritone.settings().allowPlaceThrowaway.get() && MovementHelper.throwaway(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolSet getToolSet() {
|
public ToolSet getToolSet() {
|
||||||
|
@ -37,7 +37,7 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static baritone.bot.InputOverrideHandler.Input;
|
import static baritone.bot.utils.InputOverrideHandler.Input;
|
||||||
|
|
||||||
public abstract class Movement implements Helper, MovementHelper {
|
public abstract class Movement implements Helper, MovementHelper {
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package baritone.bot.pathing.movement;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
import baritone.bot.Baritone;
|
import baritone.bot.Baritone;
|
||||||
import baritone.bot.InputOverrideHandler;
|
|
||||||
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
||||||
import baritone.bot.pathing.movement.MovementState.MovementTarget;
|
import baritone.bot.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.bot.pathing.movement.movements.MovementDescend;
|
import baritone.bot.pathing.movement.movements.MovementDescend;
|
||||||
@ -137,7 +136,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
IBlockState state = BlockStateInterface.get(position);
|
IBlockState state = BlockStateInterface.get(position);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!block.equals(Blocks.AIR) && !canWalkThrough(position)) {
|
if (!block.equals(Blocks.AIR) && !canWalkThrough(position)) {
|
||||||
if (!Baritone.settings().allowBreak) {
|
if (!Baritone.settings().allowBreak.get()) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (avoidBreaking(position)) {
|
if (avoidBreaking(position)) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler.Input;
|
import baritone.bot.utils.InputOverrideHandler.Input;
|
||||||
import baritone.bot.utils.Rotation;
|
import baritone.bot.utils.Rotation;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
||||||
import baritone.bot.pathing.movement.CalculationContext;
|
import baritone.bot.pathing.movement.CalculationContext;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.bot.pathing.movement.CalculationContext;
|
import baritone.bot.pathing.movement.CalculationContext;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
import baritone.bot.pathing.movement.MovementHelper;
|
import baritone.bot.pathing.movement.MovementHelper;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
||||||
import baritone.bot.pathing.movement.*;
|
import baritone.bot.pathing.movement.*;
|
||||||
import baritone.bot.pathing.movement.MovementState.MovementStatus;
|
import baritone.bot.pathing.movement.MovementState.MovementStatus;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.bot.pathing.movement.CalculationContext;
|
import baritone.bot.pathing.movement.CalculationContext;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
import baritone.bot.pathing.movement.MovementHelper;
|
import baritone.bot.pathing.movement.MovementHelper;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package baritone.bot.pathing.movement.movements;
|
package baritone.bot.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
import baritone.bot.behavior.impl.LookBehaviorUtils;
|
||||||
import baritone.bot.pathing.movement.CalculationContext;
|
import baritone.bot.pathing.movement.CalculationContext;
|
||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
|
@ -41,7 +41,7 @@ public class BlockStateInterface implements Helper {
|
|||||||
if (chunk.isLoaded()) {
|
if (chunk.isLoaded()) {
|
||||||
return chunk.getBlockState(pos);
|
return chunk.getBlockState(pos);
|
||||||
}
|
}
|
||||||
if(Baritone.settings().chuckCaching) {
|
if (Baritone.settings().chuckCaching.get()) {
|
||||||
CachedWorld world = CachedWorldProvider.INSTANCE.getCurrentWorld();
|
CachedWorld world = CachedWorldProvider.INSTANCE.getCurrentWorld();
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
PathingBlockType type = world.getBlockType(pos);
|
PathingBlockType type = world.getBlockType(pos);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package baritone.bot.utils;
|
package baritone.bot.utils;
|
||||||
|
|
||||||
import baritone.bot.Baritone;
|
import baritone.bot.Baritone;
|
||||||
|
import baritone.bot.Settings;
|
||||||
import baritone.bot.behavior.Behavior;
|
import baritone.bot.behavior.Behavior;
|
||||||
import baritone.bot.behavior.impl.PathingBehavior;
|
import baritone.bot.behavior.impl.PathingBehavior;
|
||||||
import baritone.bot.event.events.ChatEvent;
|
import baritone.bot.event.events.ChatEvent;
|
||||||
@ -27,6 +28,8 @@ import baritone.bot.pathing.goals.GoalXZ;
|
|||||||
import baritone.bot.pathing.goals.GoalYLevel;
|
import baritone.bot.pathing.goals.GoalYLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ExampleBaritoneControl extends Behavior {
|
public class ExampleBaritoneControl extends Behavior {
|
||||||
public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl();
|
public static ExampleBaritoneControl INSTANCE = new ExampleBaritoneControl();
|
||||||
|
|
||||||
@ -40,7 +43,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendChatMessage(ChatEvent event) {
|
public void onSendChatMessage(ChatEvent event) {
|
||||||
if (!Baritone.settings().chatControl) {
|
if (!Baritone.settings().chatControl.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
@ -82,11 +85,6 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("slowpath")) {
|
|
||||||
Baritone.settings().slowPath ^= true;
|
|
||||||
event.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (msg.toLowerCase().equals("cancel")) {
|
if (msg.toLowerCase().equals("cancel")) {
|
||||||
PathingBehavior.INSTANCE.cancel();
|
PathingBehavior.INSTANCE.cancel();
|
||||||
event.cancel();
|
event.cancel();
|
||||||
@ -100,5 +98,14 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<Settings.Setting<Boolean>> toggleable = Baritone.settings().getByValueType(Boolean.class);
|
||||||
|
for (Settings.Setting<Boolean> setting : toggleable) {
|
||||||
|
if (msg.toLowerCase().equals(setting.getName().toLowerCase())) {
|
||||||
|
setting.value ^= true;
|
||||||
|
event.cancel();
|
||||||
|
displayChatMessageRaw("Toggled " + setting.getName() + " to " + setting.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public interface Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void displayChatMessageRaw(String message) {
|
default void displayChatMessageRaw(String message) {
|
||||||
if (!Baritone.settings().chatDebug) {
|
if (!Baritone.settings().chatDebug.get()) {
|
||||||
System.out.println("Suppressed debug message:");
|
System.out.println("Suppressed debug message:");
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
return;
|
return;
|
||||||
|
@ -15,9 +15,25 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.bot;
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.bot.utils;
|
||||||
|
|
||||||
import baritone.bot.utils.Helper;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@ -34,7 +50,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public final class InputOverrideHandler implements Helper {
|
public final class InputOverrideHandler implements Helper {
|
||||||
|
|
||||||
InputOverrideHandler() {}
|
public InputOverrideHandler() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps keybinds to whether or not we are forcing their state down.
|
* Maps keybinds to whether or not we are forcing their state down.
|
@ -1,7 +1,7 @@
|
|||||||
package baritone.movement;
|
package baritone.movement;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.bot.InputOverrideHandler;
|
import baritone.bot.utils.InputOverrideHandler;
|
||||||
import baritone.ui.LookManager;
|
import baritone.ui.LookManager;
|
||||||
import net.minecraft.block.BlockLadder;
|
import net.minecraft.block.BlockLadder;
|
||||||
import net.minecraft.block.BlockVine;
|
import net.minecraft.block.BlockVine;
|
||||||
|
Loading…
Reference in New Issue
Block a user