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

fix #31 in resource-loader #32

Merged
merged 2 commits into from
Jul 5, 2024
Merged

fix #31 in resource-loader #32

merged 2 commits into from
Jul 5, 2024

Conversation

crazysmc
Copy link
Contributor

@crazysmc crazysmc commented Jul 4, 2024

Instead of wrapping the load call, the alternate lang formats are injected before the argument calling getResources is evaluated. Any exception thrown from this argument evaluation will no longer prevent loading of the alternate files.

This changes the evaluation order of the variants but users of these different file name options (lang/en_US.lang, lang/en_US.json, lang/en_us.lang, lang/en_us.json) should not expect a specific ordering anyway.

@crazysmc
Copy link
Contributor Author

crazysmc commented Jul 4, 2024

Oh btw do we even need the toLowerCase variants after Minecraft 1.11? I think all language codes are lowercase since.

@Shadow
protected abstract void load(List<?> resources);

@Inject(
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that this changes more than is needed, as you could keep the previous implementation and wrap the original.call(...)s in try-catch blocks with the same effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that too at first but WrapOperation evaluates the arguments of the function call in order to capture them, and trying to evaluate the list argument throws an exception, so the mixin is not called at all after that.

Copy link
Member

Choose a reason for hiding this comment

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

aaaahhh gotcha, alright then, this change looks good

@SpaceWalkerRS
Copy link
Member

Oh btw do we even need the toLowerCase variants after Minecraft 1.11? I think all language codes are lowercase since.

I suppose not. Ideally we'd allow uppercase language codes in those versions. Something for later.


@Final
@Shadow
private Map<String, String> translations;

@WrapOperation(
@Shadow
protected abstract void load(List<?> resources);
Copy link
Member

Choose a reason for hiding this comment

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

nit: please parameterize this properly (should be List<Resources>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh true yeah

@SpaceWalkerRS SpaceWalkerRS merged commit c6e158c into OrnitheMC:main Jul 5, 2024
1 check passed
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