From 4d4291725a28e6fbeaf8d5fb81927891d04acf34 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Mon, 2 May 2022 21:00:53 +0700 Subject: [PATCH] remove connected textures fix x2 --- .../cc/woverflow/crashpatch/CrashPatch.kt | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt b/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt index 786be5f..3854254 100644 --- a/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt +++ b/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt @@ -5,24 +5,16 @@ import cc.woverflow.crashpatch.crashes.DeobfuscatingRewritePolicy import cc.woverflow.crashpatch.hooks.ModsCheckerPlugin import cc.woverflow.onecore.utils.Updater import cc.woverflow.onecore.utils.command -import cc.woverflow.onecore.utils.sendBrandedNotification import gg.essential.api.EssentialAPI import gg.essential.api.utils.Multithreading import gg.essential.universal.ChatColor import gg.essential.universal.UDesktop -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiMainMenu -import net.minecraft.client.settings.GameSettings import net.minecraft.launchwrapper.Launch -import net.minecraftforge.client.event.GuiScreenEvent -import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.apache.logging.log4j.LogManager import java.io.File -import java.lang.reflect.Field @Mod(modid = CrashPatch.MODID, version = CrashPatch.VERSION, name = CrashPatch.NAME, modLanguageAdapter = "gg.essential.api.utils.KotlinAdapter") @@ -40,7 +32,6 @@ object CrashPatch { Launch.minecraftHome } } - var stopChecking = false @Mod.EventHandler fun onPreInit(e: FMLPreInitializationEvent) { @@ -65,55 +56,6 @@ object CrashPatch { } } } - MinecraftForge.EVENT_BUS.register(this) - } - - @SubscribeEvent - fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent.Post) { - if (!stopChecking && event.gui !is GuiMainMenu) { - stopChecking = true - try { - val settingsClass: Class = Minecraft.getMinecraft().gameSettings.javaClass - val field = settingsClass.getFieldAndSetAccessible("ofConnectedTextures") - field?.let { property -> - try { - property.getInt(Minecraft.getMinecraft().gameSettings).let { - if (it == 0 || it == 3) { - sendBrandedNotification("CrashPatch", "CrashPatch fixes the Connected Textures crash on Forge.\n\nClick here to enable Connected Textures!", duration = 10f, action = { - var reload = true - try { - property.setInt(Minecraft.getMinecraft().gameSettings, 2) - } catch (e: Exception) { - e.printStackTrace() - reload = false - } - if (reload) { - Minecraft.getMinecraft().gameSettings.saveOptions() - Minecraft.getMinecraft().gameSettings.loadOptions() - Minecraft.getMinecraft().refreshResources() - } - }) - } - } - } catch (e: Exception) { - e.printStackTrace() - } - } - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - private fun Class<*>.getFieldAndSetAccessible(name: String): Field? { - return try { - val field = this.getDeclaredField(name) - field.isAccessible = true - field - } catch (e: Exception) { - e.printStackTrace() - null - } } } val logger = LogManager.getLogger(CrashPatch) \ No newline at end of file