From a5c540d977a3510812cac7fac340fe17e7d10983 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Thu, 14 Jul 2022 12:06:07 +0200 Subject: renamed mod to SkyHanni --- .../at/hannibal2/skyhanni/dungeon/DungeonData.kt | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt (limited to 'src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt new file mode 100644 index 000000000..eedf664a3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.dungeon + +import at.hannibal2.skyhanni.events.DungeonEnterEvent +import at.hannibal2.skyhanni.misc.ScoreboardData +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class DungeonData { + + companion object { + var dungeonFloor: String? = null + + fun isOneOf(vararg floors: String): Boolean { + for (floor in floors) { + if (dungeonFloor == floor) { + return true + } + } + + return false + } + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + if (LorenzUtils.inDungeons) { + if (dungeonFloor == null) { + for (line in ScoreboardData.sidebarLines) { + if (line.contains("The Catacombs (")) { + dungeonFloor = line.substringAfter("(").substringBefore(")") + DungeonEnterEvent(dungeonFloor!!).postAndCatch() + break + } + } + } + } + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + dungeonFloor = null + } +} \ No newline at end of file -- cgit