diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-04-15 07:09:37 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-14 23:09:37 +0200 |
commit | 377fd979821296cde9d6ceb2fa4b365e4637232a (patch) | |
tree | f89e2cbc22ec01155c8a48dcbc9661ed05e96cab /src/main/java | |
parent | 161ed783e0e4e0d5d57e358f9939c08f934aee1d (diff) | |
download | skyhanni-377fd979821296cde9d6ceb2fa4b365e4637232a.tar.gz skyhanni-377fd979821296cde9d6ceb2fa4b365e4637232a.tar.bz2 skyhanni-377fd979821296cde9d6ceb2fa4b365e4637232a.zip |
Fix skill issue (#1446)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java | 14 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt | 13 |
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 |