Class ComponentUtil

java.lang.Object
org.moddingx.libx.util.game.ComponentUtil

public class ComponentUtil extends Object
Utilities for text components.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getConsoleString(net.minecraft.network.chat.Component tc)
    Gets a text component as a string formatted with ANSI escape codes to be printed on the console.
    static net.minecraft.util.FormattedCharSequence
    subSequence(net.minecraft.util.FormattedCharSequence text, int start)
    Gets a sub-sequence from the given FormattedCharSequence.
    static net.minecraft.util.FormattedCharSequence
    subSequence(net.minecraft.util.FormattedCharSequence text, int start, int end)
    Gets a sub-sequence from the given FormattedCharSequence.
    static net.minecraft.network.chat.Component
    Turns a JsonElement to a Component with syntax highlighting that can be used for display.
    static net.minecraft.network.chat.Component
    withCopyAction(net.minecraft.network.chat.Component component, String copyText)
    Adds a click event to the given component to copy the given text to clipboard.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ComponentUtil

      public ComponentUtil()
  • Method Details

    • getConsoleString

      public static String getConsoleString(net.minecraft.network.chat.Component tc)
      Gets a text component as a string formatted with ANSI escape codes to be printed on the console.
    • toPrettyComponent

      public static net.minecraft.network.chat.Component toPrettyComponent(JsonElement json)
      Turns a JsonElement to a Component with syntax highlighting that can be used for display.
    • withCopyAction

      public static net.minecraft.network.chat.Component withCopyAction(net.minecraft.network.chat.Component component, String copyText)
      Adds a click event to the given component to copy the given text to clipboard.
    • subSequence

      public static net.minecraft.util.FormattedCharSequence subSequence(net.minecraft.util.FormattedCharSequence text, int start)
      Gets a sub-sequence from the given FormattedCharSequence. The sub sequence will include all characters from start (inclusive) to the end of the sequence.
    • subSequence

      public static net.minecraft.util.FormattedCharSequence subSequence(net.minecraft.util.FormattedCharSequence text, int start, int end)
      Gets a sub-sequence from the given FormattedCharSequence. The sub sequence will include all characters between start (inclusive) and end (exclusive). start and end may not be negative but may be greater that the length of the sequence.