Minor clean ups in PathingBehavior

This commit is contained in:
Brady 2018-08-05 18:56:21 -05:00
parent 379d358408
commit 8ef9f9db70
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 32 additions and 41 deletions

View File

@ -3,7 +3,6 @@ package baritone.bot.behavior.impl;
import baritone.bot.behavior.Behavior;
import baritone.bot.event.events.ChatEvent;
import baritone.bot.event.events.RenderEvent;
import baritone.bot.event.events.TickEvent;
import baritone.bot.pathing.calc.AStarPathFinder;
import baritone.bot.pathing.calc.IPathFinder;
import baritone.bot.pathing.goals.Goal;
@ -35,7 +34,7 @@ public class PathingBehavior extends Behavior {
private Goal goal;
@Override
public void onTick(TickEvent event) {
public void onTick() {
// System.out.println("Ticking");
if (current == null) {
return;
@ -57,16 +56,12 @@ public class PathingBehavior extends Behavior {
return current.getPath();
}
private static void chatRaw(String s) {
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(s));
}
@Override
public void onSendChatMessage(ChatEvent event) {
String msg = event.getMessage();
if (msg.equals("goal")) {
goal = new GoalBlock(playerFeet());
chatRaw("Goal: " + goal);
displayChatMessageRaw("Goal: " + goal);
event.cancel();
return;
}
@ -85,13 +80,9 @@ public class PathingBehavior extends Behavior {
* @param talkAboutIt
*/
public void findPathInNewThread(final BlockPos start, final boolean talkAboutIt) {
new Thread() {
@Override
public void run() {
new Thread(() -> {
if (talkAboutIt) {
chatRaw("Starting to search for path from " + start + " to " + goal);
displayChatMessageRaw("Starting to search for path from " + start + " to " + goal);
}
try {
@ -99,8 +90,7 @@ public class PathingBehavior extends Behavior {
if (path != null) {
current = new PathExecutor(path);
}
} catch (Exception e) {
}
} catch (Exception ignored) {}
/*isThereAnythingInProgress = false;
if (!currentPath.goal.isInGoal(currentPath.end)) {
if (talkAboutIt) {
@ -110,8 +100,7 @@ public class PathingBehavior extends Behavior {
} else if (talkAboutIt) {
Out.gui("Finished finding a path from " + start + " to " + goal + ". " + currentPath.numNodes + " nodes considered", Out.Mode.Debug);
}*/
}
}.start();
}).start();
}
/**
@ -122,7 +111,7 @@ public class PathingBehavior extends Behavior {
*/
private IPath findPath(BlockPos start) {
if (goal == null) {
chatRaw("no goal");
displayChatMessageRaw("no goal");
return null;
}
try {
@ -187,6 +176,4 @@ public class PathingBehavior extends Behavior {
worldrenderer.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex();
tessellator.draw();
}
}

View File

@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
/**
* @author Brady
@ -25,4 +26,7 @@ public interface Helper {
return new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ);
}
default void displayChatMessageRaw(String message) {
mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message));
}
}