Search in sources :

Example 21 with EventHandler

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

the class ChatEncryption method onMessageReceive.

@EventHandler
private void onMessageReceive(ReceiveMessageEvent event) {
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    ((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
    Text message = event.getMessage();
    if (message.getString().endsWith(suffix.get()) && !suffix.get().isEmpty()) {
        String[] msg = message.getString().split(encryptedPrefix);
        try {
            String chat = decrypt(msg[1], customKey.get() ? groupKey.get() : password);
            BaseText prefixOpenBorder = new LiteralText("[");
            prefixOpenBorder.setStyle(prefixOpenBorder.getStyle().withFormatting(Formatting.GRAY));
            BaseText prefix = new LiteralText("Encrypted Chat");
            prefix.setStyle(prefix.getStyle().withColor(MatHax.INSTANCE.MATHAX_COLOR.getPacked()));
            BaseText prefixCloseBorder = new LiteralText("] ");
            prefixCloseBorder.setStyle(prefixCloseBorder.getStyle().withFormatting(Formatting.GRAY));
            BaseText chatText = new LiteralText(msg[0] + chat);
            chatText.setStyle(chatText.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(msg[1]))));
            BaseText chatMessage = new LiteralText("");
            if (Modules.get().get(BetterChat.class).displayPlayerHeads())
                chatMessage.append("  ");
            chatMessage.append(prefixOpenBorder);
            chatMessage.append(prefix);
            chatMessage.append(prefixCloseBorder);
            chatMessage.append(chatText);
            message = chatMessage;
        } catch (Exception exception) {
            message = event.getMessage();
        }
    }
    event.setMessage(message);
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) LiteralText(net.minecraft.text.LiteralText) BaseText(net.minecraft.text.BaseText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText) EventHandler(mathax.client.eventbus.EventHandler)

Example 22 with EventHandler

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

the class ArmorNotifier method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    Iterable<ItemStack> armorPieces = mc.player.getArmorItems();
    for (ItemStack armorPiece : armorPieces) {
        if (ArmorUtils.checkThreshold(armorPiece, threshold.get())) {
            if (ArmorUtils.isHelmet(armorPiece) && !alertedHelmet) {
                warning("Your (highlight)helmet(default) has low durability!");
                alertedHelmet = true;
            }
            if (ArmorUtils.isChestplate(armorPiece) && !alertedChestplate) {
                warning("Your (highlight)chestplate(default) has low durability!");
                alertedChestplate = true;
            }
            if (ArmorUtils.areLeggings(armorPiece) && !alertedLeggings) {
                warning("Your (highlight)leggings(default) have low durability!");
                alertedLeggings = true;
            }
            if (ArmorUtils.areBoots(armorPiece) && !alertedBoots) {
                warning("Your (highlight)boots(default) have low durability!");
                alertedBoots = true;
            }
        }
        if (!ArmorUtils.checkThreshold(armorPiece, threshold.get())) {
            if (ArmorUtils.isHelmet(armorPiece) && alertedHelmet)
                alertedHelmet = false;
            if (ArmorUtils.isChestplate(armorPiece) && alertedChestplate)
                alertedChestplate = false;
            if (ArmorUtils.areLeggings(armorPiece) && alertedLeggings)
                alertedLeggings = false;
            if (ArmorUtils.areBoots(armorPiece) && alertedBoots)
                alertedBoots = false;
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EventHandler(mathax.client.eventbus.EventHandler)

Example 23 with EventHandler

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

the class AutoWither method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    if (wither == null) {
        // Delay
        if (witherTicksWaited < witherDelay.get() - 1)
            return;
        // Clear pool and list
        for (Wither wither : withers) witherPool.free(wither);
        withers.clear();
        // Register
        BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
            Direction dir = Direction.fromRotation(Rotations.getYaw(blockPos)).getOpposite();
            if (isValidSpawn(blockPos, dir))
                withers.add(witherPool.get().set(blockPos, dir));
        });
    }
}
Also used : Direction(net.minecraft.util.math.Direction) EventHandler(mathax.client.eventbus.EventHandler)

Example 24 with EventHandler

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

the class AutoWither method onRender3D.

