Search in sources :

Example 1 with EventHandler

use of mathax.client.eventbus.EventHandler in project Client by MatHax.

the class TNTAura method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    FindItemResult obsidian = InvUtils.findInHotbar(Items.OBSIDIAN);
    if (!obsidian.isHotbar() && !toggled) {
        obsidianPos.clear();
        error("No obsidian found, disabling...");
        toggle();
        toggled = true;
    }
    FindItemResult flint = InvUtils.findInHotbar(Items.FLINT_AND_STEEL);
    if (!flint.isHotbar() && !toggled) {
        obsidianPos.clear();
        error("No flint and steel found, disabling...");
        toggle();
        toggled = true;
    }
    FindItemResult tnt = InvUtils.findInHotbar(Items.TNT);
    if (!tnt.isHotbar() && !toggled) {
        obsidianPos.clear();
        error("No TNT found, disabling...");
        toggle();
        toggled = true;
    }
    FindItemResult pickaxe = InvUtils.find(itemStack -> itemStack.getItem() == Items.DIAMOND_PICKAXE || itemStack.getItem() == Items.NETHERITE_PICKAXE);
    if (!pickaxe.isHotbar() && !toggled) {
        obsidianPos.clear();
        error("No pickaxe found, disabling...");
        toggle();
        toggled = true;
    }
    if (TargetUtils.isBadTarget(target, range.get()))
        target = TargetUtils.getPlayerTarget(range.get(), SortPriority.Lowest_Distance);
    if (target == null)
        return;
    if (burrowPause.get() && isBurrowed(target) && !toggled) {
        obsidianPos.clear();
        error("Target is burrowed, disabling...");
        toggle();
        toggled = true;
    }
    if (antiSelf.get() && antiSelf(target) && !toggled) {
        obsidianPos.clear();
        error("Target is in your hole!");
        toggle();
        toggled = true;
    }
    if (holePause.get() && !isSurrounded(target) && !toggled) {
        obsidianPos.clear();
        error("Target isn't surrounded, disabling...");
        toggle();
        toggled = true;
    }
    if (TargetUtils.isBadTarget(target, range.get()) && !toggled) {
        error("Enemy is too far, disabling...");
        toggle();
        toggled = true;
    }
    if (PlayerUtils.shouldPause(pauseOnMine.get(), pauseOnEat.get(), pauseOnDrink.get()))
        return;
    if (allowTNT(target)) {
        placeTNT(target);
        igniteTNT(target.getBlockPos().up(2), flint);
    }
    if (!mineBlockstate(target.getBlockPos().up(2)) && autoBreak.get())
        mine(target.getBlockPos().up(2), pickaxe);
    placeObsidian(target);
    if (ticks >= delay.get() && obsidianPos.size() > 0) {
        BlockPos blockPos = obsidianPos.get(obsidianPos.size() - 1);
        if (BlockUtils.place(blockPos, obsidian, rotate.get(), 50, true))
            obsidianPos.remove(blockPos);
        ticks = 0;
    } else
        ticks++;
}
Also used : FindItemResult(mathax.client.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) EventHandler(mathax.client.eventbus.EventHandler)

Example 2 with EventHandler

use of mathax.client.eventbus.EventHandler in project Client by MatHax.

the class AutoMountBypassDupe method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
        toggle();
        mc.player.closeHandledScreen();
        return;
    }
    if (timer <= 0)
        timer = delay.get();
    else {
        timer--;
        return;
    }
    int slots = getInvSize(mc.player.getVehicle());
    for (Entity e : mc.world.getEntities()) {
        if (e.distanceTo(mc.player) < 5 && e instanceof AbstractDonkeyEntity && ((AbstractDonkeyEntity) e).isTame())
            entity = (AbstractDonkeyEntity) e;
    }
    if (entity == null)
        return;
    if (sneak) {
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
        mc.player.setSneaking(false);
        sneak = false;
        return;
    }
    if (slots == -1) {
        if (entity.hasChest() || mc.player.getMainHandStack().getItem() == Items.CHEST) {
            mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
        } else {
            int slot = InvUtils.findInHotbar(Items.CHEST).slot();
            if (!InvUtils.swap(slot, true)) {
                error("Cannot find chest in your hotbar, disabling...");
                toggle();
            }
        }
    } else if (slots == 0) {
        if (isDupeTime()) {
            if (!slotsToThrow.isEmpty()) {
                if (faceDown.get())
                    Rotations.rotate(mc.player.getYaw(), 90, 99, this::drop);
                else
                    drop();
            } else {
                for (int i = 2; i < getDupeSize() + 1; i++) {
                    slotsToThrow.add(i);
                }
            }
        } else {
            mc.player.closeHandledScreen();
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
            mc.player.setSneaking(true);
            sneak = true;
        }
    } else if (!(mc.currentScreen instanceof HorseScreen))
        mc.player.openRidingInventory();
    else if (slots > 0) {
        if (slotsToMove.isEmpty()) {
            boolean empty = true;
            for (int i = 2; i <= slots; i++) {
                if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                    empty = false;
                    break;
                }
            }
            if (empty) {
                for (int i = slots + 2; i < mc.player.currentScreenHandler.getStacks().size(); i++) {
                    if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                        if (mc.player.currentScreenHandler.getSlot(i).getStack().getItem() == Items.CHEST)
                            continue;
                        if (!(mc.player.currentScreenHandler.getSlot(i).getStack().getItem() instanceof BlockItem && ((BlockItem) mc.player.currentScreenHandler.getSlot(i).getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && shulkersOnly.get())
                            continue;
                        slotsToMove.add(i);
                        if (slotsToMove.size() >= slots)
                            break;
                    }
                }
            } else {
                noCancel = true;
                mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
                noCancel = false;
                return;
            }
        }
        if (!slotsToMove.isEmpty()) {
            for (int i : slotsToMove) {
                InvUtils.quickMove().from(i).to(0);
            }
            slotsToMove.clear();
        }
    }
}
Also used : AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) Entity(net.minecraft.entity.Entity) LlamaEntity(net.minecraft.entity.passive.LlamaEntity) HorseScreen(net.minecraft.client.gui.screen.ingame.HorseScreen) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Example 3 with EventHandler

