From 377fd979821296cde9d6ceb2fa4b365e4637232a Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Mon, 15 Apr 2024 07:09:37 +1000 Subject: Fix skill issue (#1446) Co-authored-by: Cal --- .../skyhanni/mixins/transformers/MixinXPInformation.java | 14 ++++++++++++++ src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java (limited to 'src/main/java/at/hannibal2/skyhanni') 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 -- cgit