aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt13
2 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java
new file mode 100644
index 000000000..16fb774cd
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java
@@ -0,0 +1,14 @@
+package at.hannibal2.skyhanni.mixins.transformers;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Pseudo;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Pseudo
+@Mixin(targets = "io.github.moulberry.notenoughupdates.util.XPInformation$SkillInfo")
+public interface MixinXPInformation {
+
+ @Accessor(value = "totalXp")
+ double getTotalXp();
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
index 31bfe4416..362654807 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter
import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData
+import at.hannibal2.skyhanni.mixins.transformers.MixinXPInformation
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils
import io.github.moulberry.notenoughupdates.util.XPInformation
@@ -25,6 +26,16 @@ object CombatUtils {
private var gainTimer = 0
var _isKilling = false
+ private fun getSkillInfo(xpInformation: XPInformation.SkillInfo?): Float {
+ return try {
+ val a = xpInformation as? MixinXPInformation
+ a!!.getTotalXp().toFloat()
+ } catch (e: Exception) {
+ val xpInfo = xpInformation ?: return -1f
+ xpInfo.totalXp
+ }
+ }
+
/**
* Taken from NotEnoughUpdates
*/
@@ -33,7 +44,7 @@ object CombatUtils {
xpGainHourLast = xpGainHour
skillInfoLast = skillInfo
skillInfo = XPInformation.getInstance().getSkillInfo(SKILL_TYPE) ?: return
- val totalXp: Float = skillInfo!!.totalXp
+ val totalXp = getSkillInfo(skillInfo)
if (lastTotalXp > 0) {
val delta: Float = totalXp - lastTotalXp