Search in sources :

Example 6 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class AutoPot method stopDrinking.

private void stopDrinking() {
    changeSlot(prevSlot);
    setPressed(false);
    drinking = false;
    if (pauseAuras.get()) {
        for (Class<? extends Module> klass : AURA_LIST) {
            Module module = Modules.get().get(klass);
            if (wasAura.contains(klass) && !module.isActive()) {
                module.toggle();
            }
        }
    }
    if (pauseBaritone.get() && wasBaritone)
        BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume");
}
Also used : Module(mathax.client.systems.modules.Module)

Example 7 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ModulesScreen method createFavorites.

// Favorites
protected Cell<WWindow> createFavorites(WContainer c) {
    boolean hasFavorites = Modules.get().getAll().stream().anyMatch(module -> module.favorite);
    if (!hasFavorites)
        return null;
    WWindow w = theme.window("Favorites");
    w.id = "favorites";
    w.padding = 0;
    w.spacing = 0;
    if (theme.categoryIcons())
        w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(Items.NETHER_STAR.getDefaultStack())).pad(2);
    Cell<WWindow> cell = c.add(w);
    w.view.scrollOnlyWhenMouseOver = true;
    w.view.hasScrollBar = false;
    w.view.spacing = 0;
    createFavoritesW(w);
    return cell;
}
Also used : Utils(mathax.client.utils.Utils) WVerticalList(mathax.client.gui.widgets.containers.WVerticalList) WWindow(mathax.client.gui.widgets.containers.WWindow) GuiTheme(mathax.client.gui.GuiTheme) Set(java.util.Set) Items(net.minecraft.item.Items) WContainer(mathax.client.gui.widgets.containers.WContainer) WSection(mathax.client.gui.widgets.containers.WSection) Tabs(mathax.client.gui.tabs.Tabs) ArrayList(java.util.ArrayList) Cell(mathax.client.gui.utils.Cell) List(java.util.List) WTextBox(mathax.client.gui.widgets.input.WTextBox) TabScreen(mathax.client.gui.tabs.TabScreen) NbtUtils(mathax.client.utils.misc.NbtUtils) Category(mathax.client.systems.modules.Category) Modules(mathax.client.systems.modules.Modules) Module(mathax.client.systems.modules.Module) WWindow(mathax.client.gui.widgets.containers.WWindow)

Example 8 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ModulesScreen method createSearchW.

// Search
protected void createSearchW(WContainer w, String text) {
    if (!text.isEmpty()) {
        // Titles
        Set<Module> modules = Modules.get().searchTitles(text);
        if (modules.size() > 0) {
            WSection section = w.add(theme.section("Modules")).expandX().widget();
            section.spacing = 0;
            for (Module module : modules) {
                section.add(theme.module(module)).expandX();
            }
        }
        // Settings
        modules = Modules.get().searchSettingTitles(text);
        if (modules.size() > 0) {
            WSection section = w.add(theme.section("Settings")).expandX().widget();
            section.spacing = 0;
            for (Module module : modules) {
                section.add(theme.module(module)).expandX();
            }
        }
    }
}
Also used : WSection(mathax.client.gui.widgets.containers.WSection) Module(mathax.client.systems.modules.Module)

Example 9 with Module

use of mathax.client.systems.modules.Module 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 10 with Module

use of mathax.client.systems.modules.Module in project Client by MatHax.

the class ToggleCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("all").then(literal("on").executes(context -> {
        new ArrayList<>(Modules.get().getAll()).forEach(module -> {
            if (!module.isActive() && !module.name.equals("panic"))
                module.toggle();
        });
        HUD.get().active = true;
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        new ArrayList<>(Modules.get().getActive()).forEach(Module::toggle);
        HUD.get().active = false;
        return SINGLE_SUCCESS;
    }))).then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        m.toggle();
        return SINGLE_SUCCESS;
    }).then(literal("on").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (!m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })));
}
Also used : CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Modules(mathax.client.systems.modules.Modules) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) HUD(mathax.client.systems.hud.HUD) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(mathax.client.systems.commands.arguments.ModuleArgumentType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Module(mathax.client.systems.modules.Module)

Aggregations

Module (mathax.client.systems.modules.Module)29 Modules (mathax.client.systems.modules.Modules)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)4 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)4 WSection (mathax.client.gui.widgets.containers.WSection)4 Command (mathax.client.systems.commands.Command)4 Category (mathax.client.systems.modules.Category)4 CommandSource (net.minecraft.command.CommandSource)4 Set (java.util.Set)3 GuiTheme (mathax.client.gui.GuiTheme)3 TabScreen (mathax.client.gui.tabs.TabScreen)3 Tabs (mathax.client.gui.tabs.Tabs)3 Cell (mathax.client.gui.utils.Cell)3 WContainer (mathax.client.gui.widgets.containers.WContainer)3 WVerticalList (mathax.client.gui.widgets.containers.WVerticalList)3 WWindow (mathax.client.gui.widgets.containers.WWindow)3 WTextBox (mathax.client.gui.widgets.input.WTextBox)3 ModuleArgumentType (mathax.client.systems.commands.arguments.ModuleArgumentType)3