aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/rift
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-06-28 08:08:04 +1000
committerGitHub <noreply@github.com>2023-06-28 00:08:04 +0200
commitcf5a60283caf111ca81b8add1cccd21e04ec79a5 (patch)
tree2a369e0cb1feff9e8908d0be71c03b627ea836de /src/main/java/at/hannibal2/skyhanni/features/rift
parent65a4842de7a306d45bdda99788a7925443932b39 (diff)
downloadskyhanni-cf5a60283caf111ca81b8add1cccd21e04ec79a5.tar.gz
skyhanni-cf5a60283caf111ca81b8add1cccd21e04ec79a5.tar.bz2
skyhanni-cf5a60283caf111ca81b8add1cccd21e04ec79a5.zip
Merge pull request #260
* added kloon hacking solvers * Merge branch 'beta' into kloon_hacking * Code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/KloonHacking.kt131
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/KloonTerminal.kt14
2 files changed, 145 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/KloonHacking.kt
new file mode 100644
index 000000000..0277751ec
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/KloonHacking.kt
@@ -0,0 +1,131 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+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.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import io.github.moulberry.notenoughupdates.events.SlotClickEvent
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class KloonHacking {
+ private var wearingHelmet = false
+ private var inTerminalInventory = false
+ private var inColourInventory = false
+ private val correctButtons = mutableListOf<String>()
+ private var nearestColor: String? = null
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!RiftAPI.inRift()) return
+ if (event.isMod(20)) {
+ checkHelmet()
+ }
+ }
+
+ private fun checkHelmet() {
+ wearingHelmet = InventoryUtils.getArmor()[3]?.getInternalName() == "RETRO_ENCABULATING_VISOR"
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ inTerminalInventory = false
+ inColourInventory = false
+ if (!RiftAPI.inRift()) return
+ if (!SkyHanniMod.feature.rift.hacking.solver) return
+ if (event.inventoryName == "Hacking" || event.inventoryName == "Hacking (As seen on CSI)") {
+ inTerminalInventory = true
+ correctButtons.clear()
+ for ((slot, stack) in event.inventoryItems) {
+ if (slot in 2..6) {
+ correctButtons.add(stack.displayName.removeColor())
+ }
+ }
+ }
+ if (event.inventoryName == "Hacked Terminal Color Picker") {
+ inColourInventory = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ inTerminalInventory = false
+ inColourInventory = false
+ nearestColor = null
+ }
+
+ @SubscribeEvent
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!RiftAPI.inRift()) return
+ if (inTerminalInventory) {
+ if (!SkyHanniMod.feature.rift.hacking.solver) return
+ var i = 0
+ for (slot in InventoryUtils.getItemsInOpenChest()) {
+ if (slot.slotIndex == 11 + 10 * i) {
+ val correctButton = slot.stack!!.displayName.removeColor() == correctButtons[i]
+ slot highlight if (correctButton) LorenzColor.GREEN else LorenzColor.RED
+ continue
+ }
+ if (slot.slotIndex > i * 9 + 8 && slot.slotIndex < i * 9 + 18) {
+ if (slot.stack!!.displayName.removeColor() == correctButtons[i]) {
+ slot highlight LorenzColor.YELLOW
+ }
+ }
+ if (slot.slotIndex == i * 9 + 17) {
+ i += 1
+ }
+ }
+ }
+ if (inColourInventory) {
+ if (!SkyHanniMod.feature.rift.hacking.colour) return
+ val targetColour = nearestColor ?: getNearestColour()
+ for (slot in InventoryUtils.getItemsInOpenChest()) {
+ if (slot.stack.getLore().any { it.contains(targetColour) }) {
+ slot highlight LorenzColor.GREEN
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
+ fun onSlotClick(event: SlotClickEvent) {
+ if (!inTerminalInventory || !RiftAPI.inRift()) return
+ if (!inTerminalInventory) return
+ event.usePickblockInstead()
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!RiftAPI.inRift()) return
+ if (!SkyHanniMod.feature.rift.hacking.waypoints) return
+ if (!wearingHelmet) return
+ for (terminal in KloonTerminal.values()) {
+ event.drawWaypointFilled(terminal.location, LorenzColor.DARK_RED.toColor(), true, true)
+ }
+ }
+
+ private fun getNearestColour(): String {
+ var closestTerminal = ""
+ var closestDistance = 8.0
+
+ for (terminal in KloonTerminal.values()) {
+ val distance = terminal.location.distanceToPlayer()
+ if (distance < closestDistance) {
+ closestTerminal = terminal.name
+ closestDistance = distance
+ }
+ }
+ nearestColor = closestTerminal
+ return closestTerminal
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/KloonTerminal.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/KloonTerminal.kt
new file mode 100644
index 000000000..320105f23
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/KloonTerminal.kt
@@ -0,0 +1,14 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.utils.LorenzVec
+
+enum class KloonTerminal(val location: LorenzVec) {
+ RED(LorenzVec(-69.0, 65.0, -63.0)),
+ ORANGE(LorenzVec(-44.0, 71.0, -62.0)),
+ YELLOW(LorenzVec(-39.0, 71.0, -95.0)),
+ GREEN(LorenzVec(-62.0, 71.0, -83.0)),
+ AQUA(LorenzVec(-33.0, 70.0, -134.5)),
+ BLUE(LorenzVec(-66.5, 72.0, -119.0)),
+ PURPLE(LorenzVec(-89.0, 73.0, -115.0)),
+ PINK(LorenzVec(-110.0, 73.0, -107.0))
+} \ No newline at end of file