Search in sources :

Example 6 with HoverEvent

use of net.minecraft.event.HoverEvent in project ct.js by ChatTriggers.

the class TextComponent method reInstanceHover.

// helper method to re-instance the hover-able part of the component
private void reInstanceHover() {
    if (this.hoverValue == null)
        return;
    String hoverValue = this.hoverValue;
    if (this.formatted)
        hoverValue = ChatLib.addColor(hoverValue);
    chatComponentText.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.getValueByCanonicalName(this.hoverAction), new ChatComponentText(hoverValue)));
}
Also used : HoverEvent(net.minecraft.event.HoverEvent) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 7 with HoverEvent

use of net.minecraft.event.HoverEvent in project Armourers-Workshop by RiskyKen.

the class RehostedJarHandler method onPlayerTick.

@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    if (validJar) {
        return;
    }
    if (event.side != Side.CLIENT) {
        return;
    }
    if (event.type != Type.PLAYER) {
        return;
    }
    if (event.phase != Phase.END) {
        return;
    }
    if (lastMessagePost + messagePostRate > System.currentTimeMillis()) {
        return;
    }
    lastMessagePost = System.currentTimeMillis();
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    ChatComponentTranslation downloadLink = new ChatComponentTranslation("chat.armourersworkshop:invalidJarDownload", (Object) null);
    downloadLink.getChatStyle().setUnderlined(true);
    downloadLink.getChatStyle().setColor(EnumChatFormatting.BLUE);
    downloadLink.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentTranslation("chat.armourersworkshop:invalidJarDownloadTooltip", (Object) null)));
    downloadLink.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, LibModInfo.DOWNLOAD_URL));
    ChatComponentTranslation stopModRepostsLink = new ChatComponentTranslation("chat.armourersworkshop:invalidJarStopModReposts", (Object) null);
    stopModRepostsLink.getChatStyle().setUnderlined(true);
    stopModRepostsLink.getChatStyle().setColor(EnumChatFormatting.BLUE);
    stopModRepostsLink.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentTranslation("chat.armourersworkshop:invalidJarStopModRepostsTooltip", (Object) null)));
    stopModRepostsLink.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, STOP_MOD_REPOSTS_URL));
    ChatComponentTranslation updateMessage = new ChatComponentTranslation("chat.armourersworkshop:invalidJar", downloadLink, stopModRepostsLink);
    updateMessage.getChatStyle().setColor(EnumChatFormatting.RED);
    player.addChatMessage(updateMessage);
}
Also used : HoverEvent(net.minecraft.event.HoverEvent) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ClickEvent(net.minecraft.event.ClickEvent) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

HoverEvent (net.minecraft.event.HoverEvent)7 ClickEvent (net.minecraft.event.ClickEvent)6 ChatComponentText (net.minecraft.util.ChatComponentText)4 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)2 ChatStyle (net.minecraft.util.ChatStyle)2 IChatComponent (net.minecraft.util.IChatComponent)2 Hyperium (cc.hyperium.Hyperium)1 InvokeEvent (cc.hyperium.event.InvokeEvent)1 Levelhead (cc.hyperium.mods.levelhead.Levelhead)1 cc.hyperium.mods.levelhead.display (cc.hyperium.mods.levelhead.display)1 LevelheadDisplay (cc.hyperium.mods.levelhead.display.LevelheadDisplay)1 LevelheadPurchaseStates (cc.hyperium.mods.levelhead.purchases.LevelheadPurchaseStates)1 LevelheadChatRenderer (cc.hyperium.mods.levelhead.renderer.LevelheadChatRenderer)1 LevelheadJsonHolder (cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)1 Multithreading (cc.hyperium.mods.sk1ercommon.Multithreading)1 Sk1erMod (cc.hyperium.mods.sk1ercommon.Sk1erMod)1 ChatColor (cc.hyperium.utils.ChatColor)1 JsonHolder (cc.hyperium.utils.JsonHolder)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 java.awt (java.awt)1