Class TextVisitFactory

java.lang.Object
net.minecraft.client.font.TextVisitFactory

@Environment(CLIENT)
public class TextVisitFactory
extends Object
A utility class for visiting the characters of strings, handling surrogate code points and formatting codes.
  • Field Details

    • VISIT_TERMINATED

      private static final Optional<Object> VISIT_TERMINATED
  • Constructor Details

    • TextVisitFactory

      public TextVisitFactory()
  • Method Details

    • visitRegularCharacter

      private static boolean visitRegularCharacter​(Style style, CharacterVisitor visitor, int index, char c)
    • visitForwards

      public static boolean visitForwards​(String text, Style style, CharacterVisitor visitor)
      Visits the code points of a string in forward (left to right) direction.
      Parameters:
      text - the string
      style - the style of the string
      visitor - the visitor of characters
      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
    • visitBackwards

      public static boolean visitBackwards​(String text, Style style, CharacterVisitor visitor)
      Visits the code points of a string in backward (right to left) direction.
      Parameters:
      text - the string
      style - the style of the string
      visitor - the visitor
      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
    • visitFormatted

      public static boolean visitFormatted​(String text, Style style, CharacterVisitor visitor)
      Visits the code points of a string, applying the formatting codes within.

      The visit is in forward direction.

      Parameters:
      text - the string visited
      style - the style of the string
      visitor - the visitor
      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
    • visitFormatted

      public static boolean visitFormatted​(String text, int startIndex, Style style, CharacterVisitor visitor)
      Visits the code points of a string, applying the formatting codes within.

      The visit is in forward direction.

      Parameters:
      text - the string visited
      startIndex - the starting index of the visit
      style - the style of the string
      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
    • visitFormatted

      public static boolean visitFormatted​(String text, int startIndex, Style startingStyle, Style resetStyle, CharacterVisitor visitor)
      Visits the code points of a string, applying the formatting codes within.

      The visit is in forward direction.

      Parameters:
      text - the string visited
      startIndex - the starting index of the visit
      startingStyle - the style of the string when the visit starts
      resetStyle - the style to reset to when a §r formatting code is encountered
      visitor - the visitor
      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
    • visitFormatted

      public static boolean visitFormatted​(StringVisitable text, Style style, CharacterVisitor visitor)
      Visits the code points for every literal string and the formatting codes supplied by the renderable.

      The visit is in forward direction.

      Returns:
      true if the full string was visited, or false indicating the visitor terminated half-way
      See Also:
      StringRenderable#visit(StringRenderable.StyledVisitor, Style)
    • validateSurrogates

      public static String validateSurrogates​(String text)
      Returns a new string that has all surrogate characters within validated from an original string.
      Parameters:
      text - the original string
    • method_31402

      public static String method_31402​(StringVisitable stringVisitable)