Search in sources :

Example 16 with HoverEvent

use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.

the class CmdFriends method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0 || args.length > 2) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("add")) {
        if (args.length < 2) {
            throw new CmdSyntaxException("No username selected");
        }
        BleachHack.friendMang.add(args[1]);
        BleachLogger.info("Added \"" + args[1] + "\" to the friend list");
    } else if (args[0].equalsIgnoreCase("remove")) {
        if (args.length < 2) {
            throw new CmdSyntaxException("No username selected");
        }
        BleachHack.friendMang.remove(args[1].toLowerCase(Locale.ENGLISH));
        BleachLogger.info("Removed \"" + args[1] + "\" from the friend list");
    } else if (args[0].equalsIgnoreCase("list")) {
        if (BleachHack.friendMang.getFriends().isEmpty()) {
            BleachLogger.info("You don't have any friends :(");
        } else {
            int len = BleachHack.friendMang.getFriends().stream().min((f1, f2) -> f2.length() - f1.length()).get().length() + 3;
            MutableText text = new LiteralText("Friends:");
            for (String f : BleachHack.friendMang.getFriends()) {
                String spaces = StringUtils.repeat(' ', len - f.length());
                text.append(new LiteralText("\n> " + f + spaces).styled(style -> style.withColor(BleachLogger.INFO_COLOR))).append(new LiteralText("\u00a7c[Del]").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Remove " + f + " from your friendlist"))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, getPrefix() + "friends remove " + f)))).append("   ").append(new LiteralText("\u00a73[NameMC]").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Open NameMC page of " + f))).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + f))));
            }
            BleachLogger.info(text);
        }
    } else if (args[0].equalsIgnoreCase("clear")) {
        BleachHack.friendMang.getFriends().clear();
        BleachLogger.info("Cleared Friend list");
    } else {
        throw new CmdSyntaxException();
    }
    BleachFileHelper.SCHEDULE_SAVE_FRIENDS.set(true);
}
Also used : LiteralText(net.minecraft.text.LiteralText) CommandCategory(org.bleachhack.command.CommandCategory) BleachHack(org.bleachhack.BleachHack) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Locale(java.util.Locale) ClickEvent(net.minecraft.text.ClickEvent) MutableText(net.minecraft.text.MutableText) Command(org.bleachhack.command.Command) BleachLogger(org.bleachhack.util.BleachLogger) BleachFileHelper(org.bleachhack.util.io.BleachFileHelper) HoverEvent(net.minecraft.text.HoverEvent) StringUtils(org.apache.commons.lang3.StringUtils) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Example 17 with HoverEvent

use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.

the class CmdNBT method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("get")) {
        if (args.length != 2) {
            throw new CmdSyntaxException();
        }
        NbtCompound nbt = getNbt(args[1]);
        if (nbt != null) {
            String stringNbt = NbtHelper.toPrettyPrintedString(nbt);
            Text copy = new LiteralText("\u00a7e\u00a7l<COPY>").styled(s -> s.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stringNbt)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the nbt of this item to your clipboard"))));
            BleachLogger.info(new LiteralText("\u00a76\u00a7lNBT: ").append(copy).append("\u00a76\n" + stringNbt));
        }
    } else if (args[0].equalsIgnoreCase("copy")) {
        if (args.length != 2) {
            throw new CmdSyntaxException();
        }
        NbtCompound nbt = getNbt(args[1]);
        if (nbt != null) {
            mc.keyboard.setClipboard(nbt.toString());
            BleachLogger.info("\u00a76Copied\n\u00a7f" + NbtHelper.toPrettyPrintedString(nbt) + "\n\u00a76to clipboard.");
        }
    } else if (args[0].equalsIgnoreCase("set")) {
        if (!mc.interactionManager.getCurrentGameMode().isCreative()) {
            BleachLogger.error("You must be in creative mode to set NBT!");
            return;
        }
        if (args.length < 2) {
            throw new CmdSyntaxException();
        }
        ItemStack item = mc.player.getMainHandStack();
        item.setNbt(StringNbtReader.parse(StringUtils.join(ArrayUtils.subarray(args, 1, args.length), ' ')));
        BleachLogger.info("\u00a76Set NBT of " + item.getItem().getName().getString() + " to\n" + BleachJsonHelper.formatJson(item.getNbt().toString()));
    } else if (args[0].equalsIgnoreCase("wipe")) {
        if (!mc.interactionManager.getCurrentGameMode().isCreative()) {
            BleachLogger.error("You must be in creative mode to wipe NBT!");
            return;
        }
        mc.player.getMainHandStack().setNbt(new NbtCompound());
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : HoverEvent(net.minecraft.text.HoverEvent) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) NbtCompound(net.minecraft.nbt.NbtCompound) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText)

