-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update some EditGameRulesScreen
and GameRules
mappings for accuracy and consistency
#488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fantastic once again!
the detailed descriptions are amazing to have, I hardly needed to skim the diff to review this :)
ARG 2 y | ||
ARG 3 x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these have been swapped as well. The method's parameters are indeed GuiGraphics graphics, int y, int x
. I assume it's a mistake. But they are used within the method, which is how you can tell:
protected void drawMessage(GuiGraphics graphics, int y, int x) {
if (this.name.size() == 1) {
graphics.drawText(EditGameRulesScreen.this.client.textRenderer, (OrderedText)this.name.get(0), x, y + 5, 16777215, false);
} else if (this.name.size() >= 2) {
graphics.drawText(EditGameRulesScreen.this.client.textRenderer, (OrderedText)this.name.get(0), x, y, 16777215, false);
graphics.drawText(EditGameRulesScreen.this.client.textRenderer, (OrderedText)this.name.get(1), x, y + 10, 16777215, false);
}
}
See how the x
and y
are used in the drawText
calls. The y
is shifted based on whether there is one or two lines of text.
METHOD m_evugyeiw (Ljava/util/Map$Entry;)V | ||
ARG 1 entry | ||
ARG 1 categoryMapEntry | ||
METHOD m_ffjznduo (Ljava/util/Map$Entry;)V | ||
ARG 1 entry | ||
ARG 1 gameRuleMapEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lambda function:
map.entrySet()
.stream()
.sorted(Map.Entry.comparingByKey())
.forEach(categoryMapEntry -> {
this.addEntry(
EditGameRulesScreen.this.new CategoryEntry(
Text.translatable(((GameRules.Category) categoryMapEntry.getKey()).getTranslationKey()).formatted(Formatting.BOLD, Formatting.YELLOW)
)
);
((Map) categoryMapEntry.getValue())
.entrySet()
.stream()
.sorted(Map.Entry.comparingByKey(Comparator.comparing(GameRules.Key::getName)))
.forEach(gameRuleMapEntry -> this.addEntry((AbstractEntry) gameRuleMapEntry.getValue()));
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map
is of type Map<GameRules.Category, Map<GameRules.Key<?>, AbstractEntry>>
.
categoryMapEntry
is of type Map.Entry<GameRules.Category, Map<GameRules.Key<?>, AbstractEntry>>
.
gameRuleMapEntry
is of type Map.Entry<GameRules.Key<?>, AbstractEntry>
.
mappings/net/minecraft/client/gui/screen/world/EditGameRulesScreen.mapping
Show resolved
Hide resolved
@@ -145,7 +145,7 @@ CLASS net/minecraft/unmapped/C_xmldumst net/minecraft/world/GameRules | |||
ARG 1 key | |||
ARG 2 type | |||
CLASS C_bctfwntr Acceptor | |||
METHOD call call (Lnet/minecraft/unmapped/C_xmldumst$C_avotqrag;Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | |||
METHOD call accept (Lnet/minecraft/unmapped/C_xmldumst$C_avotqrag;Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All methods that call this are named accept
, and it is the only thing in the class called Acceptor
.
METHOD m_hsodkmym visitBoolean (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
COMMENT Visit a boolean rule. | ||
METHOD m_hsodkmym visitBooleanGameRule (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
COMMENT Visit a boolean game rule. | ||
COMMENT | ||
COMMENT <p>Note {@link #visit(GameRules.Key, GameRules.Type)} will be called before this method. | ||
ARG 1 key | ||
ARG 2 type | ||
METHOD m_mfrkzoox visit (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
METHOD m_mfrkzoox visitGameRule (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
ARG 1 key | ||
ARG 2 type | ||
METHOD m_vtezodau visitInt (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
COMMENT Visit an integer rule. | ||
METHOD m_vtezodau visitIntGameRule (Lnet/minecraft/unmapped/C_xmldumst$C_iuaedxxw;Lnet/minecraft/unmapped/C_xmldumst$C_mymgluou;)V | ||
COMMENT Visit an integer game rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was confusing that these are named visitInt
and visitBoolean
when they don't visit int
s or boolean
s but rather IntGameRule
s and BooleanGameRule
s.
I already fixed those javadocs. It needs to be rebuilt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking more deeply into the CI error, I can see there are still few (one...?) Javadoc reference errors, with an attempted reference to Visitor#visit
(renamed to Visitor#visitGameRule
) being the cause
Ah, sorry. I see now. It looked a lot like the javadoc I'd already fixed. |
Also, I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
🚨 Target branch is already set to 23w35a |
🚀 Target branch has been updated to 1.20.2-pre2 |
🚨 Please fix merge conflicts before this can be merged |
Oh boy I love me some merge conflicts /s |
This PR changes existing mappings in
EditGameRulesScreen
andGameRules
.EditGameRulesScreen
RuleListWidget
->GameRuleEntryListWidget
EntryListWidget
.Rule
changed toGameRule
for consistency: I found it confusing when reading code and seeing game rules variously referred to as rules or game rules.name
->message
GameRules.Key.getName()
, and the message shown in GUIs.message
chosen based on the name used in buttons.description
->tooltip
ruleName
->description
rule
->gameRule
AbstractRuleWidget
->AbstractEntry
Entry
is for consistency with other classes extendingEntryListWidget
.AbstractEntry
rather thanAbstractGameRuleEntry
because it is also used for categories.NamedRuleWidget
->GameRuleEntry
RuleCategoryWidget
->CategoryEntry
name
->title
GameRules
Rule
->AbstractGameRule
Category
category
,getCategory
->translationKey
,getTranslationKey