aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt9
4 files changed, 24 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index b3e27f011..2877c843c 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -1,9 +1,6 @@
package at.hannibal2.skyhanni.data
-import at.hannibal2.skyhanni.events.HypixelJoinEvent
-import at.hannibal2.skyhanni.events.IslandChangeEvent
-import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -11,7 +8,6 @@ import at.hannibal2.skyhanni.utils.TabListData
import net.minecraft.client.Minecraft
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.TickEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent
class HypixelData {
@@ -73,14 +69,9 @@ class HypixelData {
}
}
- var tick = 0
-
@SubscribeEvent
- fun onTick(event: TickEvent.ClientTickEvent) {
- if (event.phase != TickEvent.Phase.START) return
-
- tick++
- if (tick % 5 != 0) return
+ fun onTick(event: LorenzTickEvent) {
+ if (!event.isMod(5)) return
if (!LorenzUtils.onHypixel) {
checkHypixel()
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
index f463391e3..334a99bf7 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.data
+import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
@@ -8,6 +9,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec
import net.minecraft.network.play.server.S29PacketSoundEffect
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
class MinecraftData {
@@ -49,4 +51,13 @@ class MinecraftData {
event.isCanceled = true
}
}
+
+ private var tick = 0
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+ tick++
+ LorenzTickEvent(tick).postAndCatch()
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt
new file mode 100644
index 000000000..ce9c57e97
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt
@@ -0,0 +1,5 @@
+package at.hannibal2.skyhanni.events
+
+class LorenzTickEvent(private val tick: Int) : LorenzEvent() {
+ fun isMod(i: Int) = tick % i == 0
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt
index 509ed4979..295104caa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt
@@ -2,17 +2,18 @@ package at.hannibal2.skyhanni.features.rift
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleUtils
+import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.test.command.CopyErrorCommand
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import net.minecraft.client.Minecraft
-import kotlin.concurrent.fixedRateTimer
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CruxWarnings {
private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!")
- init {
- fixedRateTimer(name = "skyhanni-shywarner-timer", period = 250) {
- Minecraft.getMinecraft().thePlayer ?: return@fixedRateTimer
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (event.isMod(2)) {
checkForShy()
}
}