aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/HotSwapDetection.kt53
3 files changed, 64 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index b4a9a1c12..4006df431 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -289,6 +289,7 @@ import at.hannibal2.skyhanni.features.summonings.SummoningMobManager
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.HighlightMissingRepoItems
+import at.hannibal2.skyhanni.test.HotSwapDetection
import at.hannibal2.skyhanni.test.PacketTest
import at.hannibal2.skyhanni.test.ParkourWaypointSaver
import at.hannibal2.skyhanni.test.ShowItemUuid
@@ -639,6 +640,8 @@ class SkyHanniMod {
loadModule(HighlightMissingRepoItems())
loadModule(ParkourWaypointSaver())
loadModule(TestShowSlotNumber())
+ loadModule(SkyHanniDebugsAndTests)
+ loadModule(HotSwapDetection)
}
@Mod.EventHandler
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
index be43a7526..4ee5f9469 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
@@ -34,9 +34,9 @@ public class DevConfig {
@Expose
@ConfigOption(
- name = "Mod Menu Log",
- desc = "Enables debug messages when the currently opened GUI changes, with the path to the gui class. " +
- "Useful for adding more mods to quick mod menu switch."
+ name = "Mod Menu Log",
+ desc = "Enables debug messages when the currently opened GUI changes, with the path to the gui class. " +
+ "Useful for adding more mods to quick mod menu switch."
)
@ConfigEditorBoolean
public boolean modMenuLog = false;
@@ -95,6 +95,11 @@ public class DevConfig {
@ConfigOption(name = "Highlight Missing Repo Items", desc = "Highlights each item in the current inventory that is not in your current NEU repo.")
@ConfigEditorBoolean
public boolean highlightMissingRepo = false;
+
+ @Expose
+ @ConfigOption(name = "Hot Swap Detection", desc = "Show chat messages when Hot Swap starts and ends.")
+ @ConfigEditorBoolean
+ public boolean hotSwapDetection = false;
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/test/HotSwapDetection.kt b/src/main/java/at/hannibal2/skyhanni/test/HotSwapDetection.kt
new file mode 100644
index 000000000..e3acc25e7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/HotSwapDetection.kt
@@ -0,0 +1,53 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.MinecraftData
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import kotlin.concurrent.fixedRateTimer
+
+object HotSwapDetection {
+ private val config get() = SkyHanniMod.feature.dev.debug
+
+ private var latestTick = 0
+ private var lastTps = 0
+ private var hotswap = false
+
+ init {
+ fixedRateTimer(name = "skyhanni-tps-counter-seconds", period = 1000L) {
+ val currentTick = MinecraftData.totalTicks
+ val diff = currentTick - latestTick
+ latestTick = currentTick
+
+ // we count 2 client ticks per tick, we are bad
+ handleTps(diff / 2)
+ }
+ }
+
+ private fun handleTps(tps: Int) {
+ if (!config.hotSwapDetection) return
+
+ // ignore below one minute
+ if (latestTick < 20 * 60) return
+
+ println("diff: $tps")
+
+ if (tps < 5) {
+ LorenzUtils.debug("Lags! Only $tps tps")
+ }
+
+ if (!hotswap) {
+ if (tps < 2) {
+ if (lastTps > 15) {
+ LorenzUtils.debug("Detected hotswap now!")
+ hotswap = true
+ }
+ }
+ } else {
+ if (tps > 15) {
+ hotswap = false
+ LorenzUtils.debug("Detected hotswap end!")
+ }
+ }
+ lastTps = tps
+ }
+}