refactor logging, fixes #153
This commit is contained in:
parent
bafc938424
commit
ff2714b15f
@ -60,7 +60,7 @@ public class MineBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
List<BlockPos> locs = scanFor(mining, 64);
|
List<BlockPos> locs = scanFor(mining, 64);
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
|
logDebug("No locations for " + mining + " known, cancelling");
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,14 +77,14 @@ public class PathingBehavior extends Behavior {
|
|||||||
if (current.failed() || current.finished()) {
|
if (current.failed() || current.finished()) {
|
||||||
current = null;
|
current = null;
|
||||||
if (goal == null || goal.isInGoal(playerFeet())) {
|
if (goal == null || goal.isInGoal(playerFeet())) {
|
||||||
displayChatMessageRaw("All done. At " + goal);
|
logDebug("All done. At " + goal);
|
||||||
dispatchPathEvent(PathEvent.AT_GOAL);
|
dispatchPathEvent(PathEvent.AT_GOAL);
|
||||||
next = null;
|
next = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (next != null && !next.getPath().positions().contains(playerFeet())) {
|
if (next != null && !next.getPath().positions().contains(playerFeet())) {
|
||||||
// if the current path failed, we may not actually be on the next one, so make sure
|
// if the current path failed, we may not actually be on the next one, so make sure
|
||||||
displayChatMessageRaw("Discarding next path as it does not contain current position");
|
logDebug("Discarding next path as it does not contain current position");
|
||||||
// for example if we had a nicely planned ahead path that starts where current ends
|
// for example if we had a nicely planned ahead path that starts where current ends
|
||||||
// that's all fine and good
|
// that's all fine and good
|
||||||
// but if we fail in the middle of current
|
// but if we fail in the middle of current
|
||||||
@ -94,7 +94,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
displayChatMessageRaw("Continuing on to planned next path");
|
logDebug("Continuing on to planned next path");
|
||||||
dispatchPathEvent(PathEvent.CONTINUING_ONTO_PLANNED_NEXT);
|
dispatchPathEvent(PathEvent.CONTINUING_ONTO_PLANNED_NEXT);
|
||||||
current = next;
|
current = next;
|
||||||
next = null;
|
next = null;
|
||||||
@ -118,7 +118,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
if (next != null) {
|
if (next != null) {
|
||||||
if (next.getPath().positions().contains(playerFeet())) {
|
if (next.getPath().positions().contains(playerFeet())) {
|
||||||
// jump directly onto the next path
|
// jump directly onto the next path
|
||||||
displayChatMessageRaw("Splicing into planned next path early...");
|
logDebug("Splicing into planned next path early...");
|
||||||
dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
|
dispatchPathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
|
||||||
current = next;
|
current = next;
|
||||||
next = null;
|
next = null;
|
||||||
@ -141,7 +141,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) {
|
if (ticksRemainingInSegment().get() < 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...");
|
logDebug("Path almost over. Planning ahead...");
|
||||||
dispatchPathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
dispatchPathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
||||||
findPathInNewThread(current.getPath().getDest(), false, Optional.of(current.getPath()));
|
findPathInNewThread(current.getPath().getDest(), false, Optional.of(current.getPath()));
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (talkAboutIt) {
|
if (talkAboutIt) {
|
||||||
displayChatMessageRaw("Starting to search for path from " + start + " to " + goal);
|
logDebug("Starting to search for path from " + start + " to " + goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<IPath> path = findPath(start, previous);
|
Optional<IPath> path = findPath(start, previous);
|
||||||
@ -280,9 +280,9 @@ public class PathingBehavior extends Behavior {
|
|||||||
|
|
||||||
if (talkAboutIt && current != null && current.getPath() != null) {
|
if (talkAboutIt && current != null && current.getPath() != null) {
|
||||||
if (goal == null || goal.isInGoal(current.getPath().getDest())) {
|
if (goal == null || goal.isInGoal(current.getPath().getDest())) {
|
||||||
displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
logDebug("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
||||||
} else {
|
} else {
|
||||||
displayChatMessageRaw("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
logDebug("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
private Optional<IPath> findPath(BlockPos start, Optional<IPath> previous) {
|
private Optional<IPath> findPath(BlockPos start, Optional<IPath> previous) {
|
||||||
Goal goal = this.goal;
|
Goal goal = this.goal;
|
||||||
if (goal == null) {
|
if (goal == null) {
|
||||||
displayChatMessageRaw("no goal");
|
logDebug("no goal");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
if (Baritone.settings().simplifyUnloadedYCoord.get()) {
|
if (Baritone.settings().simplifyUnloadedYCoord.get()) {
|
||||||
@ -320,7 +320,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
}
|
}
|
||||||
// TODO simplify each individual goal in a GoalComposite
|
// TODO simplify each individual goal in a GoalComposite
|
||||||
if (pos != null && world().getChunk(pos) instanceof EmptyChunk) {
|
if (pos != null && world().getChunk(pos) instanceof EmptyChunk) {
|
||||||
displayChatMessageRaw("Simplifying " + goal.getClass() + " to GoalXZ due to distance");
|
logDebug("Simplifying " + goal.getClass() + " to GoalXZ due to distance");
|
||||||
goal = new GoalXZ(pos.getX(), pos.getZ());
|
goal = new GoalXZ(pos.getX(), pos.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +334,7 @@ public class PathingBehavior extends Behavior {
|
|||||||
IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions));
|
IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions));
|
||||||
return pf.calculate(timeout);
|
return pf.calculate(timeout);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
displayChatMessageRaw("Pathing exception: " + e);
|
logDebug("Pathing exception: " + e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
long startTime = System.nanoTime() / 1000000L;
|
long startTime = System.nanoTime() / 1000000L;
|
||||||
boolean slowPath = Baritone.settings().slowPath.get();
|
boolean slowPath = Baritone.settings().slowPath.get();
|
||||||
if (slowPath) {
|
if (slowPath) {
|
||||||
displayChatMessageRaw("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.<Long>get() + "ms instead of " + timeout + "ms");
|
logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.<Long>get() + "ms instead of " + timeout + "ms");
|
||||||
}
|
}
|
||||||
long timeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.<Long>get() : timeout);
|
long timeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.<Long>get() : timeout);
|
||||||
//long lastPrintout = 0;
|
//long lastPrintout = 0;
|
||||||
@ -102,7 +102,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
numNodes++;
|
numNodes++;
|
||||||
if (goal.isInGoal(currentNodePos)) {
|
if (goal.isInGoal(currentNodePos)) {
|
||||||
currentlyRunning = null;
|
currentlyRunning = null;
|
||||||
displayChatMessageRaw("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered");
|
logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, " + numMovementsConsidered + " movements considered");
|
||||||
return Optional.of(new Path(startNode, currentNode, numNodes));
|
return Optional.of(new Path(startNode, currentNode, numNodes));
|
||||||
}
|
}
|
||||||
Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order
|
Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order
|
||||||
@ -191,7 +191,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
bestDist = dist;
|
bestDist = dist;
|
||||||
}
|
}
|
||||||
if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared
|
if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared
|
||||||
displayChatMessageRaw("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i] + ", " + numMovementsConsidered + " movements considered");
|
logDebug("Took " + (System.nanoTime() / 1000000L - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i] + ", " + numMovementsConsidered + " movements considered");
|
||||||
if (COEFFICIENTS[i] >= 3) {
|
if (COEFFICIENTS[i] >= 3) {
|
||||||
System.out.println("Warning: cost coefficient is greater than three! Probably means that");
|
System.out.println("Warning: cost coefficient is greater than three! Probably means that");
|
||||||
System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)");
|
System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)");
|
||||||
@ -202,8 +202,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
return Optional.of(new Path(startNode, bestSoFar[i], numNodes));
|
return Optional.of(new Path(startNode, bestSoFar[i], numNodes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayChatMessageRaw("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks");
|
logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks");
|
||||||
displayChatMessageRaw("No path found =(");
|
logDebug("No path found =(");
|
||||||
currentlyRunning = null;
|
currentlyRunning = null;
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class MovementPillar extends Movement {
|
|||||||
if (ladder) {
|
if (ladder) {
|
||||||
BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
||||||
if (against == null) {
|
if (against == null) {
|
||||||
displayChatMessageRaw("Unable to climb vines");
|
logDebug("Unable to climb vines");
|
||||||
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public class MovementTraverse extends Movement {
|
|||||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionToPlace) || ladder;
|
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionToPlace) || ladder;
|
||||||
BlockPos whereAmI = playerFeet();
|
BlockPos whereAmI = playerFeet();
|
||||||
if (whereAmI.getY() != dest.getY() && !ladder) {
|
if (whereAmI.getY() != dest.getY() && !ladder) {
|
||||||
displayChatMessageRaw("Wrong Y coordinate");
|
logDebug("Wrong Y coordinate");
|
||||||
if (whereAmI.getY() < dest.getY()) {
|
if (whereAmI.getY() < dest.getY()) {
|
||||||
state.setInput(InputOverrideHandler.Input.JUMP, true);
|
state.setInput(InputOverrideHandler.Input.JUMP, true);
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ public class MovementTraverse extends Movement {
|
|||||||
against1 = against1.down();
|
against1 = against1.down();
|
||||||
if (MovementHelper.canPlaceAgainst(against1)) {
|
if (MovementHelper.canPlaceAgainst(against1)) {
|
||||||
if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block
|
if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block
|
||||||
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
logDebug("bb pls get me some blocks. dirt or cobble");
|
||||||
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
||||||
@ -240,7 +240,7 @@ public class MovementTraverse extends Movement {
|
|||||||
// If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
|
// If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
|
||||||
// Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
|
// Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI);
|
||||||
if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block
|
if (!MovementHelper.throwaway(true)) {// get ready to place a throwaway block
|
||||||
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
logDebug("bb pls get me some blocks. dirt or cobble");
|
||||||
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;
|
double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D;
|
||||||
|
@ -128,12 +128,12 @@ public interface IPath extends Helper {
|
|||||||
for (int i = 0; i < positions().size(); i++) {
|
for (int i = 0; i < positions().size(); i++) {
|
||||||
BlockPos pos = positions().get(i);
|
BlockPos pos = positions().get(i);
|
||||||
if (Minecraft.getMinecraft().world.getChunk(pos) instanceof EmptyChunk) {
|
if (Minecraft.getMinecraft().world.getChunk(pos) instanceof EmptyChunk) {
|
||||||
displayChatMessageRaw("Cutting off path at edge of loaded chunks");
|
logDebug("Cutting off path at edge of loaded chunks");
|
||||||
displayChatMessageRaw("Length decreased by " + (positions().size() - i - 1));
|
logDebug("Length decreased by " + (positions().size() - i - 1));
|
||||||
return new CutoffPath(this, i);
|
return new CutoffPath(this, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayChatMessageRaw("Path ends within loaded chunks");
|
logDebug("Path ends within loaded chunks");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public interface IPath extends Helper {
|
|||||||
}
|
}
|
||||||
double factor = Baritone.settings().pathCutoffFactor.get();
|
double factor = Baritone.settings().pathCutoffFactor.get();
|
||||||
int newLength = (int) (length() * factor);
|
int newLength = (int) (length() * factor);
|
||||||
//displayChatMessageRaw("Static cutoff " + length() + " to " + newLength);
|
//logDebug("Static cutoff " + length() + " to " + newLength);
|
||||||
return new CutoffPath(this, newLength);
|
return new CutoffPath(this, newLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class PathExecutor implements Helper {
|
|||||||
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
||||||
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
||||||
if (whereAmI.equals(path.positions().get(i))) {
|
if (whereAmI.equals(path.positions().get(i))) {
|
||||||
displayChatMessageRaw("Skipping back " + (pathPosition - i) + " steps, to " + i);
|
logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i);
|
||||||
int previousPos = pathPosition;
|
int previousPos = pathPosition;
|
||||||
pathPosition = Math.max(i - 1, 0); // previous step might not actually be done
|
pathPosition = Math.max(i - 1, 0); // previous step might not actually be done
|
||||||
for (int j = pathPosition; j <= previousPos; j++) {
|
for (int j = pathPosition; j <= previousPos; j++) {
|
||||||
@ -105,7 +105,7 @@ public class PathExecutor implements Helper {
|
|||||||
for (int i = pathPosition + 2; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing)
|
for (int i = pathPosition + 2; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing)
|
||||||
if (whereAmI.equals(path.positions().get(i))) {
|
if (whereAmI.equals(path.positions().get(i))) {
|
||||||
if (i - pathPosition > 2) {
|
if (i - pathPosition > 2) {
|
||||||
displayChatMessageRaw("Skipping forward " + (i - pathPosition) + " steps, to " + i);
|
logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i);
|
||||||
}
|
}
|
||||||
System.out.println("Double skip sundae");
|
System.out.println("Double skip sundae");
|
||||||
pathPosition = i - 1;
|
pathPosition = i - 1;
|
||||||
@ -121,7 +121,7 @@ public class PathExecutor implements Helper {
|
|||||||
ticksAway++;
|
ticksAway++;
|
||||||
System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + distanceFromPath + ". Threshold: " + MAX_DIST_FROM_PATH);
|
System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + distanceFromPath + ". Threshold: " + MAX_DIST_FROM_PATH);
|
||||||
if (ticksAway > MAX_TICKS_AWAY) {
|
if (ticksAway > MAX_TICKS_AWAY) {
|
||||||
displayChatMessageRaw("Too far away from path for too long, cancelling path");
|
logDebug("Too far away from path for too long, cancelling path");
|
||||||
System.out.println("Too many ticks");
|
System.out.println("Too many ticks");
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
@ -134,7 +134,7 @@ public class PathExecutor implements Helper {
|
|||||||
if (distanceFromPath > MAX_MAX_DIST_FROM_PATH) {
|
if (distanceFromPath > MAX_MAX_DIST_FROM_PATH) {
|
||||||
if (!(path.movements().get(pathPosition) instanceof MovementFall)) { // might be midair
|
if (!(path.movements().get(pathPosition) instanceof MovementFall)) { // might be midair
|
||||||
if (pathPosition == 0 || !(path.movements().get(pathPosition - 1) instanceof MovementFall)) { // might have overshot the landing
|
if (pathPosition == 0 || !(path.movements().get(pathPosition - 1) instanceof MovementFall)) { // might have overshot the landing
|
||||||
displayChatMessageRaw("too far from path");
|
logDebug("too far from path");
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
failed = true;
|
failed = true;
|
||||||
@ -211,7 +211,7 @@ public class PathExecutor implements Helper {
|
|||||||
}
|
}
|
||||||
long end = System.nanoTime() / 1000000L;
|
long end = System.nanoTime() / 1000000L;
|
||||||
if (end - start > 0) {
|
if (end - start > 0) {
|
||||||
//displayChatMessageRaw("Recalculating break and place took " + (end - start) + "ms");
|
//logDebug("Recalculating break and place took " + (end - start) + "ms");
|
||||||
}
|
}
|
||||||
Movement movement = path.movements().get(pathPosition);
|
Movement movement = path.movements().get(pathPosition);
|
||||||
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
|
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
|
||||||
@ -220,7 +220,7 @@ public class PathExecutor implements Helper {
|
|||||||
currentMovementInitialCostEstimate = movement.getCost(null);
|
currentMovementInitialCostEstimate = movement.getCost(null);
|
||||||
for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) {
|
for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) {
|
||||||
if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) {
|
if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF) {
|
||||||
displayChatMessageRaw("Something has changed in the world and a future movement has become impossible. Cancelling.");
|
logDebug("Something has changed in the world and a future movement has become impossible. Cancelling.");
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
failed = true;
|
failed = true;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
@ -230,7 +230,7 @@ public class PathExecutor implements Helper {
|
|||||||
}
|
}
|
||||||
double currentCost = movement.recalculateCost();
|
double currentCost = movement.recalculateCost();
|
||||||
if (currentCost >= ActionCosts.COST_INF) {
|
if (currentCost >= ActionCosts.COST_INF) {
|
||||||
displayChatMessageRaw("Something has changed in the world and this movement has become impossible. Cancelling.");
|
logDebug("Something has changed in the world and this movement has become impossible. Cancelling.");
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
failed = true;
|
failed = true;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
@ -238,7 +238,7 @@ public class PathExecutor implements Helper {
|
|||||||
}
|
}
|
||||||
MovementState.MovementStatus movementStatus = movement.update();
|
MovementState.MovementStatus movementStatus = movement.update();
|
||||||
if (movementStatus == UNREACHABLE || movementStatus == FAILED) {
|
if (movementStatus == UNREACHABLE || movementStatus == FAILED) {
|
||||||
displayChatMessageRaw("Movement returns status " + movementStatus);
|
logDebug("Movement returns status " + movementStatus);
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
failed = true;
|
failed = true;
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
@ -259,7 +259,7 @@ public class PathExecutor implements Helper {
|
|||||||
// as you break the blocks required, the remaining cost goes down, to the point where
|
// as you break the blocks required, the remaining cost goes down, to the point where
|
||||||
// ticksOnCurrent is greater than recalculateCost + 100
|
// ticksOnCurrent is greater than recalculateCost + 100
|
||||||
// this is why we cache cost at the beginning, and don't recalculate for this comparison every tick
|
// this is why we cache cost at the beginning, and don't recalculate for this comparison every tick
|
||||||
displayChatMessageRaw("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling.");
|
logDebug("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling.");
|
||||||
movement.cancel();
|
movement.cancel();
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
|
||||||
pathPosition = path.length() + 3;
|
pathPosition = path.length() + 3;
|
||||||
@ -318,7 +318,7 @@ public class PathExecutor implements Helper {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//displayChatMessageRaw("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));
|
||||||
}
|
}
|
||||||
player().setSprinting(false);
|
player().setSprinting(false);
|
||||||
}
|
}
|
||||||
|
@ -92,26 +92,26 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2])));
|
goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2])));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
displayChatMessageRaw("unable to understand lol");
|
logDirect("unable to understand lol");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
displayChatMessageRaw("unable to parse integer " + ex);
|
logDirect("unable to parse integer " + ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
displayChatMessageRaw("Goal: " + goal);
|
logDirect("Goal: " + goal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.equals("path")) {
|
if (msg.equals("path")) {
|
||||||
if (!PathingBehavior.INSTANCE.path()) {
|
if (!PathingBehavior.INSTANCE.path()) {
|
||||||
if (PathingBehavior.INSTANCE.getGoal() == null) {
|
if (PathingBehavior.INSTANCE.getGoal() == null) {
|
||||||
displayChatMessageRaw("No goal.");
|
logDirect("No goal.");
|
||||||
} else {
|
} else {
|
||||||
if (PathingBehavior.INSTANCE.getGoal().isInGoal(playerFeet())) {
|
if (PathingBehavior.INSTANCE.getGoal().isInGoal(playerFeet())) {
|
||||||
displayChatMessageRaw("Already in goal");
|
logDirect("Already in goal");
|
||||||
} else {
|
} else {
|
||||||
displayChatMessageRaw("Currently executing a path. Please cancel it first.");
|
logDirect("Currently executing a path. Please cancel it first.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,13 +123,13 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
FollowBehavior.INSTANCE.cancel();
|
FollowBehavior.INSTANCE.cancel();
|
||||||
MineBehavior.INSTANCE.cancel();
|
MineBehavior.INSTANCE.cancel();
|
||||||
event.cancel();
|
event.cancel();
|
||||||
displayChatMessageRaw("ok canceled");
|
logDirect("ok canceled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("forcecancel")) {
|
if (msg.toLowerCase().equals("forcecancel")) {
|
||||||
AbstractNodeCostSearch.forceCancel();
|
AbstractNodeCostSearch.forceCancel();
|
||||||
event.cancel();
|
event.cancel();
|
||||||
displayChatMessageRaw("ok force canceled");
|
logDirect("ok force canceled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("invert")) {
|
if (msg.toLowerCase().equals("invert")) {
|
||||||
@ -140,8 +140,8 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
} else if (goal instanceof GoalBlock) {
|
} else if (goal instanceof GoalBlock) {
|
||||||
runAwayFrom = ((GoalBlock) goal).getGoalPos();
|
runAwayFrom = ((GoalBlock) goal).getGoalPos();
|
||||||
} else {
|
} else {
|
||||||
displayChatMessageRaw("Goal must be GoalXZ or GoalBlock to invert");
|
logDirect("Goal must be GoalXZ or GoalBlock to invert");
|
||||||
displayChatMessageRaw("Inverting goal of player feet");
|
logDirect("Inverting goal of player feet");
|
||||||
runAwayFrom = playerFeet();
|
runAwayFrom = playerFeet();
|
||||||
}
|
}
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalRunAway(1, runAwayFrom) {
|
PathingBehavior.INSTANCE.setGoal(new GoalRunAway(1, runAwayFrom) {
|
||||||
@ -151,7 +151,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!PathingBehavior.INSTANCE.path()) {
|
if (!PathingBehavior.INSTANCE.path()) {
|
||||||
displayChatMessageRaw("Currently executing a path. Please cancel it first.");
|
logDirect("Currently executing a path. Please cancel it first.");
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
@ -159,31 +159,31 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
if (msg.toLowerCase().equals("follow")) {
|
if (msg.toLowerCase().equals("follow")) {
|
||||||
Optional<Entity> entity = MovementHelper.whatEntityAmILookingAt();
|
Optional<Entity> entity = MovementHelper.whatEntityAmILookingAt();
|
||||||
if (!entity.isPresent()) {
|
if (!entity.isPresent()) {
|
||||||
displayChatMessageRaw("You aren't looking at an entity bruh");
|
logDirect("You aren't looking at an entity bruh");
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FollowBehavior.INSTANCE.follow(entity.get());
|
FollowBehavior.INSTANCE.follow(entity.get());
|
||||||
displayChatMessageRaw("Following " + entity.get());
|
logDirect("Following " + entity.get());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("reloadall")) {
|
if (msg.toLowerCase().equals("reloadall")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk();
|
WorldProvider.INSTANCE.getCurrentWorld().cache.reloadAllFromDisk();
|
||||||
displayChatMessageRaw("ok");
|
logDirect("ok");
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("saveall")) {
|
if (msg.toLowerCase().equals("saveall")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().cache.save();
|
WorldProvider.INSTANCE.getCurrentWorld().cache.save();
|
||||||
displayChatMessageRaw("ok");
|
logDirect("ok");
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().startsWith("find")) {
|
if (msg.toLowerCase().startsWith("find")) {
|
||||||
String blockType = msg.toLowerCase().substring(4).trim();
|
String blockType = msg.toLowerCase().substring(4).trim();
|
||||||
LinkedList<BlockPos> locs = WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(blockType, 1, 4);
|
LinkedList<BlockPos> locs = WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(blockType, 1, 4);
|
||||||
displayChatMessageRaw("Have " + locs.size() + " locations");
|
logDirect("Have " + locs.size() + " locations");
|
||||||
for (BlockPos pos : locs) {
|
for (BlockPos pos : locs) {
|
||||||
Block actually = BlockStateInterface.get(pos).getBlock();
|
Block actually = BlockStateInterface.get(pos).getBlock();
|
||||||
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) {
|
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) {
|
||||||
@ -197,20 +197,20 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
String[] blockTypes = msg.toLowerCase().substring(4).trim().split(" ");
|
String[] blockTypes = msg.toLowerCase().substring(4).trim().split(" ");
|
||||||
for (String s : blockTypes) {
|
for (String s : blockTypes) {
|
||||||
if (ChunkPacker.stringToBlock(s) == null) {
|
if (ChunkPacker.stringToBlock(s) == null) {
|
||||||
displayChatMessageRaw(s + " isn't a valid block name");
|
logDirect(s + " isn't a valid block name");
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MineBehavior.INSTANCE.mine(blockTypes);
|
MineBehavior.INSTANCE.mine(blockTypes);
|
||||||
displayChatMessageRaw("Started mining blocks of type " + Arrays.toString(blockTypes));
|
logDirect("Started mining blocks of type " + Arrays.toString(blockTypes));
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().startsWith("thisway")) {
|
if (msg.toLowerCase().startsWith("thisway")) {
|
||||||
Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim()));
|
Goal goal = GoalXZ.fromDirection(playerFeetAsVec(), player().rotationYaw, Double.parseDouble(msg.substring(7).trim()));
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
displayChatMessageRaw("Goal: " + goal);
|
logDirect("Goal: " + goal);
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
}
|
}
|
||||||
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,9 +230,9 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
// might as well show them from oldest to newest
|
// might as well show them from oldest to newest
|
||||||
List<Waypoint> sorted = new ArrayList<>(waypoints);
|
List<Waypoint> sorted = new ArrayList<>(waypoints);
|
||||||
sorted.sort(Comparator.comparingLong(Waypoint::creationTimestamp));
|
sorted.sort(Comparator.comparingLong(Waypoint::creationTimestamp));
|
||||||
displayChatMessageRaw("Waypoints under tag " + tag + ":");
|
logDirect("Waypoints under tag " + tag + ":");
|
||||||
for (Waypoint waypoint : sorted) {
|
for (Waypoint waypoint : sorted) {
|
||||||
displayChatMessageRaw(waypoint.toString());
|
logDirect(waypoint.toString());
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
@ -246,15 +246,15 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
String mining = waypointType;
|
String mining = waypointType;
|
||||||
//displayChatMessageRaw("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
if (ChunkPacker.stringToBlock(mining) == null) {
|
if (ChunkPacker.stringToBlock(mining) == null) {
|
||||||
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = MineBehavior.scanFor(Arrays.asList(mining), 64);
|
List<BlockPos> locs = MineBehavior.scanFor(Arrays.asList(mining), 64);
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new)));
|
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new)));
|
||||||
@ -263,7 +263,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
}
|
}
|
||||||
Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag);
|
Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(tag);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
displayChatMessageRaw("None saved for tag " + tag);
|
logDirect("None saved for tag " + tag);
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
if (!PathingBehavior.INSTANCE.path()) {
|
if (!PathingBehavior.INSTANCE.path()) {
|
||||||
if (!goal.isInGoal(playerFeet())) {
|
if (!goal.isInGoal(playerFeet())) {
|
||||||
displayChatMessageRaw("Currently executing a path. Please cancel it first.");
|
logDirect("Currently executing a path. Please cancel it first.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
@ -283,30 +283,30 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
BlockPos spawnPoint = player().getBedLocation();
|
BlockPos spawnPoint = player().getBedLocation();
|
||||||
// for some reason the default spawnpoint is underground sometimes
|
// for some reason the default spawnpoint is underground sometimes
|
||||||
Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getZ());
|
Goal goal = new GoalXZ(spawnPoint.getX(), spawnPoint.getZ());
|
||||||
displayChatMessageRaw("spawn not saved, defaulting to world spawn. set goal to " + goal);
|
logDirect("spawn not saved, defaulting to world spawn. set goal to " + goal);
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
} else {
|
} else {
|
||||||
Goal goal = new GoalBlock(waypoint.location);
|
Goal goal = new GoalBlock(waypoint.location);
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
displayChatMessageRaw("Set goal to most recent bed " + goal);
|
logDirect("Set goal to most recent bed " + goal);
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("sethome")) {
|
if (msg.toLowerCase().equals("sethome")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet()));
|
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet()));
|
||||||
displayChatMessageRaw("Saved. Say home to set goal.");
|
logDirect("Saved. Say home to set goal.");
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("home")) {
|
if (msg.toLowerCase().equals("home")) {
|
||||||
Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME);
|
Waypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().waypoints.getMostRecentByTag(Waypoint.Tag.HOME);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
displayChatMessageRaw("home not saved");
|
logDirect("home not saved");
|
||||||
} else {
|
} else {
|
||||||
Goal goal = new GoalBlock(waypoint.location);
|
Goal goal = new GoalBlock(waypoint.location);
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
displayChatMessageRaw("Set goal to saved home " + goal);
|
logDirect("Set goal to saved home " + goal);
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
@ -325,7 +325,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
if (cost >= ActionCosts.COST_INF) {
|
if (cost >= ActionCosts.COST_INF) {
|
||||||
strCost = "IMPOSSIBLE";
|
strCost = "IMPOSSIBLE";
|
||||||
}
|
}
|
||||||
displayChatMessageRaw(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
|
logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
@ -335,13 +335,13 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
if (msg.equalsIgnoreCase(setting.getName())) {
|
if (msg.equalsIgnoreCase(setting.getName())) {
|
||||||
setting.value ^= true;
|
setting.value ^= true;
|
||||||
event.cancel();
|
event.cancel();
|
||||||
displayChatMessageRaw("Toggled " + setting.getName() + " to " + setting.value);
|
logDirect("Toggled " + setting.getName() + " to " + setting.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.toLowerCase().equals("baritone") || msg.toLowerCase().equals("settings")) {
|
if (msg.toLowerCase().equals("baritone") || msg.toLowerCase().equals("settings")) {
|
||||||
for (Settings.Setting<?> setting : Baritone.settings().allSettings) {
|
for (Settings.Setting<?> setting : Baritone.settings().allSettings) {
|
||||||
displayChatMessageRaw(setting.toString());
|
logDirect(setting.toString());
|
||||||
}
|
}
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
@ -362,11 +362,11 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
setting.value = Double.parseDouble(data[1]);
|
setting.value = Double.parseDouble(data[1]);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
displayChatMessageRaw("Unable to parse " + data[1]);
|
logDirect("Unable to parse " + data[1]);
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
displayChatMessageRaw(setting.toString());
|
logDirect(setting.toString());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -374,7 +374,7 @@ public class ExampleBaritoneControl extends Behavior {
|
|||||||
}
|
}
|
||||||
if (Baritone.settings().byLowerName.containsKey(msg.toLowerCase())) {
|
if (Baritone.settings().byLowerName.containsKey(msg.toLowerCase())) {
|
||||||
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg.toLowerCase());
|
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg.toLowerCase());
|
||||||
displayChatMessageRaw(setting.toString());
|
logDirect(setting.toString());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -73,15 +73,24 @@ public interface Helper {
|
|||||||
return new Rotation(player().rotationYaw, player().rotationPitch);
|
return new Rotation(player().rotationYaw, player().rotationPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void displayChatMessageRaw(String message) {
|
/**
|
||||||
|
* Send a message to chat only if chatDebug is on
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
default void logDebug(String message) {
|
||||||
if (!Baritone.settings().chatDebug.get()) {
|
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);
|
||||||
/*if (!Stream.of(Thread.currentThread().getStackTrace()).map(StackTraceElement::getClassName).anyMatch(x -> x.equals(ExampleBaritoneControl.class.getName()))) {
|
return;
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
logDirect(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command)
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
default void logDirect(String message) {
|
||||||
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(new TextComponentString(" " + message));
|
component.appendSibling(new TextComponentString(" " + message));
|
||||||
|
Loading…
Reference in New Issue
Block a user