diff --git a/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java b/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java index d50cddf5..342c6db9 100644 --- a/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java +++ b/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java @@ -47,8 +47,7 @@ public void initialize(Map data, Map entry : soundRegistry.entrySet()) { diff --git a/src/main/java/club/sk1er/patcher/hooks/LanguageHook.java b/src/main/java/club/sk1er/patcher/hooks/LanguageHook.java index 775d6d61..254a1153 100644 --- a/src/main/java/club/sk1er/patcher/hooks/LanguageHook.java +++ b/src/main/java/club/sk1er/patcher/hooks/LanguageHook.java @@ -1,14 +1,16 @@ package club.sk1er.patcher.hooks; +import club.sk1er.patcher.Patcher; import com.google.common.collect.Lists; import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.resources.LanguageManager; +import java.lang.reflect.Method; import java.util.List; public class LanguageHook { private static boolean loadLanguage = false; private static List languageManager = null; + private static Method langMethod; public static boolean shouldLoadLanguage() { return loadLanguage; @@ -25,4 +27,27 @@ public static void setLanguageManager(IResourceManagerReloadListener languageMan public static void setLoadLanguage(boolean loadLanguage) { LanguageHook.loadLanguage = loadLanguage; } + + public static void reloadOptiFineLanguage() { + if (langMethod == null) { + try { + Class clazz = Class.forName("net.optifine.Lang"); + langMethod = clazz.getDeclaredMethod("resourcesReloaded"); + } catch (ClassNotFoundException ignored) { + return; + } catch (Exception e) { + if (Patcher.instance != null) { + Patcher.instance.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); + } + return; + } + } + try { + langMethod.invoke(null); + } catch (Exception e) { + if (Patcher.instance != null) { + Patcher.instance.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); + } + } + } } diff --git a/src/main/java/club/sk1er/patcher/mixins/performance/SimpleReloadableResourceManager_RefreshLanguage.java b/src/main/java/club/sk1er/patcher/mixins/performance/SimpleReloadableResourceManager_RefreshLanguage.java index 531af2b4..dd175ad2 100644 --- a/src/main/java/club/sk1er/patcher/mixins/performance/SimpleReloadableResourceManager_RefreshLanguage.java +++ b/src/main/java/club/sk1er/patcher/mixins/performance/SimpleReloadableResourceManager_RefreshLanguage.java @@ -36,4 +36,11 @@ private List redirectNotifyReloadListeners(Simpl return reloadListeners; } } + + @Inject(method = "notifyReloadListeners", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/ProgressManager;pop(Lnet/minecraftforge/fml/common/ProgressManager$ProgressBar;)V")) + private void callOptiFineLanguage(CallbackInfo ci) { + if (LanguageHook.shouldLoadLanguage()) { + LanguageHook.reloadOptiFineLanguage(); + } + } } diff --git a/src/main/java/club/sk1er/patcher/screen/PatcherMenuEditor.java b/src/main/java/club/sk1er/patcher/screen/PatcherMenuEditor.java index f39c572b..6dc2bca2 100644 --- a/src/main/java/club/sk1er/patcher/screen/PatcherMenuEditor.java +++ b/src/main/java/club/sk1er/patcher/screen/PatcherMenuEditor.java @@ -203,7 +203,6 @@ public void keyboardInput(GuiScreenEvent.KeyboardInputEvent.Post event) { if (next > 9) { next = 0; tripped = !tripped; - Patcher.instance.getLogger().info("yep"); } } }