From e1c24ecc30132fc98aa9cf33b928232b2efabcd8 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 30 Oct 2023 21:46:01 +0100 Subject: Show hint for people who dont know that they need to turn on optifine (#905) --- .../miscgui/DynamicLightItemsEditor.kt | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/DynamicLightItemsEditor.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/DynamicLightItemsEditor.kt index 7cebadcb..6e6ec662 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/DynamicLightItemsEditor.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/DynamicLightItemsEditor.kt @@ -20,19 +20,29 @@ package io.github.moulberry.notenoughupdates.miscgui import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack import net.minecraft.util.ResourceLocation +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.registry.GameRegistry import org.lwjgl.opengl.GL11 import java.awt.Color +import java.io.File import kotlin.math.ceil class DynamicLightItemsEditor() : GuiScreen() { + val isOfLightsEnabled = run { + val ofDynamicLights = File("optionsof.txt").takeIf { it.exists() }?.readLines() + ?.find { it.startsWith("ofDynamicLights:") } + ofDynamicLights != null && !ofDynamicLights.endsWith(":3") + } + val background = ResourceLocation("notenoughupdates:dynamic_light_items_editor.png") val enabledButton = ResourceLocation("notenoughupdates:enabled_button.png") val disabledButton = ResourceLocation("notenoughupdates:disabled_button.png") @@ -98,6 +108,12 @@ class DynamicLightItemsEditor() : GuiScreen() { fontRendererObj.drawString("the discord for help", guiLeft + 52, guiTop + 42, Color.RED.rgb) return } + if (!isOfLightsEnabled) { + fontRendererObj.drawString("Dynamic lights have", guiLeft + 50, guiTop + 22, Color.RED.rgb) + fontRendererObj.drawString("been disabled in OptiFine.", guiLeft + 50, guiTop + 32, Color.RED.rgb) + fontRendererObj.drawString("Enable in Video Settings.", guiLeft + 52, guiTop + 42, Color.RED.rgb) + return + } // Buttons GlStateManager.color(1f, 1f, 1f, 1f) @@ -204,7 +220,26 @@ class DynamicLightItemsEditor() : GuiScreen() { super.mouseClicked(mouseX, mouseY, mouseButton) } + @NEUAutoSubscribe companion object { + var hasAttemptedToLoadOptifine = false + + @SubscribeEvent + fun autoloadOptifine(event: TickEvent) { + if (Minecraft.getMinecraft().thePlayer == null || hasAttemptedToLoadOptifine) return + try { + Class.forName("net.optifine.DynamicLights") + println("Loaded dynamic lights successfully.") + } catch (e: Exception) { + e.printStackTrace() + } + hasAttemptedToLoadOptifine = true + if (!didApplyMixin) { + println("Loaded optifine dynamic lights class without applying mixin!") + } + } + + @JvmStatic var didApplyMixin = false @@ -228,7 +263,8 @@ class DynamicLightItemsEditor() : GuiScreen() { @JvmStatic fun resolveInternalName(itemStack: ItemStack): String? { var internalName = - NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(itemStack).resolveInternalName() + NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(itemStack) + .resolveInternalName() if (internalName == null) { // If resolving internal name failed, the item may be a minecraft item internalName = itemStack.item.registryName -- cgit