aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-20 00:56:40 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-20 00:56:40 +0100
commit8964cf9bd7647fd9216ce0c3e5af229dabfa5fb5 (patch)
treebf15062d5b293938cb9c25af0164589f67b8ca39 /src/main/java/at/hannibal2/skyhanni
parent86e9f31988715756c0fce31963a162b90ed0e2b6 (diff)
downloadskyhanni-8964cf9bd7647fd9216ce0c3e5af229dabfa5fb5.tar.gz
skyhanni-8964cf9bd7647fd9216ce0c3e5af229dabfa5fb5.tar.bz2
skyhanni-8964cf9bd7647fd9216ce0c3e5af229dabfa5fb5.zip
Fixed ender chest not reopening correctly after opening gui editor.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt21
2 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
index 2486c7eee..7477d74bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
@@ -19,9 +19,13 @@ import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.UUID
+import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.minutes
class GuiEditManager {
+
+ var lastHotkeyPressed = SimpleTimeMark.farPast()
+
@SubscribeEvent
fun onKeyClick(event: LorenzKeyPressEvent) {
if (!LorenzUtils.inSkyBlock) return
@@ -33,8 +37,11 @@ class GuiEditManager {
if (it is GuiEditSign && !it.isRancherSign()) return
}
+ if (lastHotkeyPressed.passedSince() < 500.milliseconds) return
if (NEUItems.neuHasFocus()) return
+ lastHotkeyPressed = SimpleTimeMark.now()
+ Minecraft.getMinecraft().thePlayer.closeScreen()
openGuiPositionEditor(hotkeyReminder = false)
}
@@ -71,8 +78,8 @@ class GuiEditManager {
lastHotkeyReminded = SimpleTimeMark.now()
LorenzUtils.chat(
"§eTo edit hidden GUI elements:\n" +
- " §7- §e1. Set a key in /sh edit.\n" +
- " §7- §e2. Click that key while the GUI element is visible."
+ " §7- §e1. Set a key in /sh edit.\n" +
+ " §7- §e2. Click that key while the GUI element is visible."
)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
index eb06c23ee..2a6b002af 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -1,14 +1,12 @@
package at.hannibal2.skyhanni.utils
-import at.hannibal2.skyhanni.config.ConfigManager
-import at.hannibal2.skyhanni.data.OtherMod
import at.hannibal2.skyhanni.test.command.ErrorManager
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
-import java.io.File
import kotlin.time.Duration.Companion.seconds
object InventoryUtils {
@@ -56,15 +54,14 @@ object InventoryUtils {
val isNeuStorageEnabled = RecalculatingValue(10.seconds) {
try {
- val configPath = OtherMod.NEU.configPath
- if (File(configPath).exists()) {
- val json = ConfigManager.gson.fromJson(
- APIUtil.readFile(File(configPath)),
- com.google.gson.JsonObject::class.java
- )
- json["storageGUI"].asJsonObject["enableStorageGUI3"].asBoolean
- } else false
- } catch (e: Exception) {
+ val config = NotEnoughUpdates.INSTANCE.config
+
+ val storageField = config.javaClass.getDeclaredField("storageGUI")
+ val storage = storageField.get(config)
+
+ val booleanField = storage.javaClass.getDeclaredField("enableStorageGUI3")
+ booleanField.get(storage) as Boolean
+ } catch (e: Throwable) {
ErrorManager.logError(e, "Could not read NEU config to determine if the neu storage is emabled.")
false
}