Package net.minecraft.client.font
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 Summary
Fields Modifier and Type Field Description private static Optional<Object>
VISIT_TERMINATED
-
Constructor Summary
Constructors Constructor Description TextVisitFactory()
-
Method Summary
Modifier and Type Method Description static String
method_31402(StringVisitable stringVisitable)
static String
validateSurrogates(String text)
Returns a new string that has all surrogate characters within validated from an original string.static boolean
visitBackwards(String text, Style style, CharacterVisitor visitor)
Visits the code points of a string in backward (right to left) direction.static boolean
visitFormatted(String text, int startIndex, Style style, CharacterVisitor visitor)
Visits the code points of a string, applying the formatting codes within.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.static boolean
visitFormatted(String text, Style style, CharacterVisitor visitor)
Visits the code points of a string, applying the formatting codes within.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.static boolean
visitForwards(String text, Style style, CharacterVisitor visitor)
Visits the code points of a string in forward (left to right) direction.private static boolean
visitRegularCharacter(Style style, CharacterVisitor visitor, int index, char c)
-
Field Details
-
VISIT_TERMINATED
-
-
Constructor Details
-
TextVisitFactory
public TextVisitFactory()
-
-
Method Details
-
visitRegularCharacter
private static boolean visitRegularCharacter(Style style, CharacterVisitor visitor, int index, char c) -
visitForwards
Visits the code points of a string in forward (left to right) direction.- Parameters:
text
- the stringstyle
- the style of the stringvisitor
- the visitor of characters- Returns:
true
if the full string was visited, orfalse
indicating thevisitor
terminated half-way
-
visitBackwards
Visits the code points of a string in backward (right to left) direction.- Parameters:
text
- the stringstyle
- the style of the stringvisitor
- the visitor- Returns:
true
if the full string was visited, orfalse
indicating thevisitor
terminated half-way
-
visitFormatted
Visits the code points of a string, applying the formatting codes within.The visit is in forward direction.
- Parameters:
text
- the string visitedstyle
- the style of the stringvisitor
- the visitor- Returns:
true
if the full string was visited, orfalse
indicating thevisitor
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 visitedstartIndex
- the starting index of the visitstyle
- the style of the string- Returns:
true
if the full string was visited, orfalse
indicating thevisitor
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 visitedstartIndex
- the starting index of the visitstartingStyle
- the style of the string when the visit startsresetStyle
- the style to reset to when a§r
formatting code is encounteredvisitor
- the visitor- Returns:
true
if the full string was visited, orfalse
indicating thevisitor
terminated half-way
-
visitFormatted
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, orfalse
indicating thevisitor
terminated half-way- See Also:
StringRenderable#visit(StringRenderable.StyledVisitor, Style)
-
validateSurrogates
Returns a new string that has all surrogate characters within validated from an original string.- Parameters:
text
- the original string
-
method_31402
-