aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <roman.graef@gmail.com>2023-10-30 21:46:01 +0100
committerGitHub <noreply@github.com>2023-10-30 21:46:01 +0100
commite1c24ecc30132fc98aa9cf33b928232b2efabcd8 (patch)
treea263e0da73ef91b610902f21dabdd51ffc9c9a31 /src
parentce153f0376d3fdb399cfd53c9b3dfaeeaf75dd42 (diff)
downloadNotEnoughUpdates-e1c24ecc30132fc98aa9cf33b928232b2efabcd8.tar.gz
NotEnoughUpdates-e1c24ecc30132fc98aa9cf33b928232b2efabcd8.tar.bz2
NotEnoughUpdates-e1c24ecc30132fc98aa9cf33b928232b2efabcd8.zip
Show hint for people who dont know that they need to turn on optifine (#905)
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/DynamicLightItemsEditor.kt38
1 files changed, 37 insertions, 1 deletions
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