aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-10-02 09:59:48 +0200
committerGitHub <noreply@github.com>2024-10-02 09:59:48 +0200
commit0864f1e1de572b955f356053ad9cb73be24d5683 (patch)
tree540c9be006afcd444b0af104a8c700a27feb122a /src/main/java/at/hannibal2/skyhanni/data
parentd06878ca5d28d20fa835a41a0f931c7a123dffb8 (diff)
downloadskyhanni-0864f1e1de572b955f356053ad9cb73be24d5683.tar.gz
skyhanni-0864f1e1de572b955f356053ad9cb73be24d5683.tar.bz2
skyhanni-0864f1e1de572b955f356053ad9cb73be24d5683.zip
Automatically stating pathfind after clicking the hypixel reminder ch… (#2635)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt
index 92a36b623..d38b6824b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.EntityMoveEvent
+import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWarpEvent
@@ -8,22 +9,36 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.entity.Entity
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.milliseconds
+import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
object EntityMovementData {
private val warpingPattern by RepoPattern.pattern(
"data.entity.warping",
- "§7(?:Warping|Warping you to your SkyBlock island|Warping using transfer token|Finding player|Sending a visit request)\\.\\.\\."
+ "§7(?:Warping|Warping you to your SkyBlock island|Warping using transfer token|Finding player|Sending a visit request)\\.\\.\\.",
)
+ private var nextTeleport: OnNextTeleport? = null
+
+ fun onNextTeleport(island: IslandType, action: () -> Unit) {
+ nextTeleport = OnNextTeleport(island, action)
+ }
+
+ class OnNextTeleport(val island: IslandType, val action: () -> Unit) {
+ val startTime: SimpleTimeMark = SimpleTimeMark.now()
+ }
+
private val entityLocation = mutableMapOf<Entity, LorenzVec>()
fun addToTrack(entity: Entity) {
@@ -33,6 +48,40 @@ object EntityMovementData {
}
@SubscribeEvent
+ fun onIslandChange(event: IslandChangeEvent) {
+ val nextData = nextTeleport ?: return
+ if (nextData.island != event.newIsland) return
+ val passedSince = nextData.startTime.passedSince()
+ if (passedSince > 5.seconds) {
+ nextTeleport = null
+ return
+ }
+
+ DelayedRun.runDelayed(100.milliseconds) {
+ nextData.action()
+ }
+ nextTeleport = null
+ }
+
+ @SubscribeEvent
+ fun onPlayerMove(event: EntityMoveEvent) {
+ if (!LorenzUtils.inSkyBlock || event.entity != Minecraft.getMinecraft().thePlayer) return
+
+ val nextData = nextTeleport ?: return
+
+ val passedSince = nextData.startTime.passedSince()
+ if (passedSince > 5.seconds) {
+ nextTeleport = null
+ return
+ }
+ if (passedSince > 50.milliseconds && nextData.island.isInIsland()) {
+ nextData.action()
+ nextTeleport = null
+ return
+ }
+ }
+
+ @SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!LorenzUtils.inSkyBlock) return
addToTrack(Minecraft.getMinecraft().thePlayer)