Search in sources :

Example 21 with ClickEvent

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

the class RCTextStyle method area.

public static ITextComponent area(BlockArea area) {
    ITextComponent component = ServerTranslations.format("commands.rcarea.get", pos(area.getPoint1()), pos(area.getPoint2()));
    component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcarea.select")));
    component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s %s %d %d %d %d %d %d --first --second", RCCommands.select.getName(), RCCommands.select.set.getName(), area.getPoint1().getX(), area.getPoint1().getY(), area.getPoint1().getZ(), area.getPoint2().getX(), area.getPoint2().getY(), area.getPoint2().getZ())));
    return component;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Example 22 with ClickEvent

use of net.minecraft.util.text.event.ClickEvent in project MorePlanets by SteveKunG.

the class ClientEventHandler method onPlayerTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerTick(PlayerTickEvent event) {
    String URL = "https://minecraft.curseforge.com/projects/galacticraft-add-on-more-planets";
    JsonUtil json = new JsonUtil();
    EntityPlayer player = event.player;
    if (player != null) {
        // prevent randomly NPE
        if (this.mc.player == player) {
            this.runAlienBeamTick(player);
        }
        // 0 = OutOfDate, 1 = ShowDesc, 2 = NoConnection
        if (player.world.isRemote) {
            if (ConfigManagerMP.enableVersionChecker) {
                if (!MorePlanetsCore.STATUS_CHECK[2] && VersionChecker.INSTANCE.noConnection()) {
                    player.sendMessage(json.text("Unable to check latest version, Please check your internet connection").setStyle(json.red()));
                    player.sendMessage(json.text(VersionChecker.INSTANCE.getExceptionMessage()).setStyle(json.red()));
                    MorePlanetsCore.STATUS_CHECK[2] = true;
                    return;
                }
                if (!MorePlanetsCore.STATUS_CHECK[0] && !MorePlanetsCore.STATUS_CHECK[2] && VersionChecker.INSTANCE.isLatestVersion()) {
                    player.sendMessage(json.text("New version of ").appendSibling(json.text("More Planets").setStyle(json.style().setColor(TextFormatting.AQUA)).appendSibling(json.text(" is available ").setStyle(json.white()).appendSibling(json.text("v" + VersionChecker.INSTANCE.getLatestVersion().replace("[" + MorePlanetsCore.MC_VERSION + "]=", "")).setStyle(json.style().setColor(TextFormatting.GREEN)).appendSibling(json.text(" for ").setStyle(json.white()).appendSibling(json.text("MC-" + MorePlanetsCore.MC_VERSION).setStyle(json.style().setColor(TextFormatting.GOLD))))))));
                    player.sendMessage(json.text("Download Link ").setStyle(json.style().setColor(TextFormatting.YELLOW)).appendSibling(json.text("[CLICK HERE]").setStyle(json.style().setColor(TextFormatting.BLUE).setHoverEvent(json.hover(HoverEvent.Action.SHOW_TEXT, json.text("Click Here!").setStyle(json.style().setColor(TextFormatting.DARK_GREEN)))).setClickEvent(json.click(ClickEvent.Action.OPEN_URL, URL)))));
                    MorePlanetsCore.STATUS_CHECK[0] = true;
                }
            }
            if (ConfigManagerMP.enableChangeLogInGame) {
                if (!MorePlanetsCore.STATUS_CHECK[1] && !MorePlanetsCore.STATUS_CHECK[2]) {
                    for (String log : VersionChecker.INSTANCE.getChangeLog()) {
                        player.sendMessage(json.text(log).setStyle(json.colorFromConfig("gray")));
                    }
                    player.sendMessage(json.text("To read More Planets full change log. Use /mpchangelog command!").setStyle(json.colorFromConfig("gray").setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/mpchangelog"))));
                }
                MorePlanetsCore.STATUS_CHECK[1] = true;
            }
        }
    }
}
Also used : ClickEvent(net.minecraft.util.text.event.ClickEvent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) JsonUtil(stevekung.mods.moreplanets.util.JsonUtil) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ClickEvent (net.minecraft.util.text.event.ClickEvent)22 HoverEvent (net.minecraft.util.text.event.HoverEvent)16 TextComponentString (net.minecraft.util.text.TextComponentString)9 ITextComponent (net.minecraft.util.text.ITextComponent)8 Nonnull (javax.annotation.Nonnull)7 Style (net.minecraft.util.text.Style)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 Colony (com.minecolonies.coremod.colony.Colony)2 BlockPos (net.minecraft.util.math.BlockPos)2 CitizenData (com.minecolonies.coremod.colony.CitizenData)1 IColony (com.minecolonies.coremod.colony.IColony)1 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)1 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)1 WorldRandomData (ivorius.reccomplex.world.gen.feature.WorldRandomData)1 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)1 Metadata (ivorius.reccomplex.world.gen.feature.structure.generic.Metadata)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1