Search in sources :

Example 76 with EventHandler

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

the class AutoBreed method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    for (Entity entity : mc.world.getEntities()) {
        AnimalEntity animal;
        if (!(entity instanceof AnimalEntity))
            continue;
        else
            animal = (AnimalEntity) entity;
        if (!entities.get().getBoolean(animal.getType()) || (animal.isBaby() && !ignoreBabies.get()) || animalsFed.contains(animal) || mc.player.distanceTo(animal) > range.get() || !animal.isBreedingItem(hand.get() == Hand.Mainhand ? mc.player.getMainHandStack() : mc.player.getOffHandStack()))
            continue;
        Rotations.rotate(Rotations.getYaw(entity), Rotations.getPitch(entity), -100, () -> {
            mc.interactionManager.interactEntity(mc.player, animal, hand.get().hand);
            mc.player.swingHand(hand.get().hand);
            animalsFed.add(animal);
        });
        return;
    }
}
Also used : Entity(net.minecraft.entity.Entity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) EventHandler(mathax.client.eventbus.EventHandler)

Example 77 with EventHandler

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

the class LiquidFiller method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    // Update timer according to delay
    if (timer < delay.get()) {
        timer++;
        return;
    } else
        timer = 0;
    // Find slot with a block
    FindItemResult item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && whitelist.get().contains(Block.getBlockFromItem(itemStack.getItem())));
    if (!item.found())
        return;
    // Loop blocks around the player
    BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
        // Check if the block a source liquid block
        if (isSource(blockState)) {
            Block liquid = blockState.getBlock();
            PlaceIn placeIn = placeInLiquids.get();
            if (placeIn == PlaceIn.Both || (placeIn == PlaceIn.Lava && liquid == Blocks.LAVA) || (placeIn == PlaceIn.Water && liquid == Blocks.WATER)) {
                if (BlockUtils.place(blockPos, item, rotate.get(), 0, true))
                    BlockIterator.disableCurrent();
            }
        }
    });
}
Also used : FindItemResult(mathax.client.utils.player.FindItemResult) Block(net.minecraft.block.Block) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Example 78 with EventHandler

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

the class NoobDetector method onTick.

