net.minecraft.util.text.Style Java Examples

The following examples show how to use net.minecraft.util.text.Style. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 8 votes vote down vote up
private static ITextComponent stripEvents(ITextComponent c) {
    Style modi = c.getStyle();
    if (modi != null) {
        modi.setClickEvent(null);
        modi.setHoverEvent(null);
    }
    c.setStyle(modi);
    if (c instanceof TextComponentTranslation) {
        TextComponentTranslation cm = (TextComponentTranslation) c;
        Object[] oo = cm.getFormatArgs();
        for (int i = 0; i < oo.length; i++) {
            Object o = oo[i];
            if (o instanceof ITextComponent) {
                oo[i] = stripEvents((ITextComponent) o);
            }
        }
    }
    List<ITextComponent> ls = c.getSiblings();
    if (ls != null) {
        for (int i = 0; i < ls.size(); i++) {
            ls.set(i, stripEvents(ls.get(i)));
        }
    }
    return c;
}
 
Example #2
Source File: MultiblockWithDisplayBase.java    From GregTech with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Called serverside to obtain text displayed in GUI
 * each element of list is displayed on new line
 * to use translation, use TextComponentTranslation
 */
protected void addDisplayText(List<ITextComponent> textList) {
    if (!isStructureFormed()) {
        ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.invalid_structure.tooltip");
        tooltip.setStyle(new Style().setColor(TextFormatting.GRAY));
        textList.add(new TextComponentTranslation("gregtech.multiblock.invalid_structure")
            .setStyle(new Style().setColor(TextFormatting.RED)
                .setHoverEvent(new HoverEvent(Action.SHOW_TEXT, tooltip))));
    }
}
 
Example #3
Source File: PortalFinderModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
private void printPortalToChat(Vec3d portal) {
    final TextComponentString portalTextComponent = new TextComponentString("Portal found!");

    String overworld = "";
    String nether = "";

    if (Minecraft.getMinecraft().player.dimension == 0) { // overworld
        overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
        nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x / 8, (int) portal.y, (int) portal.z / 8);
    } else if (Minecraft.getMinecraft().player.dimension == -1) { // nether
        overworld = String.format("Overworld: X: %s, Y: %s, Z: %s", (int) portal.x * 8, (int) portal.y, (int) portal.z * 8);
        nether = String.format("Nether: X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
    }

    int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z);
    String distance = ChatFormatting.GRAY + "" + playerDistance + "m away";

    String hoverText = overworld + "\n" + nether + "\n" + distance;
    portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText))));

    Seppuku.INSTANCE.logcChat(portalTextComponent);
}
 
Example #4
Source File: ModuleCommand.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 1, 1)) {
        this.printUsage();
        return;
    }

    final int size = Seppuku.INSTANCE.getModuleManager().getModuleList().size();

    final TextComponentString msg = new TextComponentString("\2477Modules [" + size + "]\247f ");

    final CommandsModule commandsModule = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);

    for (int i = 0; i < size; i++) {
        final Module mod = Seppuku.INSTANCE.getModuleManager().getModuleList().get(i);
        if (mod != null) {
            msg.appendSibling(new TextComponentString((mod.isEnabled() ? "\247a" : "\247c") + mod.getDisplayName() + "\2477" + ((i == size - 1) ? "" : ", "))
                    .setStyle(new Style()
                            .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + (mod.getDesc() == null ? "There is no description for this module" : mod.getDesc()) + "\247f").appendSibling(new TextComponentString((mod.toUsageTextComponent() == null ? "" : "\n" + mod.toUsageTextComponent().getText()) + "\247f"))))
                            .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, commandsModule.getPrefix().getValue() + "toggle" + " " + mod.getDisplayName()))));
        }
    }

    Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(msg);
}
 
Example #5
Source File: HelpCommand.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 1, 1)) {
        this.printUsage();
        return;
    }

    final int size = Seppuku.INSTANCE.getCommandManager().getCommandList().size();

    final TextComponentString msg = new TextComponentString("\2477Commands [" + size + "]\247f ");

    for (int i = 0; i < size; i++) {
        final Command cmd = Seppuku.INSTANCE.getCommandManager().getCommandList().get(i);

        msg.appendSibling(new TextComponentString("\247a" + cmd.getDisplayName() + "\2477" + ((i == size - 1) ? "" : ", "))
                .setStyle(new Style()
                        .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\2476" + cmd.getDesc() + "\247f")
                                .appendSibling(new TextComponentString("\n" + cmd.getUsage()))))));
    }

    Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(msg);
}
 
