Search in sources :

Example 1 with HoverEvent

use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.

the class RCTextStyle method visitFile.

@Nonnull
public static ITextComponent visitFile(String id) {
    ITextComponent submit = ServerTranslations.get("reccomplex.save.submit");
    submit.getStyle().setColor(TextFormatting.AQUA);
    submit.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("reccomplex.save.submit.hover")));
    submit.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Repository.submitURL(id)));
    return submit;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Nonnull(javax.annotation.Nonnull)

Example 2 with HoverEvent

use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.

the class GuiHider method hideGUI.

public static boolean hideGUI() {
    if (!canHide())
        return false;
    Minecraft mc = Minecraft.getMinecraft();
    hiddenGUI = mc.currentScreen;
    if (hiddenGUI == null)
        return false;
    mc.displayGuiScreen(null);
    ITextComponent reopen = new TextComponentString("/" + RCCommands.reopen.getName());
    reopen.getStyle().setColor(TextFormatting.GREEN);
    reopen.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.reopen.getName()));
    reopen.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcreopen.run")));
    mc.player.sendMessage(ServerTranslations.format("commands.rc.didhide", reopen));
    return true;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Minecraft(net.minecraft.client.Minecraft) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 3 with HoverEvent

use of net.minecraft.util.text.event.HoverEvent in project AgriCraft by AgriCraft.

the class DebugModeIGrowable method debugActionBlockClicked.

@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return;
    }
    // Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
    StringBuilder outputRaw = new StringBuilder(String.format("`7%1$4d,%2$4d,%3$4d`r ", pos.getX(), pos.getY(), pos.getZ()));
    // Check if the clicked on block has the IGrowable interface.
    final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
    if (crop == null) {
        // If it does not, add a nicely formatted report, then skip onward.
        outputRaw.append(chatNotIG);
    } else {
        // Otherwise run the tests and record the results.
        IBlockState state = world.getBlockState(pos);
        // canGrow
        outputRaw.append(crop.canGrow(world, pos, state, false) ? chatTrue : chatFalse);
        // canUseBonemeal
        outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse);
        // grow
        crop.grow(world, world.rand, pos, state);
        // It's also helpful to also make clear what block was being tested.
        // '3' is dark aqua.
        outputRaw.append("`3");
        outputRaw.append(crop.toString().replaceFirst("Block", ""));
        outputRaw.append("`r");
    }
    // Ellipsis are added as a clue that there's more text.
    // '8' is dark gray.
    outputRaw.append(" `8[...]`r");
    // Create a hover box with explanatory information.
    TextComponentString hoverComponent = new TextComponentString(MessageUtil.colorize(chatInfo));
    HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);
    // Turn the output String into a chat message.
    TextComponentString outputComponent = new TextComponentString(MessageUtil.colorize(outputRaw.toString()));
    // Add the hover box to the chat message.
    outputComponent.getStyle().setHoverEvent(hoverEvent);
    // Now send the completed chat message.
    player.sendMessage(outputComponent);
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) IBlockState(net.minecraft.block.state.IBlockState) IGrowable(net.minecraft.block.IGrowable) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 4 with HoverEvent

use of net.minecraft.util.text.event.HoverEvent in project Wizardry by TeamWizardry.

the class VersionChecker method onTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTick(TickEvent.ClientTickEvent event) {
    EntityPlayer player = Minecraft.getMinecraft().player;
    if (!ConfigValues.versionCheckerEnabled)
        return;
    if (doneChecking && event.phase == TickEvent.Phase.END && player != null && !triedToWarnPlayer) {
        ITextComponent component = new TextComponentString("[").setStyle(new Style().setColor(TextFormatting.GREEN)).appendSibling(new TextComponentTranslation("wizardry.misc.update_link").setStyle(new Style().setColor(TextFormatting.GRAY))).appendSibling(new TextComponentString("]").setStyle(new Style().setColor(TextFormatting.GREEN)));
        component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(updateMessage))).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://minecraft.curseforge.com/projects/wizardry-mod/files"));
        if (onlineVersion != null && !onlineVersion.isEmpty()) {
            String clientBuild = Wizardry.VERSION;
            if (Utils.compareVersions(onlineVersion, clientBuild) == 1) {
                ArrayList<String> messages = new ArrayList<>();
                String base = "wizardry.update";
                int n = 0;
                while (LibrarianLib.PROXY.canTranslate(base + n)) messages.add(base + n++);
                if (!messages.isEmpty())
                    player.sendMessage(new TextComponentTranslation(messages.get(RandUtil.nextInt(messages.size() - 1))).setStyle(new Style().setColor(TextFormatting.YELLOW)));
                player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker0").setStyle(new Style().setColor(TextFormatting.GREEN)));
                player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker1").setStyle(new Style().setColor(TextFormatting.GREEN)).appendText(" ").appendSibling(new TextComponentString(" " + clientBuild).setStyle(new Style().setColor(TextFormatting.RED))));
                player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker2").setStyle(new Style().setColor(TextFormatting.GREEN)).appendText(" ").appendSibling(new TextComponentString(" " + onlineVersion).setStyle(new Style().setColor(TextFormatting.YELLOW))));
                if (updateMessage != null && !updateMessage.isEmpty())
                    player.sendMessage(component);
            } else if (updateMessage != null && !updateMessage.isEmpty())
                player.sendMessage(component);
        }
        triedToWarnPlayer = true;
    }
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with HoverEvent

use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.

the class CommandListStructures method linkToPage.

public static void linkToPage(ITextComponent component, int page, ITextComponent hoverTitle) {
    component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s", RCCommands.structures.list(page))));
    component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTitle));
    component.getStyle().setColor(TextFormatting.AQUA);
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Aggregations

HoverEvent (net.minecraft.util.text.event.HoverEvent)30 ClickEvent (net.minecraft.util.text.event.ClickEvent)21 ITextComponent (net.minecraft.util.text.ITextComponent)9 TextComponentString (net.minecraft.util.text.TextComponentString)9 Nonnull (javax.annotation.Nonnull)8 IGrowable (net.minecraft.block.IGrowable)2 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 Style (net.minecraft.util.text.Style)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 TextFormatting (net.minecraft.util.text.TextFormatting)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 JsonObject (com.google.gson.JsonObject)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 CommandContext (com.mojang.brigadier.context.CommandContext)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)1 ivorius.mcopts.commands.parameters (ivorius.mcopts.commands.parameters)1