Example 18 with HoverEvent

use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.

the class BleachCreditsScreen method init.

public void init() {
    super.init();
    addWindow(new Window(width / 8, height / 8, width - width / 8, height - height / 8, "Credits", new ItemStack(Items.DRAGON_HEAD)));
    int w = getWindow(0).x2 - getWindow(0).x1;
    int h = getWindow(0).y2 - getWindow(0).y1;
    getWindow(0).addWidget(new WindowTextWidget(BleachHack.watermark.getText(), true, WindowTextWidget.TextAlign.MIDDLE, 3f, w / 2, 22, 0xb0b0b0));
    getWindow(0).addWidget(new WindowTextWidget(BleachHack.VERSION, true, WindowTextWidget.TextAlign.MIDDLE, 1.5f, w / 2, 41, 0xffc050));
    getWindow(0).addWidget(new WindowTextWidget("- Main Developer -", true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 65, 0xe0e0e0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("Bleach").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/BleachDrinker420\n\n\u00a7eMain Developer!")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 80, 0x51eff5));
    getWindow(0).addWidget(new WindowTextWidget("- Contributors -", true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 100, 0xe0e0e0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("LasnikProgram").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/lasnikprogram\n\n\u00a7fMade first version of LogoutSpot, AirPlace, EntityMenu, HoleESP, AutoParkour and Search.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 115, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("slcoolj").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/slcoolj\n\n\u00a7fMade Criticals, Speedmine OG mode and did the module system rewrite.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 127, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("DevScyu").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/DevScyu\n\n\u00a7fMade first version of AutoTool, Trajectories, NoRender, AutoWalk, ElytraReplace, HandProgress and added Login manager encryption.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 139, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("Bunt3rhund").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/Bunt3rhund\n\n\u00a7fMade first version of Zoom.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 151, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("MorganAnkan").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/MorganAnkan\n\n\u00a7fMade the title screen text Rgb.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 163, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget(new LiteralText("ThePapanoob").styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("\u00a77https://github.com/thepapanoob\n\n\u00a7fAdded Projectiles mode in Killaura.")))), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 175, 0x00a0a0));
    getWindow(0).addWidget(new WindowTextWidget("- Donators/Boosters -", true, WindowTextWidget.TextAlign.MIDDLE, w / 2, 195, 0xe0e0e0));
    int y = 210;
    if (boosterList != null) {
        boostersLoaded = true;
        for (ImmutablePair<Boolean, String> i : boosterList) {
            getWindow(0).addWidget(new WindowTextWidget(getBoosterText(i), true, WindowTextWidget.TextAlign.MIDDLE, w / 2, y, 0));
            y += 12;
        }
    } else {
        getWindow(0).addWidget(new WindowTextWidget("\u00a77Loading..", true, WindowTextWidget.TextAlign.MIDDLE, w / 2, y, 0));
        y += 12;
    }
    for (WindowWidget widget : getWindow(0).getWidgets()) {
        if (!(widget instanceof WindowScrollbarWidget)) {
            widget.cullY = true;
        }
    }
    scrollbar = getWindow(0).addWidget(new WindowScrollbarWidget(w - 11, 12, y - 10, h - 13, 0));
}
Also used : Window(org.bleachhack.gui.window.Window) WindowScrollbarWidget(org.bleachhack.gui.window.widget.WindowScrollbarWidget) HoverEvent(net.minecraft.text.HoverEvent) WindowTextWidget(org.bleachhack.gui.window.widget.WindowTextWidget) ItemStack(net.minecraft.item.ItemStack) WindowWidget(org.bleachhack.gui.window.widget.WindowWidget) LiteralText(net.minecraft.text.LiteralText)

Example 19 with HoverEvent

