Search in sources :

Example 36 with ClickEvent

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

the class RCTextStyle method copy.

public static ITextComponent copy(String text) {
    ITextComponent comp = new TextComponentString(text);
    comp.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RecurrentComplex.translations.get("commands.rccopy.suggest")));
    comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, text));
    return comp;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Example 37 with ClickEvent

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

the class RCTextStyle method structure.

public static ITextComponent structure(String id) {
    TextComponentString comp = new TextComponentString(id);
    comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s", RCCommands.structures.lookup(id))));
    comp.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RecurrentComplex.translations.get("commands.rcsearch.lookup")));
    comp.getStyle().setColor(TextFormatting.AQUA);
    return comp;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent)

Example 38 with ClickEvent

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

the class RCTextStyle method submit.

@Nonnull
public static ITextComponent submit(String id) {
    ITextComponent submit = RecurrentComplex.translations.get("reccomplex.save.submit");
    submit.getStyle().setColor(TextFormatting.AQUA);
    submit.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RecurrentComplex.translations.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 39 with ClickEvent

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

the class RCTextStyle method biome.

@Nonnull
public static ITextComponent biome(Biome biome) {
    ITextComponent component = new TextComponentString(biome.getBiomeName());
    Style style = component.getStyle();
    style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s types %s", RCCommands.biomeDict.getName(), biome.getRegistryName())));
    style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RecurrentComplex.translations.format("commands.biomedict.list.number", BiomeDictionary.getTypes(biome).size())));
    style.setColor(TextFormatting.AQUA);
    return component;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Nonnull(javax.annotation.Nonnull)

Example 40 with ClickEvent

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

the class RCTextStyle method visit.

@Nonnull
public static ITextComponent visit(File file, String... path) {
    ITextComponent pathComponent = new TextComponentString(String.join("/", path));
    pathComponent.getStyle().setColor(TextFormatting.GOLD);
    pathComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Visit File")));
    pathComponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()));
    return pathComponent;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) Nonnull(javax.annotation.Nonnull)

Aggregations

ClickEvent (net.minecraft.util.text.event.ClickEvent)41 HoverEvent (net.minecraft.util.text.event.HoverEvent)21 TextComponentString (net.minecraft.util.text.TextComponentString)19 ITextComponent (net.minecraft.util.text.ITextComponent)16 Style (net.minecraft.util.text.Style)10 Nonnull (javax.annotation.Nonnull)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6 BlockPos (net.minecraft.util.math.BlockPos)4 JsonObject (com.google.gson.JsonObject)3 Colony (com.minecolonies.coremod.colony.Colony)3 Minecraft (net.minecraft.client.Minecraft)3 JsonArray (com.google.gson.JsonArray)2 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Matcher (java.util.regex.Matcher)2 CommandException (net.minecraft.command.CommandException)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 JsonElement (com.google.gson.JsonElement)1