aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
new file mode 100644
index 000000000..1020a5a9c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt
@@ -0,0 +1,81 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox
+import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.client.gui.inventory.GuiEditSign
+import net.minecraft.client.gui.inventory.GuiInventory
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import org.lwjgl.input.Keyboard
+
+class ParkourWaypointSaver {
+ private val config get() = SkyHanniMod.feature.dev.waypoint
+ private var timeLastSaved: Long = 0
+ private var locations = mutableListOf<LorenzVec>()
+ private var parkourHelper: ParkourHelper? = null
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!Keyboard.getEventKeyState()) return
+ if (NEUItems.neuHasFocus()) return
+ if (System.currentTimeMillis() - timeLastSaved < 250) return
+
+ Minecraft.getMinecraft().currentScreen?.let {
+ if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return
+ }
+
+ val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey()
+ if (config.deleteKey == key) {
+ locations = locations.dropLast(1).toMutableList()
+ update()
+ }
+ if (config.saveKey == key) {
+ val newLocation = LocationUtils.playerLocation().roundLocation()
+ if (locations.isNotEmpty()) {
+ if (newLocation == locations.last()) return
+ }
+ locations.add(newLocation)
+ update()
+ }
+ }
+
+ private fun update() {
+ locations.copyLocations()
+ parkourHelper = ParkourHelper(locations, emptyList()).also {
+ it.showEverything = true
+ it.rainbowColor = true
+ }
+ }
+
+ private fun MutableList<LorenzVec>.copyLocations() {
+ val resultList = mutableListOf<String>()
+ timeLastSaved = System.currentTimeMillis()
+ for (location in this) {
+ val x = location.x.toString().replace(",", ".")
+ val y = location.y.toString().replace(",", ".")
+ val z = location.z.toString().replace(",", ".")
+ resultList.add("\"$x:$y:$z\"")
+ }
+ OSUtils.copyToClipboard(resultList.joinToString((",\n")))
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ if (locations.size > 2) {
+ parkourHelper?.render(event)
+ } else {
+ for (location in locations) {
+ val aabb = location.boundingToOffset(1.0, 1.0, 1.0).expandBlock()
+ event.drawFilledBoundingBox(aabb, LorenzColor.GREEN.toColor(), 1f)
+ }
+ }
+ }
+} \ No newline at end of file