Example #6
Source File: MetaTileEntityLargeTurbine.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void addDisplayText(List<ITextComponent> textList) {
    if (isStructureFormed()) {
        MetaTileEntityRotorHolder rotorHolder = getAbilities(ABILITY_ROTOR_HOLDER).get(0);
        FluidStack fuelStack = ((LargeTurbineWorkableHandler) workableHandler).getFuelStack();
        int fuelAmount = fuelStack == null ? 0 : fuelStack.amount;

        ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName());
        textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.fuel_amount", fuelAmount, fuelName));

        if (rotorHolder.getRotorEfficiency() > 0.0) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_speed", rotorHolder.getCurrentRotorSpeed(), rotorHolder.getMaxRotorSpeed()));
            textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_efficiency", (int) (rotorHolder.getRotorEfficiency() * 100)));
            int rotorDurability = (int) (rotorHolder.getRotorDurability() * 100);
            if (rotorDurability > MIN_DURABILITY_TO_WARN) {
                textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_durability", rotorDurability));
            } else {
                textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.low_rotor_durability",
                    MIN_DURABILITY_TO_WARN, rotorDurability).setStyle(new Style().setColor(TextFormatting.RED)));
            }
        }
    }
    super.addDisplayText(textList);
}
 
Example #7
Source File: Helper.java    From ForgeHax with MIT License 6 votes vote down vote up
public static void printMessageNaked(
    String startWith, String message, Style firstStyle, Style secondStyle) {
  if (!Strings.isNullOrEmpty(message)) {
    if (message.contains("\n")) {
      Scanner scanner = new Scanner(message);
      scanner.useDelimiter("\n");
      Style s1 = firstStyle;
      Style s2 = secondStyle;
      while (scanner.hasNext()) {
        printMessageNaked(startWith, scanner.next(), s1, s2);
        // alternate between colors each newline
        Style cpy = s1;
        s1 = s2;
        s2 = cpy;
      }
    } else {
      TextComponentString string =
          new TextComponentString(startWith + message.replaceAll("\r", ""));
      string.setStyle(firstStyle);
      outputMessage(string.getFormattedText());
    }
  }
}
 
Example #8
Source File: HICommand.java    From HoloInventory with MIT License 5 votes vote down vote up
private void showHelp(ICommandSender sender)
{
    sender.sendMessage(new TextComponentString(HoloInventory.MODID).setStyle(new Style().setColor(TextFormatting.AQUA)).appendSibling(new TextComponentString(" by Dries007").setStyle(new Style().setColor(TextFormatting.WHITE))));
    sender.sendMessage(new TextComponentString("This command depends on the context in which it is used."));
    sender.sendMessage(new TextComponentString("On a server (OP only) it can be used to (un)ban a block type, server wide."));
    sender.sendMessage(new TextComponentString("On a client (SSP) it can be used to (un)ban a block type, client side only."));
    sender.sendMessage(new TextComponentString("Syntax:").setStyle(new Style().setUnderlined(true)));
    sender.sendMessage(new TextComponentString("/" + getName() + " <ban>"));
    sender.sendMessage(new TextComponentString("        Ban the next block you right click."));
    sender.sendMessage(new TextComponentString("/" + getName() + " <unban> [name]"));
    sender.sendMessage(new TextComponentString("        Un ban the next block you right click, or specified via the name."));
    sender.sendMessage(new TextComponentString("/" + getName() + " <list>"));
    sender.sendMessage(new TextComponentString("        Print a list of banned block types on the current side."));
}
 
Example #9
Source File: PortalFinderModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private void printEndPortalToChat(Vec3d portal) {
    final TextComponentString portalTextComponent = new TextComponentString("End Portal found!");

    String coords = String.format("X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
    int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z);
    String distance = ChatFormatting.GRAY + "" + playerDistance + "m away";

    String hoverText = coords + "\n" + distance;
    portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText))));

    Seppuku.INSTANCE.logcChat(portalTextComponent);
}
 
