From 80cd54c7a94323d62876cf681ae9aee4d1569f0d Mon Sep 17 00:00:00 2001 From: liach <7806504+liach@users.noreply.github.com> Date: Mon, 8 Jun 2020 12:24:56 -0500 Subject: [PATCH] String renderable (or visitable?) (#1431) * String visitable Signed-off-by: liach * Fix leftover jd errors Signed-off-by: liach * visitable -> renderable, some language stuff Signed-off-by: liach Co-authored-by: liach --- mappings/net/minecraft/class_5348.mapping | 27 ------- .../minecraft/client/font/TextHandler.mapping | 11 +++ .../client/font/TextRenderer.mapping | 16 +++++ .../client/font/TextVisitFactory.mapping | 8 +-- .../language/LanguageDefinition.mapping | 1 + .../language/TranslationStorage.mapping | 9 +++ .../minecraft/text/StringRenderable.mapping | 72 +++++++++++++++++++ .../minecraft/text/TranslatableText.mapping | 2 + mappings/net/minecraft/util/Language.mapping | 14 +++- 9 files changed, 128 insertions(+), 32 deletions(-) delete mode 100644 mappings/net/minecraft/class_5348.mapping create mode 100644 mappings/net/minecraft/text/StringRenderable.mapping diff --git a/mappings/net/minecraft/class_5348.mapping b/mappings/net/minecraft/class_5348.mapping deleted file mode 100644 index c3e472e384..0000000000 --- a/mappings/net/minecraft/class_5348.mapping +++ /dev/null @@ -1,27 +0,0 @@ -CLASS net/minecraft/class_5348 - METHOD method_27657 visit (Lnet/minecraft/class_5348$class_5245;)Ljava/util/Optional; - METHOD method_27658 visit (Lnet/minecraft/class_5348$class_5246;Lnet/minecraft/class_2583;)Ljava/util/Optional; - CLASS class_5245 Visitor - COMMENT A visitor for text content. - METHOD accept (Ljava/lang/String;)Ljava/util/Optional; - COMMENT Visits a text's {@link Text#asString() asString result}. - COMMENT - COMMENT

When a {@link Optional#isPresent() present optional} is returned, - COMMENT the visit is terminated before visiting all text. Can return {@link - COMMENT Text#TERMINATE_VISIT} for convenience.

- ARG 1 asString - CLASS class_5246 StyledVisitor - COMMENT A visitor for text content and a contextual {@link Style}. - METHOD accept (Lnet/minecraft/class_2583;Ljava/lang/String;)Ljava/util/Optional; - COMMENT Visits a text's contextual style and {@link Text#asString() asString - COMMENT result}. - COMMENT - COMMENT

A contextual style is obtained by calling {@link Style#withParent(Style)} - COMMENT on the current's text style, passing the previous contextual style or - COMMENT the starting style if it is the beginning of a visit.

- COMMENT - COMMENT

When a {@link Optional#isPresent() present optional} is returned, - COMMENT the visit is terminated before visiting all text. Can return {@link - COMMENT Text#TERMINATE_VISIT} for convenience.

- ARG 1 style - ARG 2 asString diff --git a/mappings/net/minecraft/client/font/TextHandler.mapping b/mappings/net/minecraft/client/font/TextHandler.mapping index 90552ae6c5..b15a00d2af 100644 --- a/mappings/net/minecraft/client/font/TextHandler.mapping +++ b/mappings/net/minecraft/client/font/TextHandler.mapping @@ -27,13 +27,16 @@ CLASS net/minecraft/class_5225 net/minecraft/client/font/TextHandler ARG 5 consumer METHOD method_27488 getWidth (Lnet/minecraft/class_5348;)F COMMENT Returns the width of a text. + ARG 1 text METHOD method_27489 trimToWidth (Lnet/minecraft/class_5348;I)Lnet/minecraft/class_2583; COMMENT Trim a text to be at most {@code maxWidth} wide. COMMENT COMMENT @return the trimmed text + ARG 1 text ARG 2 maxWidth COMMENT the max width of the trimmed text METHOD method_27490 trimToWidth (Lnet/minecraft/class_5348;ILnet/minecraft/class_2583;)Lnet/minecraft/class_5348; + ARG 1 text ARG 2 width ARG 3 style METHOD method_27494 trimToWidth (Ljava/lang/String;ILnet/minecraft/class_2583;)Ljava/lang/String; @@ -47,7 +50,9 @@ CLASS net/minecraft/class_5225 net/minecraft/client/font/TextHandler ARG 3 style COMMENT the style of the trimmed string METHOD method_27495 wrapLines (Lnet/minecraft/class_5348;ILnet/minecraft/class_2583;)Ljava/util/List; + ARG 1 text ARG 2 maxWidth + ARG 3 style METHOD method_27497 trimToWidthBackwards (Ljava/lang/String;ILnet/minecraft/class_2583;)Ljava/lang/String; COMMENT Trim a string from right to left to be at most {@code maxWidth} wide. COMMENT @@ -121,3 +126,9 @@ CLASS net/minecraft/class_5225 net/minecraft/client/font/TextHandler COMMENT the character's code point ARG 2 style COMMENT the style of the character, carrying font and formatting information + CLASS class_5345 StyledString + FIELD field_25261 literal Ljava/lang/String; + FIELD field_25262 style Lnet/minecraft/class_2583; + METHOD (Ljava/lang/String;Lnet/minecraft/class_2583;)V + ARG 1 literal + ARG 2 style diff --git a/mappings/net/minecraft/client/font/TextRenderer.mapping b/mappings/net/minecraft/client/font/TextRenderer.mapping index e4cbae389d..3cab65b6cd 100644 --- a/mappings/net/minecraft/client/font/TextRenderer.mapping +++ b/mappings/net/minecraft/client/font/TextRenderer.mapping @@ -21,6 +21,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 12 alpha ARG 13 light METHOD method_1712 drawTrimmed (Lnet/minecraft/class_5348;IIII)V + ARG 1 text ARG 2 x ARG 3 y ARG 4 maxWidth @@ -29,6 +30,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 1 text ARG 2 maxWidth METHOD method_1714 trimToWidth (Lnet/minecraft/class_5348;I)Lnet/minecraft/class_5348; + ARG 1 text ARG 2 width METHOD method_1720 drawWithShadow (Lnet/minecraft/class_4587;Ljava/lang/String;FFI)I ARG 1 matrices @@ -39,6 +41,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer METHOD method_1721 mirror (Ljava/lang/String;)Ljava/lang/String; ARG 1 text METHOD method_1723 drawInternal (Lnet/minecraft/class_5348;FFIZLnet/minecraft/class_1159;Lnet/minecraft/class_4597;ZII)I + ARG 1 text ARG 2 x ARG 3 y ARG 4 color @@ -63,6 +66,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer METHOD method_1727 getWidth (Ljava/lang/String;)I ARG 1 text METHOD method_1728 wrapLines (Lnet/minecraft/class_5348;I)Ljava/util/List; + ARG 1 text ARG 2 width METHOD method_1729 draw (Lnet/minecraft/class_4587;Ljava/lang/String;FFI)I ARG 1 matrices @@ -71,12 +75,14 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 4 y ARG 5 color METHOD method_22941 draw (Lnet/minecraft/class_5348;FFILnet/minecraft/class_1159;Z)I + ARG 1 text ARG 2 x ARG 3 y ARG 4 color ARG 5 matrix ARG 6 shadow METHOD method_22942 draw (Lnet/minecraft/class_5348;FFIZLnet/minecraft/class_1159;Lnet/minecraft/class_4597;ZII)I + ARG 1 text ARG 2 x ARG 3 y ARG 4 color @@ -90,6 +96,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 0 argb METHOD method_27517 drawWithShadow (Lnet/minecraft/class_4587;Lnet/minecraft/class_5348;FFI)I ARG 1 matrices + ARG 2 text ARG 3 x ARG 4 y ARG 5 color @@ -137,6 +144,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer METHOD method_27527 getTextHandler ()Lnet/minecraft/class_5225; METHOD method_27528 draw (Lnet/minecraft/class_4587;Lnet/minecraft/class_5348;FFI)I ARG 1 matrices + ARG 2 text ARG 3 x ARG 4 y ARG 5 color @@ -153,6 +161,7 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 10 light ARG 11 mirror METHOD method_27530 drawLayer (Lnet/minecraft/class_5348;FFIZLnet/minecraft/class_1159;Lnet/minecraft/class_4597;ZII)F + ARG 1 text ARG 2 x ARG 3 y ARG 4 color @@ -162,6 +171,13 @@ CLASS net/minecraft/class_327 net/minecraft/client/font/TextRenderer ARG 8 seeThrough ARG 9 underlineColor ARG 10 light + METHOD method_29342 drawWithShadow (Lnet/minecraft/class_4587;Ljava/lang/String;FFIZ)I + ARG 1 matrices + ARG 2 text + ARG 3 x + ARG 4 y + ARG 5 color + ARG 6 rightToLeft CLASS class_5232 ShadowDrawer FIELD field_24239 vertexConsumers Lnet/minecraft/class_4597; FIELD field_24241 shadow Z diff --git a/mappings/net/minecraft/client/font/TextVisitFactory.mapping b/mappings/net/minecraft/client/font/TextVisitFactory.mapping index 8e4bab420c..98cec0cb70 100644 --- a/mappings/net/minecraft/client/font/TextVisitFactory.mapping +++ b/mappings/net/minecraft/client/font/TextVisitFactory.mapping @@ -50,15 +50,15 @@ CLASS net/minecraft/class_5223 net/minecraft/client/font/TextVisitFactory ARG 2 visitor COMMENT the visitor of characters METHOD method_27476 visitFormatted (Lnet/minecraft/class_5348;Lnet/minecraft/class_2583;Lnet/minecraft/class_5223$class_5224;)Z - COMMENT Visits the code points for every {@link Text#asString() partial string} - COMMENT of the texts in {@code text} and its siblings, applying the formatting - COMMENT codes within. + COMMENT Visits the code points for every literal string and the formatting codes + COMMENT supplied by the renderable. COMMENT COMMENT

The visit is in forward direction.

COMMENT COMMENT @return {@code true} if the full string was visited, or {@code false} indicating COMMENT the {@code visitor} terminated half-way - COMMENT @see Text#visit(Text.StyledVisitor, Style) + COMMENT @see StringRenderable#visit(StringRenderable.StyledVisitor, Style) + ARG 0 text ARG 1 style ARG 2 visitor METHOD method_27477 visitRegularCharacter (Lnet/minecraft/class_2583;Lnet/minecraft/class_5223$class_5224;IC)Z diff --git a/mappings/net/minecraft/client/resource/language/LanguageDefinition.mapping b/mappings/net/minecraft/client/resource/language/LanguageDefinition.mapping index 4b0859e2ea..9b8dd7415f 100644 --- a/mappings/net/minecraft/client/resource/language/LanguageDefinition.mapping +++ b/mappings/net/minecraft/client/resource/language/LanguageDefinition.mapping @@ -7,6 +7,7 @@ CLASS net/minecraft/class_1077 net/minecraft/client/resource/language/LanguageDe ARG 1 code ARG 2 name ARG 3 region + ARG 4 rightToLeft METHOD equals (Ljava/lang/Object;)Z ARG 1 o METHOD method_4672 isRightToLeft ()Z diff --git a/mappings/net/minecraft/client/resource/language/TranslationStorage.mapping b/mappings/net/minecraft/client/resource/language/TranslationStorage.mapping index 61863e6031..7b931ae610 100644 --- a/mappings/net/minecraft/client/resource/language/TranslationStorage.mapping +++ b/mappings/net/minecraft/client/resource/language/TranslationStorage.mapping @@ -1,5 +1,14 @@ CLASS net/minecraft/class_1078 net/minecraft/client/resource/language/TranslationStorage + FIELD field_25289 rightToLeft Z FIELD field_5330 translations Ljava/util/Map; FIELD field_5332 LOGGER Lorg/apache/logging/log4j/Logger; + METHOD (Ljava/util/Map;Z)V + ARG 1 translations + ARG 2 rightToLeft + METHOD method_29390 reorder (Ljava/lang/String;)Ljava/lang/String; METHOD method_4675 load (Lnet/minecraft/class_3300;Ljava/util/List;)Lnet/minecraft/class_1078; + ARG 0 resourceManager + ARG 1 definitions METHOD method_4676 load (Ljava/util/List;Ljava/util/Map;)V + ARG 0 resources + ARG 1 translationMap diff --git a/mappings/net/minecraft/text/StringRenderable.mapping b/mappings/net/minecraft/text/StringRenderable.mapping new file mode 100644 index 0000000000..010b7823c7 --- /dev/null +++ b/mappings/net/minecraft/text/StringRenderable.mapping @@ -0,0 +1,72 @@ +CLASS net/minecraft/class_5348 net/minecraft/text/StringRenderable + COMMENT An object that can supply strings to a visitor, with or without a style + COMMENT context, for rendering the strings. + FIELD field_25309 TERMINATE_VISIT Ljava/util/Optional; + COMMENT Convenience object indicating the termination of a string visit. + FIELD field_25310 EMPTY Lnet/minecraft/class_5348; + COMMENT An empty renderable that does not call the visitors. + METHOD method_27657 visit (Lnet/minecraft/class_5348$class_5245;)Ljava/util/Optional; + COMMENT Supplies this renderable's literal content to the visitor. + COMMENT + COMMENT @return {@code Optional.empty()} if the visit finished, or a terminating + COMMENT result from the {@code visitor} + ARG 1 visitor + COMMENT the visitor + METHOD method_27658 visit (Lnet/minecraft/class_5348$class_5246;Lnet/minecraft/class_2583;)Ljava/util/Optional; + COMMENT Supplies this renderable's literal content and contextual style to + COMMENT the visitor. + COMMENT + COMMENT @return {@code Optional.empty()} if the visit finished, or a terminating + COMMENT result from the {@code visitor} + ARG 1 styledVisitor + COMMENT the visitor + ARG 2 style + COMMENT the contextual style + METHOD method_29430 plain (Ljava/lang/String;)Lnet/minecraft/class_5348; + COMMENT Creates a renderable from a plain string. + ARG 0 string + COMMENT the plain string + METHOD method_29431 styled (Ljava/lang/String;Lnet/minecraft/class_2583;)Lnet/minecraft/class_5348; + COMMENT Creates a visitable from a plain string and a root style. + ARG 0 string + COMMENT the plain string + ARG 1 style + COMMENT the root style + METHOD method_29432 concat (Ljava/util/List;)Lnet/minecraft/class_5348; + COMMENT Concats multiple string renderables by the order they appear in the list. + ARG 0 visitables + COMMENT a list of visitables + METHOD method_29433 concat ([Lnet/minecraft/class_5348;)Lnet/minecraft/class_5348; + COMMENT Concats multiple string renderables by the order they appear in the array. + ARG 0 visitables + COMMENT an array or varargs of visitables + CLASS class_5245 Visitor + COMMENT A visitor for rendered string content. + METHOD accept (Ljava/lang/String;)Ljava/util/Optional; + COMMENT Visits a literal string. + COMMENT + COMMENT

When a {@link Optional#isPresent() present optional} is returned, + COMMENT the visit is terminated before visiting all text. Can return {@link + COMMENT StringRenderable#TERMINATE_VISIT} for convenience.

+ COMMENT + COMMENT @return {@code Optional.empty()} to continue, a non-empty result to terminate + ARG 1 asString + COMMENT the literal string + CLASS class_5246 StyledVisitor + COMMENT A visitor for rendered string content and a contextual {@link Style}. + METHOD accept (Lnet/minecraft/class_2583;Ljava/lang/String;)Ljava/util/Optional; + COMMENT Visits a string's content with a contextual style. + COMMENT + COMMENT

A contextual style is obtained by calling {@link Style#withParent(Style)} + COMMENT on the current's text style, passing the previous contextual style or + COMMENT the starting style if it is the beginning of a visit.

+ COMMENT + COMMENT

When a {@link Optional#isPresent() present optional} is returned, + COMMENT the visit is terminated before visiting all text. Can return {@link + COMMENT StringRenderable#TERMINATE_VISIT} for convenience.

+ COMMENT + COMMENT @return {@code Optional.empty()} to continue, a non-empty result to terminate + ARG 1 style + COMMENT the current style + ARG 2 asString + COMMENT the literal string diff --git a/mappings/net/minecraft/text/TranslatableText.mapping b/mappings/net/minecraft/text/TranslatableText.mapping index 0d8a16ae89..74b543a283 100644 --- a/mappings/net/minecraft/text/TranslatableText.mapping +++ b/mappings/net/minecraft/text/TranslatableText.mapping @@ -6,6 +6,7 @@ CLASS net/minecraft/class_2588 net/minecraft/text/TranslatableText FIELD field_24367 EMPTY_ARGUMENTS [Ljava/lang/Object; FIELD field_24368 LITERAL_PERCENT_SIGN Lnet/minecraft/class_5348; FIELD field_24369 NULL_ARGUMENT Lnet/minecraft/class_5348; + FIELD field_25317 languageCache Lnet/minecraft/class_2477; METHOD (Ljava/lang/String;)V ARG 1 key METHOD (Ljava/lang/String;[Ljava/lang/Object;)V @@ -15,4 +16,5 @@ CLASS net/minecraft/class_2588 net/minecraft/text/TranslatableText METHOD method_11023 getArgs ()[Ljava/lang/Object; METHOD method_11024 setTranslation (Ljava/lang/String;Lnet/minecraft/class_2477;)V ARG 1 translation + ARG 2 language METHOD method_11025 updateTranslations ()V diff --git a/mappings/net/minecraft/util/Language.mapping b/mappings/net/minecraft/util/Language.mapping index 8ca5b9829d..41f6b5d05a 100644 --- a/mappings/net/minecraft/util/Language.mapping +++ b/mappings/net/minecraft/util/Language.mapping @@ -1,8 +1,20 @@ CLASS net/minecraft/class_2477 net/minecraft/util/Language - FIELD field_11486 INSTANCE Lnet/minecraft/class_2477; + FIELD field_11486 instance Lnet/minecraft/class_2477; FIELD field_11489 TOKEN_PATTERN Ljava/util/regex/Pattern; FIELD field_11490 LOGGER Lorg/apache/logging/log4j/Logger; + FIELD field_25307 GSON Lcom/google/gson/Gson; METHOD method_10517 getInstance ()Lnet/minecraft/class_2477; + METHOD method_29425 load (Ljava/io/InputStream;Ljava/util/function/BiConsumer;)V + ARG 0 inputStream + ARG 1 entryConsumer + METHOD method_29426 reorder (Ljava/lang/String;Z)Ljava/lang/String; + ARG 1 string + ARG 2 allowTokens + METHOD method_29427 setInstance (Lnet/minecraft/class_2477;)V + ARG 0 language + METHOD method_29428 isRightToLeft ()Z + METHOD method_29429 create ()Lnet/minecraft/class_2477; METHOD method_4678 hasTranslation (Ljava/lang/String;)Z ARG 1 key METHOD method_4679 get (Ljava/lang/String;)Ljava/lang/String; + ARG 1 key