@EventHandler
public void onTick(TickEvent.Post event) {
    if (this.count >= 20) {
        for (Entity entity : mc.world.getEntities()) {
            if (entity.isAlive() && entity.distanceTo(mc.player) <= Modules.get().get(CrystalAura.class).targetRange.get() && entity != mc.player && PlayerUtils.isNoob(target)) {
                isTargetANoob = true;
                if (chat.get())
                    info("Your target is a noob!");
                count = 0;
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventHandler(mathax.client.eventbus.EventHandler)

Example 79 with EventHandler

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

the class AnchorAura method onRender3D.

@EventHandler
private void onRender3D(Render3DEvent event) {
    if (target == null)
        return;
    if (renderPlace.get()) {
        BlockPos placePos = findPlacePos(target.getBlockPos());
        if (placePos == null)
            return;
        event.renderer.box(placePos, placeSideColor.get(), placeLineColor.get(), shapeMode.get(), 0);
    }
    if (renderBreak.get()) {
        BlockPos breakPos = findBreakPos(target.getBlockPos());
        if (breakPos == null)
            return;
        event.renderer.box(breakPos, breakSideColor.get(), breakLineColor.get(), shapeMode.get(), 0);
    }
    if (renderAutomation.get() && target != null) {
        if (sentBurrowMine)
            event.renderer.box(target.getBlockPos(), breakSideColor.get(), breakLineColor.get(), shapeMode.get(), 0);
        if (sentTrapMine)
            event.renderer.box(target.getBlockPos().up(2), breakSideColor.get(), breakLineColor.get(), shapeMode.get(), 0);
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EventHandler(mathax.client.eventbus.EventHandler)

Example 80 with EventHandler

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

the class AnchorAura method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.world.getDimension().isRespawnAnchorWorking()) {
        error("You are in the Nether, disabling...");
        toggle();
        return;
    }
    if (PlayerUtils.shouldPause(pauseOnMine.get(), pauseOnEat.get(), pauseOnDrink.get()))
        return;
    if (EntityUtils.getTotalPlayerHealth(mc.player) <= minHealth.get())
        return;
    if (TargetUtils.isBadTarget(target, targetRange.get()))
        target = TargetUtils.getPlayerTarget(targetRange.get(), targetPriority.get());
    if (TargetUtils.isBadTarget(target, targetRange.get()))
        return;
    FindItemResult anchor = InvUtils.findInHotbar(Items.RESPAWN_ANCHOR);
    FindItemResult glowStone = InvUtils.findInHotbar(Items.GLOWSTONE);
    if (!anchor.found() || !glowStone.found())
        return;
    if (antiStuck.get() && !sentAntiStuck) {
        if (findBreakPos(target.getBlockPos()) == null && findPlacePos(target.getBlockPos()) == null && BlockUtils.getBlock(target.getBlockPos().up(2)) == Blocks.GLOWSTONE) {
            FindItemResult pick = InvUtils.findPick();
            if (pick.found()) {
                InvUtils.updateSlot(pick.slot());
                PlayerUtils.doPacketMine(target.getBlockPos().up(2));
                sentAntiStuck = true;
                return;
            }
        }
    }
    if (sentAntiStuck && BlockUtils.getBlock(target.getBlockPos().up(2)) != Blocks.GLOWSTONE)
        sentAntiStuck = false;
    if (breakSelfTrap.get() && !sentTrapMine) {
        if (findBreakPos(target.getBlockPos()) == null && findPlacePos(target.getBlockPos()) == null && BlockUtils.isTrapBlock(target.getBlockPos().up(2))) {
            FindItemResult pick = InvUtils.findPick();
            if (pick.found()) {
                InvUtils.updateSlot(pick.slot());
                info("Breaking (highlight)%s(default)'s self-trap.", target.getEntityName());
                PlayerUtils.doPacketMine(target.getBlockPos().up(2));
                sentTrapMine = true;
                return;
            }
        }
    }
    if (sentTrapMine && !BlockUtils.isTrapBlock(target.getBlockPos().up(2))) {
        if (fastPlaceAfter.get()) {
            placeDelayLeft = 0;
            breakDelayLeft = 0;
        }
        sentTrapMine = false;
    }
    if (breakBurrow.get() && !sentBurrowMine && PlayerUtils.isBurrowed(target, true)) {
        FindItemResult pick = InvUtils.findPick();
        if (pick.found()) {
            InvUtils.updateSlot(pick.slot());
            info("Breaking (highlight)%s(default)'s burrow.", target.getEntityName());
            PlayerUtils.doPacketMine(target.getBlockPos());
            sentBurrowMine = true;
            return;
        }
    }
    if (sentBurrowMine && PlayerUtils.isBurrowed(target, true))
        return;
    else
        sentBurrowMine = false;
    if (breakDelayLeft >= breakDelay.get()) {
        BlockPos breakPos = findBreakPos(target.getBlockPos());
        if (breakPos != null) {
            breakDelayLeft = 0;
            if (rotationMode.get() == RotationMode.Both || rotationMode.get() == RotationMode.Break)
                Rotations.rotate(Rotations.getYaw(breakPos), Rotations.getPitch(breakPos), 50, () -> breakAnchor(breakPos, anchor, glowStone));
            else
                breakAnchor(breakPos, anchor, glowStone);
        }
    }
    if (placeDelayLeft >= placeDelay.get() && place.get()) {
        BlockPos placePos = findPlacePos(target.getBlockPos());
        if (placePos != null) {
            placeDelayLeft = 0;
            BlockUtils.place(placePos, anchor, (rotationMode.get() == RotationMode.Place || rotationMode.get() == RotationMode.Both), 50);
        }
    }
    placeDelayLeft++;
    breakDelayLeft++;
}
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