Example #10
Source File: HICommand.java    From HoloInventory with MIT License 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (isOP(sender)) throw new CommandException(getUsage(sender));
    else if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h") || args[0].equalsIgnoreCase("?"))  showHelp(sender);
    else if (args[0].equalsIgnoreCase("ban"))
    {
        ServerEventHandler.catchNext = ServerEventHandler.Type.BAN;
        sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA)));
    }
    else if (args[0].equalsIgnoreCase("unban"))
    {
        if (args.length == 1)
        {
            ServerEventHandler.catchNext = ServerEventHandler.Type.UNBAN;
            sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA)));
        }
        else
        {
            boolean wasBanned = Helper.banned.remove(args[1]);
            if (wasBanned)
                sender.sendMessage(new TextComponentString("Unbanned " + args[1]).setStyle(new Style().setColor(TextFormatting.GREEN)));
            else
                sender.sendMessage(new TextComponentString(args[1] + " is not banned.").setStyle(new Style().setColor(TextFormatting.RED)));
        }
    }
    else if (args[0].equalsIgnoreCase("list"))
    {
        sender.sendMessage(new TextComponentString(HoloInventory.MODID.concat(" banlist:")).setStyle(new Style().setColor(TextFormatting.AQUA)));
        for (String type : Helper.banned)
        {
            sender.sendMessage(new TextComponentString(type));
        }
    }
    else throw new WrongUsageException(getUsage(sender));
}
 
Example #11
Source File: ServerEventHandler.java    From HoloInventory with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onRightClick(PlayerInteractEvent.RightClickBlock event)
{
    if (catchNext == Type.NONE) return;
    boolean ban = catchNext == Type.BAN;
    catchNext = Type.NONE;
    event.setCanceled(true);

    TileEntity te = event.getWorld().getTileEntity(event.getPos());

    if (te == null)
    {
        event.getEntityPlayer().sendMessage(new TextComponentString("That block does not have a TileEntity.").setStyle(new Style().setColor(TextFormatting.RED)));
        return;
    }

    if (ban)
    {
        if (Helper.banned.add(te.getClass().getCanonicalName()))
            event.getEntityPlayer().sendMessage(new TextComponentString("Banned " + te.getClass().getCanonicalName()).setStyle(new Style().setColor(TextFormatting.GREEN)));
        else
            event.getEntityPlayer().sendMessage(new TextComponentString(te.getClass().getCanonicalName() + " is already banned.").setStyle(new Style().setColor(TextFormatting.RED)));
    }
    else
    {
        boolean wasBanned = Helper.banned.remove(te.getClass().getCanonicalName());
        if (wasBanned)
            event.getEntityPlayer().sendMessage(new TextComponentString("Unbanned " + te.getClass().getCanonicalName()).setStyle(new Style().setColor(TextFormatting.GREEN)));
        else
            event.getEntityPlayer().sendMessage(new TextComponentString(te.getClass().getCanonicalName() + " is not banned. Perhaps it is banned on the " + (FMLCommonHandler.instance().getSide().isClient() ? "server" : "client") + "?").setStyle(new Style().setColor(TextFormatting.RED)));
    }

    HoloInventory.getInstance().saveBanned();
}
 
Example #12
Source File: AgentQuitFromTimeUpImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
protected void drawCountDown(int secondsRemaining)
{
       TextComponentString text = new TextComponentString("" + secondsRemaining + "...");
       Style style = new Style();
       style.setBold(true);
       if (secondsRemaining <= 5)
           style.setColor(TextFormatting.RED);

       text.setStyle(style);
       Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
 
Example #13
Source File: ConsoleIO.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void write(String msg, Style style) {
  String tab = Strings.repeat('>', Math.max(getOrCreate().get(), MIN_INDENT)) + " ";
  if (style == null) {
    Helper.printMessageNaked(tab, msg); // TODO: use a non-chat console
  } else {
    Helper.printMessageNaked(tab, msg, style); // TODO: use a non-chat console
  }
}
 
Example #14
Source File: Helper.java    From ForgeHax with MIT License 5 votes vote down vote up
private static ITextComponent getFormattedText(String text, TextFormatting color,
    boolean bold, boolean italic) {
  return new TextComponentString(text.replaceAll("\r", ""))
      .setStyle(new Style()
          .setColor(color)
          .setBold(bold)
          .setItalic(italic)
      );
}
 
Example #15
Source File: Helper.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void printMessageNaked(String append, String message) {
  printMessageNaked(
      append,
      message,
      new Style().setColor(TextFormatting.WHITE),
      new Style().setColor(TextFormatting.GRAY));
}
 
Example #16
Source File: CommandWorldgenReload.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
    try {
        WorldGenRegistry.INSTANCE.reinitializeRegisteredVeins();
        sender.sendMessage(new TextComponentTranslation("gregtech.command.worldgen.reload.success")
            .setStyle(new Style().setColor(TextFormatting.GREEN)));
    } catch (IOException | RuntimeException exception) {
        GTLog.logger.error("Failed to reload worldgen config", exception);
        sender.sendMessage(new TextComponentTranslation("gregtech.command.worldgen.reload.failed")
            .setStyle(new Style().setColor(TextFormatting.RED)));
    }
}
 
