Incompatible mixin for `LanguageOptionsScreen#keyPressed`
Antikyth opened this issue ยท 1 comments
I am not a user of Language Reload, but I was alerted to this problem by this issue on my own mod's repo. Language Reload has a number of overrides for methods in that mixin instead of actually doing some kind of compatible injection.
It seems that in the case of LanguageOptionsScreen#keyPressed
, both our mods - mine being Searchable - mix into keyPressed
with the same purpose: to allow our search boxes to be typed in, due to a mistake in vanilla where they seem to have accidentally overridden keyPressed
in LanguageOptionsScreen
instead of LanguageListWidget
.
I opted to solve this by using Mixin Extras' ModifyExpressionValue
(Mixin Extras can be bundled with this mod without adding more dependencies for users) to add a check that the language list is selected to the method call named CommonInputs.isToggle(keyCode)
in Quilt Mappings in a way that is compatible with other mods adding the same or other conditions. I think that is probably a reasonable solution for your mod too.
This is the mixin Searchable uses if you wanted to use it for reference:
// Only select a language when a toggle key is pressed if the language selection list is focused.
@ModifyExpressionValue(method = "keyPressed", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/CommonInputs;isToggle(I)Z"
))
private boolean onlySelectLanguageIfFocused(boolean original) {
// Only if the language selection list is focused...
return original && this.languageSelectionList.equals(this.getFocused());
}