aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-11 15:13:50 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-11 15:13:50 +0100
commit74a3ac9c70238a7154637c9c2c01690ae9d538ab (patch)
tree64294e5e787248237527a737eb69ec3e771f6a08 /src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
parenta634e3326a484f2048259fb64cba623dbcde4370 (diff)
downloadskyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.tar.gz
skyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.tar.bz2
skyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.zip
Added location fixes to repo.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
new file mode 100644
index 000000000..2bd6a9dcb
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
@@ -0,0 +1,33 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside
+import at.hannibal2.skyhanni.utils.jsonobjects.LocationFixJson
+import net.minecraft.util.AxisAlignedBB
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object LocationFixData {
+ private var locationFixes = mutableListOf<LocationFix>()
+
+ class LocationFix(val island: IslandType, val area: AxisAlignedBB, val realLocation: String)
+
+ // priority set to low so that IslandType can load their island names from repo earlier
+ @SubscribeEvent(priority = EventPriority.LOW)
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ val data = event.getConstant<LocationFixJson>("LocationFix")
+ locationFixes.clear()
+
+ for (fix in data.locationFixes.values) {
+ val island = IslandType.getByName(fix.island_name)
+ val area = fix.a.axisAlignedTo(fix.b)
+ val realLocation = fix.real_location
+
+ locationFixes.add(LocationFix(island, area, realLocation))
+ }
+ }
+
+ fun fixLocation(skyBlockIsland: IslandType) = locationFixes
+ .firstOrNull { skyBlockIsland == it.island && it.area.isPlayerInside() }
+ ?.realLocation
+}