Example #17
Source File: RecipeMapMultiblockController.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void addDisplayText(List<ITextComponent> textList) {
    super.addDisplayText(textList);
    if (isStructureFormed()) {
        IEnergyContainer energyContainer = recipeMapWorkable.getEnergyContainer();
        if (energyContainer != null && energyContainer.getEnergyCapacity() > 0) {
            long maxVoltage = energyContainer.getInputVoltage();
            String voltageName = GTValues.VN[GTUtility.getTierByVoltage(maxVoltage)];
            textList.add(new TextComponentTranslation("gregtech.multiblock.max_energy_per_tick", maxVoltage, voltageName));
        }

        if (!recipeMapWorkable.isWorkingEnabled()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused"));

        } else if (recipeMapWorkable.isActive()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.running"));
            int currentProgress = (int) (recipeMapWorkable.getProgressPercent() * 100);
            textList.add(new TextComponentTranslation("gregtech.multiblock.progress", currentProgress));
        } else {
            textList.add(new TextComponentTranslation("gregtech.multiblock.idling"));
        }

        if (recipeMapWorkable.isHasNotEnoughEnergy()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.not_enough_energy").setStyle(new Style().setColor(TextFormatting.RED)));
        }
    }
}
 
Example #18
Source File: EntityPenguin.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
	boolean ret = super.processInteract(player, hand);
	if (player.world.isRemote && hand == EnumHand.MAIN_HAND) {
		player.sendMessage(new TextComponentString(
				"If you like these penguins, you'll like the full version more!"));
		player.sendMessage(new TextComponentString("Click [here] to download it on CurseForge.")
				.setStyle(new Style().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
						"https://minecraft.curseforge.com/projects/penguins"))));
	}
	return ret;
}
 
Example #19
Source File: CalcStrongholdCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (this.firstStart != null && this.firstEnd != null && this.secondStart != null && this.secondEnd != null) {
            final double[] start = new double[]{this.secondStart.x, this.secondStart.z, this.secondEnd.x, this.secondEnd.z};
            final double[] end = new double[]{this.firstStart.x, this.firstStart.z, this.firstEnd.x, this.firstEnd.z};
            final double[] intersection = MathUtil.calcIntersection(start, end);

            if (Double.isNaN(intersection[0]) || Double.isNaN(intersection[1]) || Double.isInfinite(intersection[0]) || Double.isInfinite(intersection[1])) {
                Seppuku.INSTANCE.errorChat("Error lines are parallel");
                Seppuku.INSTANCE.getEventManager().removeEventListener(this);
                return;
            }

            final double dist = Minecraft.getMinecraft().player.getDistance(intersection[0], Minecraft.getMinecraft().player.posY, intersection[1]);

            final TextComponentString component = new TextComponentString("Stronghold found " + ChatFormatting.GRAY + (int) dist + "m away");
            final String coords = String.format("X: %s, Y: ?, Z: %s\nClick to add a Waypoint", (int) intersection[0], (int) intersection[1]);
            final CommandsModule cmds = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);

            if (cmds != null) {
                component.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(coords))).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmds.prefix.getValue() + "Waypoints add Stronghold " + intersection[0] + " " + Minecraft.getMinecraft().player.posY + " " + intersection[1])));
            }

            Seppuku.INSTANCE.logcChat(component);
            Seppuku.INSTANCE.getNotificationManager().addNotification("", "Stronghold found " + ChatFormatting.GRAY + (int) dist + "m away");
            this.firstStart = null;
            this.firstEnd = null;
            this.secondStart = null;
            this.secondEnd = null;
            Seppuku.INSTANCE.getEventManager().removeEventListener(this);
        }
    }
}
 
