diff options
author | CalMWolfs <cwolfson58@gmail.com> | 2023-06-24 00:16:11 +1000 |
---|---|---|
committer | CalMWolfs <cwolfson58@gmail.com> | 2023-06-24 00:16:11 +1000 |
commit | 092eac9752c79d34c9a7a9bf20c5491b1936f16e (patch) | |
tree | 2f7cbd748db3aa2a62969dae1b9da248f1946e17 /src/main/java/at/hannibal2 | |
parent | bba69288cb1224cd203bfb113a6c9f11bf6499e8 (diff) | |
download | skyhanni-092eac9752c79d34c9a7a9bf20c5491b1936f16e.tar.gz skyhanni-092eac9752c79d34c9a7a9bf20c5491b1936f16e.tar.bz2 skyhanni-092eac9752c79d34c9a7a9bf20c5491b1936f16e.zip |
kinda more done
Diffstat (limited to 'src/main/java/at/hannibal2')
3 files changed, 72 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2ba491953..9739e4aa5 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -309,7 +309,7 @@ class SkyHanniMod { loadModule(RiftLarva()) loadModule(RiftOdonata()) loadModule(RiftAgaricusCap()) - loadModule(EnigmaSoulWaypoints()) + loadModule(EnigmaSoulWaypoints) init() diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt index 7f5c901a6..5abbc22ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt @@ -2,40 +2,85 @@ package at.hannibal2.skyhanni.features.rift import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent import io.github.moulberry.notenoughupdates.events.SlotClickEvent +import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.player.inventory.ContainerLocalMenu +import net.minecraft.init.Blocks import net.minecraft.inventory.ContainerChest +import net.minecraft.item.ItemStack import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class EnigmaSoulWaypoints { +object EnigmaSoulWaypoints { private var inInventory = false - private val soulLocations = mutableMapOf<String, LorenzVec>() + private val soulLocations = mutableMapOf<String, Pair<LorenzVec, RiftRegion>>() private val trackedSouls = mutableListOf<String>() + private val inventoryUnfound = mutableListOf<String>() + private var adding = true + + private val item by lazy { + val neuItem = NEUItems.getItemStackOrNull("SKYBLOCK_ENIGMA_SOUL") ?: ItemStack(Blocks.obsidian) // can prob have a better fallback + Utils.createItemStack(neuItem.item, "§5Toggle Missing", "§7Click here to toggle", "§7the waypoints for each", "§7missing souls on this page") + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (inventoryUnfound.isEmpty()) return + if (event.inventory is ContainerLocalMenu && inInventory && event.slotNumber == 31) { + event.replaceWith(item) + } + } @SubscribeEvent fun onInventoryOpen(event: InventoryOpenEvent) { inInventory = false - if (event.inventoryName.contains("Enigma Souls")) inInventory = true + if (!event.inventoryName.contains("Enigma Souls")) return + inInventory = true + + for (stack in event.inventoryItems.values) { + val split = stack.displayName.split("Enigma: ") + if (split.size == 2) { + if (stack.getLore().last() == "§8✖ Not completed yet!") { + inventoryUnfound.add(split.last()) + } + } + } } @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { inInventory = false + inventoryUnfound.clear() + adding = true } @SubscribeEvent(priority = EventPriority.HIGH) fun onSlotClick(event: SlotClickEvent) { if (!inInventory || !RiftAPI.inRift()) return + if (event.slotId == 31 && inventoryUnfound.isNotEmpty()) { + event.isCanceled = true + if (adding) { + trackedSouls.addAll(inventoryUnfound) + adding = false + } else { + trackedSouls.removeAll(inventoryUnfound) + adding = true + } + } + val split = event.slot.stack.displayName.split("Enigma: ") if (split.size == 2) { event.isCanceled = true // maybe change to a middle click @@ -69,14 +114,17 @@ class EnigmaSoulWaypoints { } } } + if (!adding) { + chest.inventorySlots[31] highlight LorenzColor.DARK_PURPLE + } } @SubscribeEvent fun onRenderWorld(event: RenderWorldLastEvent) { if (!RiftAPI.inRift()) return for (soul in trackedSouls) { - soulLocations[soul]?.let { event.drawWaypointFilled(it, LorenzColor.DARK_PURPLE.toColor(), true, true) } - soulLocations[soul]?.let { event.drawDynamicText(it.add(0, 1, 0), "§5$soul Soul", 1.0) } + soulLocations[soul]?.let { event.drawWaypointFilled(it.first, LorenzColor.DARK_PURPLE.toColor(), true, true) } + soulLocations[soul]?.let { event.drawDynamicText(it.first.add(0, 1, 0), "§5$soul Soul", 1.0) } } } @@ -85,6 +133,7 @@ class EnigmaSoulWaypoints { val data = event.getConstant("EnigmaSouls") ?: return for (area in data.entrySet()) { + val region = RiftRegion.values().firstOrNull {it.areaName == area.key.toString()} ?: continue val element = area.value.asJsonArray for (i in 0 until element.size()) { @@ -93,7 +142,8 @@ class EnigmaSoulWaypoints { val position = itemObject["position"].asString val split = position.split(", ") if (split.size == 3) { - soulLocations[name] = LorenzVec(split[0].toDouble(), split[1].toDouble(), split[2].toDouble()) + val location = LorenzVec(split[0].toDouble(), split[1].toDouble(), split[2].toDouble()) + soulLocations[name] = Pair(location, region) } } } @@ -114,9 +164,9 @@ class EnigmaSoulWaypoints { var closestDistance = 8.0 for (soul in soulLocations) { - if (soul.value.distanceToPlayer() < closestDistance) { + if (soul.value.first.distanceToPlayer() < closestDistance) { closestSoul = soul.key - closestDistance = soul.value.distanceToPlayer() + closestDistance = soul.value.first.distanceToPlayer() } } trackedSouls.remove(closestSoul) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftRegion.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftRegion.kt new file mode 100644 index 000000000..c18c05532 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftRegion.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.features.rift + +enum class RiftRegion(val areaName: String, vararg val aliases: String) { + WYLD_WOODS("Wyld Woods", "wyld", "woods"), + BLACK_LAGOON("Black Lagoon", "lagoon", "black"), + WEST_VILLAGE("West Village", "west"), + DREADFARM("Dreadfarm", "dreadfarm"), + VILLAGE_PLAZA("Village Plaza", "plaza", "villagePlaza"), + LIVING_CAVE("Living Cave", "living", "cave"), + COLOSSEUM("Colosseum", "collosseum"), + STILLGORE_CHATEAU("Stillgore Château", "stillgore", "chateau"), + MOUNTAINTOP("Mountaintop") +}
\ No newline at end of file |