diff --git a/gradle.properties b/gradle.properties index 982702e..60090c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 loader_version=0.16.7 -fabric_version=0.106.0+1.21.1 +fabric_version=0.107.0+1.21.3 # Mod Properties -mod_version=1.7+1.21.1 +mod_version=1.7+1.21.3 maven_group=jerozgen archives_base_name=language-reload # Dependencies # https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu -modmenu_version=11.0.3 +# https://modrinth.com/mod/modmenu/versions +modmenu_version=12.0.0-beta.1 diff --git a/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java b/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java index 24c0ae6..65a2f7e 100644 --- a/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/KeyboardMixin.java @@ -78,20 +78,16 @@ private void onProcessF3(int key, CallbackInfoReturnable cir) { } } - @Inject(method = "onKey", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/gui/screen/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V"), - cancellable = true) + @Inject(method = "onKey", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Keyboard;debugCrashStartTime:J", ordinal = 0), cancellable = true) private void onOnKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { - if (InputUtil.isKeyPressed(window, GLFW.GLFW_KEY_F3) && key == GLFW.GLFW_KEY_J) { + if (client.currentScreen != null && InputUtil.isKeyPressed(window, GLFW.GLFW_KEY_F3) && key == GLFW.GLFW_KEY_J) { if (action != 0) processLanguageReloadKeys(); ci.cancel(); } } - @Inject(method = "onChar", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/gui/screen/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V", - ordinal = 0), cancellable = true) + @Inject(method = "onChar", at = @At("HEAD"), cancellable = true) private void onOnChar(long window, int codePoint, int modifiers, CallbackInfo ci) { if (InputUtil.isKeyPressed(window, GLFW.GLFW_KEY_F3) && InputUtil.isKeyPressed(window, GLFW.GLFW_KEY_J)) { ci.cancel(); diff --git a/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java b/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java index 01f620b..9de1975 100644 --- a/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/LanguageOptionsScreenMixin.java @@ -83,9 +83,9 @@ public void setFocused(boolean focused) { header.add(searchBox); } - @Inject(method = "initTabNavigation", at = @At("HEAD"), cancellable = true) - protected void onInitTabNavigation(CallbackInfo ci) { - super.initTabNavigation(); + @Inject(method = "refreshWidgetPositions", at = @At("HEAD"), cancellable = true) + protected void onRefreshWidgetPositions(CallbackInfo ci) { + super.refreshWidgetPositions(); var listWidth = Math.min(width / 2 - 4, 200); availableLanguageList.position(listWidth, layout); diff --git a/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java b/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java index 6a0ceac..d20c569 100644 --- a/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/TranslationStorageMixin.java @@ -1,10 +1,13 @@ package jerozgen.languagereload.mixin; import com.google.common.collect.Maps; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import jerozgen.languagereload.access.ITranslationStorage; import jerozgen.languagereload.config.Config; import net.minecraft.client.resource.language.TranslationStorage; import net.minecraft.resource.ResourceManager; +import net.minecraft.util.DeprecatedLanguageData; import net.minecraft.util.Language; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -32,6 +35,15 @@ void onConstructed(Map translations, boolean rightToLeft, Callba separateTranslationsOnLoad = null; } + @WrapOperation(method = "load(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Z)Lnet/minecraft/client/resource/language/TranslationStorage;", + at = @At(value = "INVOKE", target = "Lnet/minecraft/util/DeprecatedLanguageData;apply(Ljava/util/Map;)V")) + private static void onLoad$applyDeprecatedLanguageData(DeprecatedLanguageData data, Map translations, Operation applier) { + applier.call(data, translations); + for (Map map : separateTranslationsOnLoad.values()) { + applier.call(data, map); + } + } + @Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Z)Lnet/minecraft/client/resource/language/TranslationStorage;", at = @At("HEAD")) private static void onLoad(ResourceManager resourceManager, List definitions, boolean rightToLeft, CallbackInfoReturnable cir) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e72e587..45d92eb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -47,7 +47,7 @@ "depends": { "fabric-resource-loader-v0": "*", "fabricloader": ">=0.15.10", - "minecraft": ">=1.21" + "minecraft": ">=1.21.2" }, "suggests": { "modmenu": "*"