aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/DevData.java25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/WaypointSaver.kt65
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt7
4 files changed, 94 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index da4431c4f..e1c83f54a 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -328,6 +328,7 @@ class SkyHanniMod {
loadModule(TestBingo)
loadModule(TestCopyRngMeterValues)
loadModule(HighlightMissingRepoItems())
+ loadModule(WaypointSaver())
}
@Mod.EventHandler
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java
index 1fb5a2be1..961eefd4b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java
@@ -2,10 +2,8 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.moulconfig.annotations.ConfigAccordionId;
-import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion;
-import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
-import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import io.github.moulberry.moulconfig.annotations.*;
+import org.lwjgl.input.Keyboard;
public class DevData {
@@ -71,6 +69,25 @@ public class DevData {
@ConfigAccordionId(id = 0)
public boolean highlightMissingRepo = false;
+ @ConfigOption(name = "Waypoints", desc = "")
+ @Accordion
+ @Expose
+ public Waypoints waypoint = new Waypoints();
+
+ public static class Waypoints {
+
+ @Expose
+ @ConfigOption(name = "Save Hotkey", desc = "Saves block location to the waypoints list and copies everything to your clipboard.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int saveKey = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(name = "Delete Hotkey", desc = "Deletes the last saved location for when you make a mistake.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int deleteKey = Keyboard.KEY_NONE;
+
+ }
+
@Expose
public Position debugPos = new Position(10, 10, false, true);
diff --git a/src/main/java/at/hannibal2/skyhanni/test/WaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/WaypointSaver.kt
new file mode 100644
index 000000000..670129e27
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/WaypointSaver.kt
@@ -0,0 +1,65 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.*
+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 WaypointSaver {
+ private val config get() = SkyHanniMod.feature.dev.waypoint
+ private var timeLastSaved: Long = 0
+ private var locations = mutableListOf<LorenzVec>()
+
+ @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()
+ locations.copyLocations()
+ }
+ if (config.saveKey == key) {
+ val newLocation = LocationUtils.playerLocation().roundLocation()
+ if (locations.isNotEmpty()) {
+ if (newLocation == locations.last()) return
+ }
+ locations.add(newLocation)
+ locations.copyLocations()
+ }
+ }
+
+ private fun MutableList<LorenzVec>.copyLocations() {
+ val resultList = mutableListOf<String>()
+ timeLastSaved = System.currentTimeMillis()
+ for (location in this) {
+ val x = location.z.toString().replace(",", ".")
+ val y = location.z.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
+ for (location in locations) {
+ event.drawWaypointFilled(location, LorenzColor.GREEN.toColor())
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 4b716964f..b0b363b05 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -95,6 +95,13 @@ data class LorenzVec(
fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals))
+ fun roundLocation(): LorenzVec {
+ val x = if (this.x < 0) x.toInt().toDouble() - 1 else x.toInt().toDouble()
+ val y = y.toInt().toDouble() - 1
+ val z = if (this.z < 0) z.toInt().toDouble() - 1 else z.toInt().toDouble()
+ return LorenzVec(x, y, z)
+ }
+
companion object {
fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
val yaw: Double = (yaw + 90) * Math.PI / 180