aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-18 10:03:23 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-18 10:03:23 +0200
commit881453266e8c9db957c7a38df0d05d1b89b2627b (patch)
tree26c7c61e0a08d410bff39dc3228894d9a1d02ac9
parentf8c44bd3cc37ed479297f823284fbf515f45a2f3 (diff)
downloadskyhanni-881453266e8c9db957c7a38df0d05d1b89b2627b.tar.gz
skyhanni-881453266e8c9db957c7a38df0d05d1b89b2627b.tar.bz2
skyhanni-881453266e8c9db957c7a38df0d05d1b89b2627b.zip
Fixed error message when opening forge in dwarven mines
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
index f7fdc55cc..6549efaa9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
@@ -1,10 +1,7 @@
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiRenderEvent
-import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.PacketEvent
-import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.test.command.CopyErrorCommand
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -14,7 +11,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
-import net.minecraft.network.play.server.S30PacketWindowItems
import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -140,18 +136,20 @@ class NonGodPotEffectDisplay {
checkFooter = true
}
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: PacketEvent.ReceiveEvent) {
- val packet = event.packet
- if (packet is S30PacketWindowItems) {
- for (stack in packet.itemStacks) {
- val name = stack?.name ?: continue
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!event.inventoryName.endsWith("Active Effects")) return
+
+ for (stack in event.inventoryItems.values) {
+ val name = stack.name ?: continue
for (effect in NonGodPotEffect.values()) {
if (name == effect.displayName) continue
for (line in stack.getLore()) {
if (line.contains("Remaining") &&
line != "§7Time Remaining: §aCompleted!" &&
- !line.contains("Remaining Uses")) {
+ !line.contains("Remaining Uses")
+ ) {
val duration = try {
TimeUtils.getMillis(line.split("§f")[1])
} catch (e: IndexOutOfBoundsException) {
@@ -165,10 +163,13 @@ class NonGodPotEffectDisplay {
update()
}
}
- }
}
}
+ }
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ val packet = event.packet
if (!checkFooter) return
if (packet is S47PacketPlayerListHeaderFooter) {
val formattedText = packet.footer.formattedText