Search in sources :

Example 26 with EventHandler

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

the class ColorSigns method onPacketSend.

@EventHandler
private void onPacketSend(PacketEvent.Send event) {
    if (event.packet instanceof GameJoinS2CPacket) {
        checkWarning();
        return;
    }
    if (!(event.packet instanceof UpdateSignC2SPacket))
        return;
    UpdateSignC2SPacket p = (UpdateSignC2SPacket) event.packet;
    for (int l = 0; l < p.getText().length; l++) {
        String newText = p.getText()[l].replaceAll("(?i)\u00a7|&([0-9A-FK-OR])", "\u00a7\u00a7$1$1");
        p.getText()[l] = newText;
    }
    event.packet = p;
}
Also used : GameJoinS2CPacket(net.minecraft.network.packet.s2c.play.GameJoinS2CPacket) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventHandler(mathax.client.eventbus.EventHandler)

Example 27 with EventHandler

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

the class SpawnProofer method onTickPost.

@EventHandler
private void onTickPost(TickEvent.Post event) {
    if (delay.get() != 0 && ticksWaited < delay.get() - 1) {
        ticksWaited++;
        return;
    }
    if (spawns.isEmpty())
        return;
    FindItemResult block = InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
    if (delay.get() == 0)
        for (BlockPos blockPos : spawns) BlockUtils.place(blockPos, block, rotate.get(), -50, false);
    else {
        if (isLightSource(Block.getBlockFromItem(mc.player.getInventory().getStack(block.slot()).getItem()))) {
            int lowestLightLevel = 16;
            BlockPos.Mutable selectedBlockPos = spawns.get(0);
            for (BlockPos blockPos : spawns) {
                int lightLevel = mc.world.getLightLevel(blockPos);
                if (lightLevel < lowestLightLevel) {
                    lowestLightLevel = lightLevel;
                    selectedBlockPos.set(blockPos);
                }
            }
            BlockUtils.place(selectedBlockPos, block, rotate.get(), -50, false);
        } else
            BlockUtils.place(spawns.get(0), block, rotate.get(), -50, false);
    }
    ticksWaited = 0;
}
Also used : FindItemResult(mathax.client.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) EventHandler(mathax.client.eventbus.EventHandler)

Example 28 with EventHandler

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

the class VeinMiner method onStartBreakingBlock.

@EventHandler
private void onStartBreakingBlock(StartBreakingBlockEvent event) {
    BlockState state = mc.world.getBlockState(event.blockPos);
    if (state.getHardness(mc.world, event.blockPos) < 0)
        return;
    if (mode.get() == ListMode.Whitelist && !selectedBlocks.get().contains(state.getBlock()))
        return;
    if (mode.get() == ListMode.Blacklist && selectedBlocks.get().contains(state.getBlock()))
        return;
    foundBlockPositions.clear();
    if (!isMiningBlock(event.blockPos)) {
        MyBlock block = blockPool.get();
        block.set(event);
        blocks.add(block);
        mineNearbyBlocks(block.originalBlock.asItem(), event.blockPos, event.direction, depth.get());
    }
}
Also used : BlockState(net.minecraft.block.BlockState) EventHandler(mathax.client.eventbus.EventHandler)

Example 29 with EventHandler

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

the class InfinityMiner method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.player.getInventory().getEmptySlot() == -1) {
        if (walkHome.get()) {
            if (isBaritoneNotWalking()) {
                info("Walking home.");
                baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(homePos));
            } else if (mc.player.getBlockPos().equals(homePos))
                logOut();
        } else if (logOut.get())
            logOut();
        else
            toggle();
        return;
    }
    if (!findPickaxe()) {
        error("Could not find a usable mending pickaxe.");
        toggle();
        return;
    }
    if (repairing) {
        if (!needsRepair()) {
            warning("Finished repairing, going back to mining.");
            repairing = false;
            mineTargetBlocks();
            return;
        }
        if (isBaritoneNotMining())
            mineRepairBlocks();
    } else {
        if (needsRepair()) {
            warning("Pickaxe needs repair, beginning repair process");
            repairing = true;
            mineRepairBlocks();
            return;
        }
        if (isBaritoneNotMining())
            mineTargetBlocks();
    }
}
Also used : GoalBlock(baritone.api.pathing.goals.GoalBlock) EventHandler(mathax.client.eventbus.EventHandler)

Example 30 with EventHandler

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

the class Nuker method onTickPre.

@EventHandler
private void onTickPre(TickEvent.Pre event) {
    renderBlocks.forEach(RenderBlock::tick);
    // Update timer
    if (timer > 0) {
        timer--;
        return;
    }
    if (mc.player.isDead())
        return;
    // Calculate some stuff
    double pX = mc.player.getX();
    double pY = mc.player.getY();
    double pZ = mc.player.getZ();
    double rangeSq = Math.pow(range.get(), 2);
    // Find blocks to break
    BlockIterator.register((int) Math.ceil(range.get()), (int) Math.ceil(range.get()), (blockPos, blockState) -> {
        // Check for air, unbreakable blocks and distance
        if (!BlockUtils.canBreak(blockPos, blockState) || Utils.squaredDistance(pX, pY, pZ, blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5) > rangeSq)
            return;
        // Flatten
        if (mode.get() == Mode.Flatten && blockPos.getY() < mc.player.getY())
            return;
        // Smash
        if (mode.get() == Mode.Smash && blockState.getHardness(mc.world, blockPos) != 0)
            return;
        // Check for selected
        if (whitelistEnabled.get() && !whitelist.get().contains(blockState.getBlock()))
            return;
        // Add block
        blocks.add(blockPosPool.get().set(blockPos));
    });
    // Break block if found
    BlockIterator.after(() -> {
        // Sort blocks
        if (sortMode.get() != SortMode.None)
            blocks.sort(Comparator.comparingDouble(value -> Utils.squaredDistance(pX, pY, pZ, value.getX() + 0.5, value.getY() + 0.5, value.getZ() + 0.5) * (sortMode.get() == SortMode.Closest ? 1 : -1)));
        // Check if some block was found
        if (blocks.isEmpty()) {
            // If no block was found for long enough then set firstBlock flag to true to not wait before breaking another again
            if (noBlockTimer++ >= delay.get())
                firstBlock = true;
            return;
        } else
            noBlockTimer = 0;
        // Update timer
        if (!firstBlock && !lastBlockPos.equals(blocks.get(0))) {
            timer = delay.get();
            firstBlock = false;
            lastBlockPos.set(blocks.get(0));
            if (timer > 0)
                return;
        }
        // Break
        int count = 0;
        for (BlockPos block : blocks) {
            if (count >= maxBlocksPerTick.get())
                break;
            boolean canInstaMine = BlockUtils.canInstaBreak(block);
            BlockUtils.breakBlock(block, swingHand.get());
            renderBlocks.add(renderBlockPool.get().set(block));
            lastBlockPos.set(block);
            count++;
            if (!canInstaMine)
                break;
        }
        firstBlock = false;
        // Clear current block positions
        for (BlockPos.Mutable blockPos : blocks) blockPosPool.free(blockPos);
        blocks.clear();
    });
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) 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