@EventHandler
private void onRender3D(Render3DEvent event) {
    if (wither == null)
        return;
    // Body
    event.renderer.box(wither.foot, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    event.renderer.box(wither.foot.up(), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    event.renderer.box(wither.foot.up().offset(wither.axis, -1), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    event.renderer.box(wither.foot.up().offset(wither.axis, 1), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    // Head
    BlockPos midHead = wither.foot.up().up();
    BlockPos leftHead = wither.foot.up().up().offset(wither.axis, -1);
    BlockPos rightHead = wither.foot.up().up().offset(wither.axis, 1);
    event.renderer.box((double) midHead.getX() + 0.2, (double) midHead.getX(), (double) midHead.getX() + 0.2, (double) midHead.getX() + 0.8, (double) midHead.getX() + 0.7, (double) midHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    event.renderer.box((double) leftHead.getX() + 0.2, (double) leftHead.getX(), (double) leftHead.getX() + 0.2, (double) leftHead.getX() + 0.8, (double) leftHead.getX() + 0.7, (double) leftHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
    event.renderer.box((double) rightHead.getX() + 0.2, (double) rightHead.getX(), (double) rightHead.getX() + 0.2, (double) rightHead.getX() + 0.8, (double) rightHead.getX() + 0.7, (double) rightHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EventHandler(mathax.client.eventbus.EventHandler)

Example 25 with EventHandler

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

the class AutoWither method onPostTick.

@EventHandler
private void onPostTick(TickEvent.Post event) {
    if (wither == null) {
        // Delay
        if (witherTicksWaited < witherDelay.get() - 1) {
            witherTicksWaited++;
            return;
        }
        if (withers.isEmpty())
            return;
        // Sorting
        switch(priority.get()) {
            case Closest:
                withers.sort(Comparator.comparingDouble(w -> PlayerUtils.distanceTo(w.foot)));
            case Furthest:
                withers.sort((w1, w2) -> {
                    int sort = Double.compare(PlayerUtils.distanceTo(w1.foot), PlayerUtils.distanceTo(w2.foot));
                    if (sort == 0)
                        return 0;
                    return sort > 0 ? -1 : 1;
                });
            case Random:
                Collections.shuffle(withers);
        }
        wither = withers.get(0);
    }
    // Soul sand/soil and skull slot
    FindItemResult findSoulSand = InvUtils.findInHotbar(Items.SOUL_SAND);
    if (!findSoulSand.found())
        findSoulSand = InvUtils.findInHotbar(Items.SOUL_SOIL);
    FindItemResult findWitherSkull = InvUtils.findInHotbar(Items.WITHER_SKELETON_SKULL);
    // Check for enough resources
    if (!findSoulSand.found() || !findWitherSkull.found()) {
        error("Not enough resources in hotbar");
        toggle();
        return;
    }
    // Build
    if (blockDelay.get() == 0) {
        // All in 1 tick
        // Body
        BlockUtils.place(wither.foot, findSoulSand, rotate.get(), -50);
        BlockUtils.place(wither.foot.up(), findSoulSand, rotate.get(), -50);
        BlockUtils.place(wither.foot.up().offset(wither.axis, -1), findSoulSand, rotate.get(), -50);
        BlockUtils.place(wither.foot.up().offset(wither.axis, 1), findSoulSand, rotate.get(), -50);
        // Head
        BlockUtils.place(wither.foot.up().up(), findWitherSkull, rotate.get(), -50);
        BlockUtils.place(wither.foot.up().up().offset(wither.axis, -1), findWitherSkull, rotate.get(), -50);
        BlockUtils.place(wither.foot.up().up().offset(wither.axis, 1), findWitherSkull, rotate.get(), -50);
        // Auto turnoff
        if (turnOff.get()) {
            wither = null;
            toggle();
        }
    } else {
        // Delay
        if (blockTicksWaited < blockDelay.get() - 1) {
            blockTicksWaited++;
            return;
        }
        switch(wither.stage) {
            case 0:
                if (BlockUtils.place(wither.foot, findSoulSand, rotate.get(), -50))
                    wither.stage++;
                break;
            case 1:
                if (BlockUtils.place(wither.foot.up(), findSoulSand, rotate.get(), -50))
                    wither.stage++;
                break;
            case 2:
                if (BlockUtils.place(wither.foot.up().offset(wither.axis, -1), findSoulSand, rotate.get(), -50))
                    wither.stage++;
                break;
            case 3:
                if (BlockUtils.place(wither.foot.up().offset(wither.axis, 1), findSoulSand, rotate.get(), -50))
                    wither.stage++;
                break;
            case 4:
                if (BlockUtils.place(wither.foot.up().up(), findWitherSkull, rotate.get(), -50))
                    wither.stage++;
                break;
            case 5:
                if (BlockUtils.place(wither.foot.up().up().offset(wither.axis, -1), findWitherSkull, rotate.get(), -50))
                    wither.stage++;
                break;
            case 6:
                if (BlockUtils.place(wither.foot.up().up().offset(wither.axis, 1), findWitherSkull, rotate.get(), -50))
                    wither.stage++;
                break;
            case 7:
                // Auto turnoff
                if (turnOff.get()) {
                    wither = null;
                    toggle();
                }
                break;
        }
    }
    witherTicksWaited = 0;
}
Also used : MatHax(mathax.client.MatHax) ShapeContext(net.minecraft.block.ShapeContext) BlockIterator(mathax.client.utils.world.BlockIterator) PlayerUtils(mathax.client.utils.player.PlayerUtils) SettingColor(mathax.client.utils.render.color.SettingColor) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) BlockUtils(mathax.client.utils.world.BlockUtils) ShapeMode(mathax.client.renderer.ShapeMode) Blocks(net.minecraft.block.Blocks) EventHandler(mathax.client.eventbus.EventHandler) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) InvUtils(mathax.client.utils.player.InvUtils) TickEvent(mathax.client.events.world.TickEvent) FindItemResult(mathax.client.utils.player.FindItemResult) Categories(mathax.client.systems.modules.Categories) Render3DEvent(mathax.client.events.render.Render3DEvent) Module(mathax.client.systems.modules.Module) Comparator(java.util.Comparator) Collections(java.util.Collections) Pool(mathax.client.utils.misc.Pool) mathax.client.settings(mathax.client.settings) Rotations(mathax.client.utils.player.Rotations) FindItemResult(mathax.client.utils.player.FindItemResult) 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