Skip to content
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 add method for StatType in TranslationBuilder #4143

Open
wants to merge 2 commits into
base: 1.21.1
Choose a base branch
from

Conversation

solonovamax
Copy link

Use either the translation key from the name or fallback to Util.createTranslationKey formatting for StatType in TranslationBuilder

@solonovamax solonovamax force-pushed the feat/update-translation-builder branch from 60c45c1 to a7ac31b Compare October 5, 2024 22:24
@solonovamax
Copy link
Author

I was originally just going to have the Util.createTranslationKey("stat_type", Registries.STAT_TYPE.getId(statType)) line, but I decided it might be a good idea to have semi-parity with add(RegistryKey<ItemGroup> registryKey, String value), so I also added the test for if the name is a TranslatableTextContent

@solonovamax
Copy link
Author

oopsies, checkstyle issues. I'll fix that in a bit.

@solonovamax
Copy link
Author

solonovamax commented Oct 9, 2024

Odd, it seems that when checking it out locally, the check task passes, but not when run in CI. edit: nvm I was on the default branch not my own branch 💀

but, the issue seems to be my use of spaces over tabs.

add("stat_type." + Registries.STAT_TYPE.getId(statType).toString().replace(':', '.'), value);
if (statType.getName() instanceof TranslatableTextContent translatableTextContent) {
add(translatableTextContent.getKey(), value);
} else { // fallback to Util.createTranslationKey formatting (should it error instead?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error? not sure how the translation would be used if the name is not TTC.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just threw in a fallback because you never know, some person might try and have like some string literal concatenated with the translation. But I can always make it an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants