diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-07-05 18:37:14 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-05 10:37:14 +0200 |
| commit | 5bedd8978dc05f60ef752a95a2062e99be41281c (patch) | |
| tree | 8bdf2fbb8fbdd39ba309dcf71668005bf46f5de0 /src/main/java/at/hannibal2/skyhanni/test | |
| parent | d869292ccf8d7e1b99a6fa3234a65dbecf38381d (diff) | |
| download | skyhanni-5bedd8978dc05f60ef752a95a2062e99be41281c.tar.gz skyhanni-5bedd8978dc05f60ef752a95a2062e99be41281c.tar.bz2 skyhanni-5bedd8978dc05f60ef752a95a2062e99be41281c.zip | |
Waypoint saver (#282)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/WaypointSaver.kt | 65 |
1 files changed, 65 insertions, 0 deletions
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 |