use of net.minecraft.text.HoverEvent in project BleachHack by BleachDrinker420.

the class BleachOptionsScreen method addCategory.

private int addCategory(int window, int x, int y, String name, Option<?>... entries) {
    getWindow(window).addWidget(new WindowTextWidget("- " + name + " -", true, WindowTextWidget.TextAlign.MIDDLE, x, y, 0xe0e0e0));
    y += 20;
    for (Option<?> entry : entries) {
        // Option
        getWindow(0).addWidget(entry.getWidget(x + 10, y - 3, 56, 16));
        // Revert button
        getWindow(window).addWidget(new WindowButtonWidget(x + 68, y - 3, x + 84, y + 13, "", entry::resetValue).withRenderEvent((w, ms, wx, wy) -> ((WindowButtonWidget) w).text = entry.isDefault() ? "\u00a77\u21c4" : "\u21c4"));
        // Name text (at the end because of... reasons)
        getWindow(window).addWidget(new WindowTextWidget(new LiteralText(entry.getName()).styled(s -> s.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(entry.getTooltip())))), true, x - 107, y, 0xffffff));
        y += 17;
    }
    return y;
}
Also used : WindowScreen(org.bleachhack.gui.window.WindowScreen) LiteralText(net.minecraft.text.LiteralText) MatrixStack(net.minecraft.client.util.math.MatrixStack) Items(net.minecraft.item.Items) WindowWidget(org.bleachhack.gui.window.widget.WindowWidget) WindowButtonWidget(org.bleachhack.gui.window.widget.WindowButtonWidget) HoverEvent(net.minecraft.text.HoverEvent) WindowTextWidget(org.bleachhack.gui.window.widget.WindowTextWidget) ItemStack(net.minecraft.item.ItemStack) Screen(net.minecraft.client.gui.screen.Screen) Window(org.bleachhack.gui.window.Window) WindowScrollbarWidget(org.bleachhack.gui.window.widget.WindowScrollbarWidget) Option(org.bleachhack.setting.option.Option) HoverEvent(net.minecraft.text.HoverEvent) WindowTextWidget(org.bleachhack.gui.window.widget.WindowTextWidget) WindowButtonWidget(org.bleachhack.gui.window.widget.WindowButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Example 20 with HoverEvent

use of net.minecraft.text.HoverEvent in project Client by MatHax.

the class ModulesCommand method getModuleText.

private BaseText getModuleText(Module module) {
    // Hover tooltip
    BaseText tooltip = new LiteralText("");
    tooltip.append(new LiteralText(module.title).formatted(Formatting.RED, Formatting.BOLD)).append("\n");
    tooltip.append(new LiteralText(module.title).formatted(Formatting.GRAY)).append("\n\n");
    tooltip.append(new LiteralText(module.description).formatted(Formatting.WHITE));
    BaseText finalModule = new LiteralText(module.title);
    if (!module.equals(Modules.get().getGroup(module.category).get(Modules.get().getGroup(module.category).size() - 1)))
        finalModule.append(new LiteralText(", ").formatted(Formatting.GRAY));
    finalModule.setStyle(finalModule.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
    return finalModule;
}
Also used : BaseText(net.minecraft.text.BaseText) HoverEvent(net.minecraft.text.HoverEvent) LiteralText(net.minecraft.text.LiteralText)

Aggregations

HoverEvent (net.minecraft.text.HoverEvent)23 LiteralText (net.minecraft.text.LiteralText)23 ClickEvent (net.minecraft.text.ClickEvent)13 BaseText (net.minecraft.text.BaseText)9 ItemStack (net.minecraft.item.ItemStack)7 MutableText (net.minecraft.text.MutableText)7 Formatting (net.minecraft.util.Formatting)7 CommandSource (net.minecraft.command.CommandSource)6 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)5 Text (net.minecraft.text.Text)5 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)4 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 CommandContext (com.mojang.brigadier.context.CommandContext)3 java.util (java.util)3 NbtPathArgumentType (net.minecraft.command.argument.NbtPathArgumentType)3 CreativeInventoryActionC2SPacket (net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket)3 Command (org.bleachhack.command.Command)3 BleachLogger (org.bleachhack.util.BleachLogger)3 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)2