Search in sources :

Example 6 with GoalXZ

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);
}
Also used : Goal(baritone.api.pathing.goals.Goal) GoalXZ(baritone.api.pathing.goals.GoalXZ)

Example 7 with GoalXZ

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;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) InfinityMiner(mathax.client.systems.modules.world.InfinityMiner) Random(java.util.Random) PlayerArgumentType(mathax.client.systems.commands.arguments.PlayerArgumentType) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) BoolArgumentType(com.mojang.brigadier.arguments.BoolArgumentType) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) GoalXZ(baritone.api.pathing.goals.GoalXZ) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) BlockStateArgument(net.minecraft.command.argument.BlockStateArgument) BaritoneAPI(baritone.api.BaritoneAPI) Swarm(mathax.client.systems.modules.client.swarm.Swarm) SwarmWorker(mathax.client.systems.modules.client.swarm.SwarmWorker) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ChatUtils(mathax.client.utils.misc.ChatUtils) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(mathax.client.systems.commands.arguments.ModuleArgumentType) CommandSource(net.minecraft.command.CommandSource) BlockStateArgumentType(net.minecraft.command.argument.BlockStateArgumentType) List(java.util.List) Modules(mathax.client.systems.modules.Modules) SwarmConnection(mathax.client.systems.modules.client.swarm.SwarmConnection) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) Swarm(mathax.client.systems.modules.client.swarm.Swarm) GoalXZ(baritone.api.pathing.goals.GoalXZ) BlockStateArgument(net.minecraft.command.argument.BlockStateArgument) SwarmConnection(mathax.client.systems.modules.client.swarm.SwarmConnection) InfinityMiner(mathax.client.systems.modules.world.InfinityMiner) SwarmWorker(mathax.client.systems.modules.client.swarm.SwarmWorker) Module(mathax.client.systems.modules.Module) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 8 with GoalXZ

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());
}
Also used : GoalXZ(baritone.api.pathing.goals.GoalXZ)

Example 9 with GoalXZ

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") };
        }
    }
}
Also used : GoalXZ(baritone.api.pathing.goals.GoalXZ) ArrayList(java.util.ArrayList) GuiPanelButton(me.wallhacks.spark.gui.panels.GuiPanelButton) InventoryManager(me.wallhacks.spark.systems.module.modules.misc.InventoryManager) KitSettingGui(me.wallhacks.spark.gui.clickGui.settingScreens.kitSetting.KitSettingGui) HudElement(me.wallhacks.spark.systems.hud.HudElement) BlockPos(net.minecraft.util.math.BlockPos) Vec3i(net.minecraft.util.math.Vec3i) GoalBlock(baritone.api.pathing.goals.GoalBlock) Setting(me.wallhacks.spark.systems.setting.Setting) WaypointManager(me.wallhacks.spark.manager.WaypointManager)

Example 10 with GoalXZ

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);
}
Also used : Goal(baritone.api.pathing.goals.Goal) GoalXZ(baritone.api.pathing.goals.GoalXZ) Favoring(baritone.utils.pathing.Favoring) IGoalRenderPos(baritone.api.utils.interfaces.IGoalRenderPos) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos) AStarPathFinder(baritone.pathing.calc.AStarPathFinder)

Aggregations

GoalXZ (baritone.api.pathing.goals.GoalXZ)15 BlockPos (net.minecraft.util.math.BlockPos)5 Random (java.util.Random)4 Goal (baritone.api.pathing.goals.Goal)3 BaritoneAPI (baritone.api.BaritoneAPI)2 RelativeGoalXZ (baritone.api.command.datatypes.RelativeGoalXZ)2 GoalNear (baritone.api.pathing.goals.GoalNear)2 BetterBlockPos (baritone.api.utils.BetterBlockPos)2 IGoalRenderPos (baritone.api.utils.interfaces.IGoalRenderPos)2 AStarPathFinder (baritone.pathing.calc.AStarPathFinder)2 Favoring (baritone.utils.pathing.Favoring)2 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)2 BoolArgumentType (com.mojang.brigadier.arguments.BoolArgumentType)2 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)2 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)2 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)2 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)2 List (java.util.List)2 CommandSource (net.minecraft.command.CommandSource)2 BlockStateArgument (net.minecraft.command.argument.BlockStateArgument)2