diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-16 13:27:44 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-16 13:27:44 +0200 |
commit | 6e8b4eba4d96fa71e5ed7263245ca9f19490d244 (patch) | |
tree | e6b8559466a126f0b536f17fcd38366e6432e658 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | b90d16f0a377a900877f4eebba7fe0c371f92fc6 (diff) | |
download | skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.tar.gz skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.tar.bz2 skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.zip |
Fixed SkyHanni gui edit button not working inside storage even if neu storage is not disabled.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt | 31 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 8 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 8aefe5a2e..4c60444c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -1,10 +1,15 @@ 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 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 { var itemInHandId = NEUInternalName.NONE @@ -39,14 +44,28 @@ object InventoryUtils { fun countItemsInLowerInventory(predicate: (ItemStack) -> Boolean) = getItemsInOwnInventory().filter { predicate(it) }.sumOf { it.stackSize } - fun inStorage() = - openInventoryName().let { - (it.contains("Storage") && !it.contains("Rift Storage")) || it.contains("Ender Chest") || it.contains( - "Backpack" - ) - } + fun inStorage() = openInventoryName().let { + (it.contains("Storage") && !it.contains("Rift Storage")) + || it.contains("Ender Chest") || it.contains("Backpack") + } fun getItemInHand(): ItemStack? = Minecraft.getMinecraft().thePlayer.heldItem fun getArmor(): Array<ItemStack?> = Minecraft.getMinecraft().thePlayer.inventory.armorInventory + + 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) { + ErrorManager.logError(e, "Could not read NEU config to determine if the neu storage is emabled.") + false + } + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index ab21c47b1..dd4e21dc1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -252,17 +252,17 @@ object NEUItems { // ignore wheat in enchanted cookie if (internalName == "ENCHANTED_COOKIE" && internalItemId == "WHEAT") { - continue + continue } // ignore golden carrot in enchanted golden carrot if (internalName == "ENCHANTED_GOLDEN_CARROT" && internalItemId == "GOLDEN_CARROT") { - continue + continue } // ignore rabbit hide in leather if (internalName == "LEATHER" && internalItemId == "RABBIT_HIDE") { - continue + continue } val old = map.getOrDefault(internalItemId, 0) @@ -298,7 +298,7 @@ object NEUItems { fun neuHasFocus(): Boolean { if (AuctionSearchOverlay.shouldReplace()) return true if (BazaarSearchOverlay.shouldReplace()) return true - if (InventoryUtils.inStorage()) return true + if (InventoryUtils.inStorage() && InventoryUtils.isNeuStorageEnabled.getValue()) return true if (NEUOverlay.searchBarHasFocus) return true return false |