use of mathax.client.eventbus.EventHandler in project Client by MatHax.

the class BookBot method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    FindItemResult writableBook = InvUtils.find(Items.WRITABLE_BOOK);
    // Check if there is a book to write
    if (!writableBook.found()) {
        toggle();
        return;
    }
    // Move the book into hand
    if (!writableBook.isMainHand()) {
        InvUtils.move().from(writableBook.slot()).toHotbar(mc.player.getInventory().selectedSlot);
        return;
    }
    // If somehow it failed, just dont do anything until it tries again
    FindItemResult finalBook = InvUtils.findInHotbar(Items.WRITABLE_BOOK);
    if (!finalBook.isMainHand())
        return;
    // Check delay
    if (delayTimer > 0) {
        delayTimer--;
        return;
    }
    // Reset delay
    delayTimer = delay.get();
    if (mode.get() == Mode.Random) {
        int origin = onlyAscii.get() ? 0x21 : 0x0800;
        int bound = onlyAscii.get() ? 0x7E : 0x10FFFF;
        writeBook(// Generate a random load of ints to use as random characters
        random.ints(origin, bound).filter(i -> !Character.isWhitespace(i) && i != '\r' && i != '\n').iterator());
    } else if (mode.get() == Mode.File) {
        // Ignore if somehow the file got deleted
        if ((file == null || !file.exists()) && mode.get() == Mode.File) {
            info("No file selected, please select a file in the GUI.");
            toggle();
            return;
        }
        // Handle the file being empty
        if (file.length() == 0) {
            MutableText message = new LiteralText("");
            message.append(new LiteralText("The bookbot file is empty! ").formatted(Formatting.RED));
            message.append(new LiteralText("Click here to edit it.").setStyle(Style.EMPTY.withFormatting(Formatting.UNDERLINE, Formatting.RED).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()))));
            info(message);
            toggle();
            return;
        }
        // Read each line of the file and construct a string with the needed line breaks
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            StringBuilder file = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                file.append(line).append('\n');
            }
            reader.close();
            // Write the file string to a book
            writeBook(file.toString().chars().iterator());
        } catch (IOException ignored) {
            error("Failed to read the file.");
        }
    }
}
Also used : MutableText(net.minecraft.text.MutableText) ClickEvent(net.minecraft.text.ClickEvent) FindItemResult(mathax.client.utils.player.FindItemResult) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) NbtString(net.minecraft.nbt.NbtString) IOException(java.io.IOException) LiteralText(net.minecraft.text.LiteralText) EventHandler(mathax.client.eventbus.EventHandler)

Example 4 with EventHandler

use of mathax.client.eventbus.EventHandler in project Client by MatHax.

the class Sniper method onTick.

@EventHandler
public void onTick(TickEvent.Post event) {
    AntiHunger antiHunger = Modules.get().get(AntiHunger.class);
    NoFall noFall = Modules.get().get(NoFall.class);
    if (spoofed && !mc.options.useKey.isPressed()) {
        if (antiHungerPause.get() && !antiHunger.isActive())
            antiHunger.toggle();
        if (noFallPause.get() && !noFall.isActive())
            noFall.toggle();
    }
}
Also used : AntiHunger(mathax.client.systems.modules.player.AntiHunger) NoFall(mathax.client.systems.modules.movement.NoFall) EventHandler(mathax.client.eventbus.EventHandler)

Example 5 with EventHandler

use of mathax.client.eventbus.EventHandler in project Client by MatHax.

the class Sniper method onTick.

@EventHandler
public void onTick(TickEvent.Pre event) {
    AntiHunger antiHunger = Modules.get().get(AntiHunger.class);
    NoFall noFall = Modules.get().get(NoFall.class);
    if ((isBow() && bows.get()) || (isTrident() && tridents.get())) {
        if (mc.player.getItemUseTime() > 0 && mc.options.useKey.isPressed()) {
            if (antiHungerPause.get() && antiHunger.isActive())
                antiHunger.toggle();
            if (noFallPause.get() && noFall.isActive())
                noFall.toggle();
        }
    }
}
Also used : AntiHunger(mathax.client.systems.modules.player.AntiHunger) NoFall(mathax.client.systems.modules.movement.NoFall) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

EventHandler (mathax.client.eventbus.EventHandler)80 BlockPos (net.minecraft.util.math.BlockPos)22 FindItemResult (mathax.client.utils.player.FindItemResult)20 Vec3d (net.minecraft.util.math.Vec3d)12 Entity (net.minecraft.entity.Entity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 BlockState (net.minecraft.block.BlockState)6 Direction (net.minecraft.util.math.Direction)5 ArrayList (java.util.ArrayList)4 TickEvent (mathax.client.events.world.TickEvent)4 IVec3d (mathax.client.mixininterface.IVec3d)4 Categories (mathax.client.systems.modules.Categories)4 Module (mathax.client.systems.modules.Module)4 InvUtils (mathax.client.utils.player.InvUtils)4 ItemStack (net.minecraft.item.ItemStack)4 mathax.client.settings (mathax.client.settings)3 BlockItem (net.minecraft.item.BlockItem)3 BlockHitResult (net.minecraft.util.hit.BlockHitResult)3 Comparator (java.util.Comparator)2 NoFall (mathax.client.systems.modules.movement.NoFall)2