use of baritone.api.pathing.goals.GoalXZ in project JexClient by DustinRepo.
the class UnsafeBaritoneHelper method pathTo.
protected static void pathTo(int x, int z) {
Goal goal = new GoalXZ(x, z);
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(goal);
}
use of baritone.api.pathing.goals.GoalXZ in project Client by MatHax.
the class SwarmCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("disconnect").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive())
swarm.close();
else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}));
builder.then(literal("join").then(argument("ip", StringArgumentType.string()).then(argument("port", IntegerArgumentType.integer(0, 65535)).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (!swarm.isActive())
swarm.toggle();
swarm.close();
swarm.mode.set(Swarm.Mode.Worker);
swarm.worker = new SwarmWorker(StringArgumentType.getString(context, "ip"), IntegerArgumentType.getInteger(context, "port"));
return SINGLE_SUCCESS;
}))));
builder.then(literal("connections").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost()) {
if (swarm.host.getConnectionCount() > 0) {
ChatUtils.info("--- Swarm Connections (highlight)(%s/%s)(default) ---", swarm.host.getConnectionCount(), swarm.host.getConnections().length);
for (int i = 0; i < swarm.host.getConnections().length; i++) {
SwarmConnection connection = swarm.host.getConnections()[i];
if (connection != null)
ChatUtils.info("(highlight)Worker %s(default): %s.", i, connection.getConnection());
}
} else
warning("No active connections");
} else if (swarm.isWorker())
info("Connected to (highlight)%s", swarm.worker.getConnection());
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}));
builder.then(literal("follow").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput() + " " + mc.player.getEntityName());
else if (swarm.isWorker())
error("The follow host command must be used by the host.");
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}).then(argument("player", PlayerArgumentType.player()).executes(context -> {
PlayerEntity playerEntity = PlayerArgumentType.getPlayer(context);
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker() && playerEntity != null)
BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName()));
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
})));
builder.then(literal("goto").then(argument("x", IntegerArgumentType.integer()).then(argument("z", IntegerArgumentType.integer()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
int x = IntegerArgumentType.getInteger(context, "x");
int z = IntegerArgumentType.getInteger(context, "z");
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(x, z));
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}))));
builder.then(literal("infinity-miner").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
runInfinityMiner();
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}).then(argument("target", BlockStateArgumentType.blockState()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
runInfinityMiner();
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}).then(argument("repair", BlockStateArgumentType.blockState()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
Modules.get().get(InfinityMiner.class).targetBlocks.set(List.of(context.getArgument("target", BlockStateArgument.class).getBlockState().getBlock()));
Modules.get().get(InfinityMiner.class).repairBlocks.set(List.of(context.getArgument("repair", BlockStateArgument.class).getBlockState().getBlock()));
runInfinityMiner();
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}))).then(literal("logout").then(argument("logout", BoolArgumentType.bool()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
Modules.get().get(InfinityMiner.class).logOut.set(BoolArgumentType.getBool(context, "logout"));
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}))).then(literal("walkhome").then(argument("walkhome", BoolArgumentType.bool()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
Modules.get().get(InfinityMiner.class).walkHome.set(BoolArgumentType.getBool(context, "walkhome"));
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}))));
builder.then(literal("mine").then(argument("block", BlockStateArgumentType.blockState()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
swarm.worker.target = context.getArgument("block", BlockStateArgument.class).getBlockState().getBlock();
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
})));
builder.then(literal("toggle").then(argument("module", ModuleArgumentType.module()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
Module module = ModuleArgumentType.getModule(context, "module");
module.toggle();
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}).then(literal("on").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
Module m = ModuleArgumentType.getModule(context, "module");
if (!m.isActive())
m.toggle();
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
})).then(literal("off").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker()) {
Module m = ModuleArgumentType.getModule(context, "module");
if (m.isActive())
m.toggle();
}
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}))));
builder.then(literal("scatter").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
scatter(100);
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}).then(argument("radius", IntegerArgumentType.integer()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
scatter(IntegerArgumentType.getInteger(context, "radius"));
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
})));
builder.then(literal("stop").executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
}));
builder.then(literal("exec").then(argument("command", StringArgumentType.greedyString()).executes(context -> {
Swarm swarm = Modules.get().get(Swarm.class);
if (swarm.isActive()) {
if (swarm.isHost())
swarm.host.sendMessage(context.getInput());
else if (swarm.isWorker())
mc.player.sendChatMessage(StringArgumentType.getString(context, "command"));
} else
throw SWARM_NOT_ACTIVE.create();
return SINGLE_SUCCESS;
})));
}
use of baritone.api.pathing.goals.GoalXZ in project postman by srgantmoomoo.
the class Baritone method onCommand.
@Override
public void onCommand(String[] args, String command) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("stop")) {
BaritoneAPI.getProvider().getPrimaryBaritone().getMineProcess().cancel();
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(null);
Main.INSTANCE.commandManager.sendClientChatMessage("baritone has now " + ChatFormatting.GREEN + "stopped" + ChatFormatting.WHITE + ".", true);
} else if (args[0].equalsIgnoreCase("farm")) {
BaritoneAPI.getProvider().getPrimaryBaritone().getFarmProcess().farm();
Main.INSTANCE.commandManager.sendClientChatMessage("baritone is now " + ChatFormatting.GREEN + "farming" + ChatFormatting.WHITE + ".", true);
} else
Main.INSTANCE.commandManager.sendCorrectionMessage(getName(), getSyntax());
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("mine")) {
String block = args[1];
try {
BaritoneAPI.getProvider().getPrimaryBaritone().getMineProcess().mineByName(block);
Main.INSTANCE.commandManager.sendClientChatMessage("baritone is now mining " + ChatFormatting.GREEN + block + ChatFormatting.WHITE + ".", true);
} catch (Exception e) {
Main.INSTANCE.commandManager.sendClientChatMessage("baritone could not find that block. :(", true);
}
} else
Main.INSTANCE.commandManager.sendCorrectionMessage(getName(), getSyntax());
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("goto")) {
String x = args[1];
String z = args[2];
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(Integer.parseInt(x), Integer.parseInt(z)));
Main.INSTANCE.commandManager.sendClientChatMessage("baritone is now pathing to " + ChatFormatting.GREEN + x + " " + z + ChatFormatting.WHITE + ".", true);
} else
Main.INSTANCE.commandManager.sendCorrectionMessage(getName(), getSyntax());
} else
Main.INSTANCE.commandManager.sendCorrectionMessage(getName(), getSyntax());
}
use of baritone.api.pathing.goals.GoalXZ in project Spark-Client by Spark-Client-Development.
the class GuiEditSettingPanel method setCurrentSettingsHolder.
public void setCurrentSettingsHolder(SettingsHolder currentSettingsHolder) {
this.currentSettingsHolder = currentSettingsHolder;
guiEditSettingPanelHolder.groups = new ArrayList<>();
if (currentSettingsHolder != null) {
ArrayList<String> groups = new ArrayList<>();
for (Setting s : currentSettingsHolder.getSettings()) {
if (!groups.contains(s.getCategory()))
groups.add(s.getCategory());
}
for (String group : groups) {
ArrayList<GuiSettingPanel> settings = new ArrayList<>();
for (Setting s : currentSettingsHolder.getSettings()) {
if (s.getCategory().equals(group)) {
if (s instanceof IntSetting)
settings.add(new GuiIntSettingPanel((IntSetting) s));
if (s instanceof DoubleSetting)
settings.add(new GuiDoubleSettingPanel((DoubleSetting) s));
if (s instanceof BooleanSetting)
settings.add(new GuiBooleanSettingPanel((BooleanSetting) s));
if (s instanceof ModeSetting)
settings.add(new GuiEnumSettingPanel((ModeSetting) s));
if (s instanceof KeySetting)
settings.add(new GuiKeySettingPanel((KeySetting) s));
if (s instanceof ColorSetting)
settings.add(new GuiColorSettingPanel((ColorSetting) s));
if (s instanceof StringSetting)
settings.add(new GuiStringSettingPanel((StringSetting) s));
if (s instanceof ListSelectSetting)
settings.add(new GuiListSettingPanel((ListSelectSetting) s));
if (s instanceof VectorSetting)
settings.add(new GuiVectorSettingPanel((VectorSetting) s));
}
}
GuiEditSettingPanelGroup g = new GuiEditSettingPanelGroup(group, guiEditSettingPanelHolder, settings);
g.setExtended(groups.size() <= 4);
guiEditSettingPanelHolder.groups.add(g);
}
buttonFunction = null;
if (currentSettingsHolder instanceof InventoryManager) {
buttonFunction = buttonFunction = new GuiPanelButton[] { new GuiPanelButton(() -> {
mc.displayGuiScreen(new KitSettingGui(Spark.clickGuiScreen));
}, "Kit Editor") };
}
if (currentSettingsHolder instanceof HudElement) {
buttonFunction = new GuiPanelButton[] { new GuiPanelButton(() -> {
HudElement h = (HudElement) currentSettingsHolder;
h.resetPos();
}, "Reset Location") };
}
if (currentSettingsHolder instanceof ConfigManager.Config) {
buttonFunction = new GuiPanelButton[] { new GuiPanelButton(() -> {
Spark.configManager.deleteConfig((ConfigManager.Config) currentSettingsHolder);
}, "Delete"), new GuiPanelButton(() -> {
Spark.configManager.loadConfig((ConfigManager.Config) currentSettingsHolder, true);
}, "Load") };
}
if (currentSettingsHolder instanceof WaypointManager.Waypoint) {
buttonFunction = new GuiPanelButton[] { new GuiPanelButton(() -> {
WaypointManager.Waypoint waypoint = (WaypointManager.Waypoint) currentSettingsHolder;
Spark.waypointManager.getWayPoints().remove(waypoint);
}, "Delete"), new GuiPanelButton(() -> {
WaypointManager.Waypoint waypoint = (WaypointManager.Waypoint) currentSettingsHolder;
Vec3i v = waypoint.getLocation();
Spark.sendInfo("Going to " + waypoint.getName());
if (waypoint.hasY())
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(v.getX(), v.getY(), v.getZ())));
else
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(v.getX(), v.getZ()));
mc.displayGuiScreen(null);
}, "Goto") };
}
}
}
use of baritone.api.pathing.goals.GoalXZ in project Spark-Client by Spark-Client-Development.
the class PathingBehavior method createPathfinder.
private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
Goal transformed = goal;
if (Baritone.settings().simplifyUnloadedYCoord.getValue() && goal instanceof IGoalRenderPos) {
BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) {
transformed = new GoalXZ(pos.getX(), pos.getZ());
}
}
Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
}
Aggregations