Example #20
Source File: Helper.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void printMessageNaked(String append, String message, Style style) {
  printMessageNaked(append, message, style, style);
}
 
Example #21
Source File: JoinMessage.java    From ForgeHax with MIT License 4 votes vote down vote up
private void debugMessage(String str) {
  if (debug_messages.get()) {
    Helper.printMessageNaked(
        Strings.EMPTY, str, new Style().setItalic(true).setColor(TextFormatting.GRAY));
  }
}
 
Example #22
Source File: CommandHand.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        ItemStack stackInHand = player.inventory.getCurrentItem();
        if (stackInHand.isEmpty()) {
            throw new CommandException("gregtech.command.util.hand.no_item");
        }
        String registryName = stackInHand.getItem().getRegistryName().toString();
        ClickEvent itemNameEvent = new ClickEvent(Action.OPEN_URL, registryName);
        player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.item_id", registryName, stackInHand.getItemDamage())
            .setStyle(new Style().setClickEvent(itemNameEvent)));

        IElectricItem electricItem = stackInHand.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
        IFluidHandlerItem fluidHandlerItem = stackInHand.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
        if (electricItem != null) {
            player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.electric",
                electricItem.getCharge(),
                electricItem.getMaxCharge(),
                electricItem.getTier(),
                Boolean.toString(electricItem.canProvideChargeExternally())));
        }

        if (fluidHandlerItem != null) {
            for (IFluidTankProperties properties : fluidHandlerItem.getTankProperties()) {
                FluidStack contents = properties.getContents();
                String fluidName = contents == null ? "empty" : contents.getFluid().getName();
                ClickEvent fluidClickEvent = new ClickEvent(Action.OPEN_URL, fluidName);
                player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.fluid",
                    fluidName,
                    contents == null ? 0 : contents.amount,
                    properties.getCapacity(),
                    Boolean.toString(properties.canFill()), Boolean.toString(properties.canDrain()))
                .setStyle(new Style().setClickEvent(fluidClickEvent)));
            }
        }

        if (stackInHand.getItem() instanceof MetaItem) {
            MetaItem<?> metaItem = (MetaItem<?>) stackInHand.getItem();
            MetaValueItem metaValueItem = metaItem.getItem(stackInHand);
            if (metaValueItem == null) {
                if (metaItem instanceof MaterialMetaItem) {
                    Material material = ((MaterialMetaItem) metaItem).getMaterial(stackInHand);
                    OrePrefix orePrefix = ((MaterialMetaItem) metaItem).getOrePrefix(stackInHand);
                    String oreDictName = new UnificationEntry(orePrefix, material).toString();
                    player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.material_meta_item", orePrefix, material)
                        .setStyle(new Style().setClickEvent(new ClickEvent(Action.OPEN_URL, oreDictName))));
                }
            } else {
                if (metaValueItem instanceof ToolMetaItem.MetaToolValueItem) {
                    IToolStats toolStats = ((MetaToolValueItem) metaValueItem).getToolStats();
                    player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.tool_stats", toolStats.getClass().getName()));
                }
                ClickEvent metaItemEvent = new ClickEvent(Action.OPEN_URL, metaValueItem.unlocalizedName);
                player.sendMessage(new TextComponentTranslation("gregtech.command.util.hand.meta_item", metaValueItem.unlocalizedName, metaValueItem)
                    .setStyle(new Style().setClickEvent(metaItemEvent)));
            }
        }
    } else {
        throw new CommandException("gregtech.command.util.hand.not_a_player");
    }
}
 
Example #23
Source File: ToggleButton.java    From MiningGadgets with MIT License 4 votes vote down vote up
public List<String> getTooltip() {
    return Arrays.asList(this.getMessage(), new StringTextComponent("Enabled: " + this.enabled).setStyle(new Style().setColor(this.enabled ? TextFormatting.GREEN : TextFormatting.RED)).getFormattedText());
}