diff options
Diffstat (limited to 'src')
8 files changed, 127 insertions, 6 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index 8b88830..1637404 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -57,6 +57,7 @@ class DulkirMod { cch.registerCommand(HurtCamCommand()) cch.registerCommand(FarmingControlSchemeCommand()) cch.registerCommand(DynamicKeyCommand()) + cch.registerCommand(ResetSlayerTracker()) } @Mod.EventHandler @@ -89,6 +90,7 @@ class DulkirMod { mcBus.register(ReaperDisplay) mcBus.register(ImpactDisplay) mcBus.register(EffigyWaypoint) + mcBus.register(SlayerTrackerUtil) keyBinds.forEach(ClientRegistry::registerKeyBinding) } diff --git a/src/main/kotlin/dulkirmod/command/ResetSlayerTracker.kt b/src/main/kotlin/dulkirmod/command/ResetSlayerTracker.kt new file mode 100644 index 0000000..7d1d1fd --- /dev/null +++ b/src/main/kotlin/dulkirmod/command/ResetSlayerTracker.kt @@ -0,0 +1,15 @@ +package dulkirmod.command + +import dulkirmod.events.SlayerTypeChangeEvent +import dulkirmod.utils.TextUtils +import net.minecraft.command.CommandException +import net.minecraft.command.ICommandSender +import net.minecraftforge.common.MinecraftForge + +class ResetSlayerTracker : ClientCommandBase("dsr") { + @Throws(CommandException::class) + override fun processCommand(sender: ICommandSender, args: Array<String>) { + MinecraftForge.EVENT_BUS.post(SlayerTypeChangeEvent()) + TextUtils.info("§6Slayer Tracker session data reset.") + } +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt index a4aea6c..bd9bf9d 100644 --- a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt +++ b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt @@ -2,12 +2,14 @@ package dulkirmod.config import cc.polyfrost.oneconfig.config.Config import cc.polyfrost.oneconfig.config.annotations.* +import cc.polyfrost.oneconfig.config.annotations.Number import cc.polyfrost.oneconfig.config.core.OneColor import cc.polyfrost.oneconfig.config.data.Mod import cc.polyfrost.oneconfig.config.data.ModType import dulkirmod.DulkirMod import dulkirmod.overlays.GardenInfoHud import dulkirmod.overlays.KeyHud +import dulkirmod.overlays.SlayerTracker import dulkirmod.overlays.YawDisplayHud import dulkirmod.utils.Utils import net.minecraft.client.audio.SoundCategory @@ -796,6 +798,22 @@ object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-conf ) var GardenInfoHud: GardenInfoHud = GardenInfoHud() + @HUD( + name = "Slayer Tracker", + category = "HUD", + subcategory = "Slayer" + ) + var slayerTracker: SlayerTracker = SlayerTracker() + + @Number( + name = "Slayer XP per boss", + category = "HUD", + subcategory = "Slayer", + max = 2000f, + min = 5f + ) + var slayerXP = 500 + @Switch( name = "Empty Composter Notif", description = "Will display in HUD instead of giga-alert", diff --git a/src/main/kotlin/dulkirmod/events/Events.kt b/src/main/kotlin/dulkirmod/events/Events.kt index 092c07d..0d8c18f 100644 --- a/src/main/kotlin/dulkirmod/events/Events.kt +++ b/src/main/kotlin/dulkirmod/events/Events.kt @@ -16,4 +16,6 @@ class EntityRemovedEvent(val entity: Entity) : Event() */ data class AlwaysPlaySoundEvent(val sound: ISound, val soundManager: SoundManager) : Event() { val name = sound.soundLocation.resourcePath -}
\ No newline at end of file +} + +class SlayerTypeChangeEvent : Event()
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt b/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt index 7375b24..8dbad9f 100644 --- a/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt +++ b/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt @@ -14,10 +14,10 @@ object BlazeSlayerFeatures { private val minibosses = "(Flare Demon)|(Kindleheart Demon)|(Burningsoul Demon)".toRegex() private val phaseColors = listOf( - "CRYSTAL ♨" to Color(15, 247, 236, 200), - "ASHEN ♨" to Color(40, 40, 40, 200), - "AURIC ♨" to Color(206, 219, 57, 200), - "SPIRIT ♨" to Color(255, 255, 255, 200) + "CRYSTAL ♨" to Color(15, 247, 236, 255), + "ASHEN ♨" to Color(0, 0, 0, 255), + "AURIC ♨" to Color(206, 219, 57, 255), + "SPIRIT ♨" to Color(255, 255, 255, 255) ) @SubscribeEvent diff --git a/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt b/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt index 8709497..0c2b12f 100644 --- a/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt +++ b/src/main/kotlin/dulkirmod/features/dungeons/DragonFeatures.kt @@ -62,7 +62,7 @@ object DragonFeatures { val particleVec = Vec3(x, y, z) dragons.forEach { - if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach + if (System.currentTimeMillis() - it.spawnTime < 7000 || !inRangeOf(it.color, particleVec)) return@forEach it.spawnTime = System.currentTimeMillis() } } diff --git a/src/main/kotlin/dulkirmod/overlays/SlayerTracker.kt b/src/main/kotlin/dulkirmod/overlays/SlayerTracker.kt new file mode 100644 index 0000000..dc1e956 --- /dev/null +++ b/src/main/kotlin/dulkirmod/overlays/SlayerTracker.kt @@ -0,0 +1,26 @@ +package dulkirmod.overlays + +import cc.polyfrost.oneconfig.hud.TextHud +import dulkirmod.utils.SlayerTrackerUtil.averageBossesPerHour +import dulkirmod.utils.SlayerTrackerUtil.averageSpawnKillTime +import dulkirmod.utils.SlayerTrackerUtil.averageXPPerHour +import dulkirmod.utils.SlayerTrackerUtil.currentSlayerType +import dulkirmod.utils.SlayerTrackerUtil.sessionXP +import java.text.NumberFormat + +class SlayerTracker : TextHud(false) { + override fun getLines(lines: MutableList<String>?, example: Boolean) { + if (currentSlayerType != "" && !example) { + val trimmedSlayer = if (currentSlayerType == "Endermen") { + "Enderman" + } else { + currentSlayerType.trimEnd('s') + } + lines?.add("Slayer: $trimmedSlayer") + lines?.add("Session XP: ${NumberFormat.getInstance().format(sessionXP)}") + lines?.add("Average Spawn + Kill Time: ${"%.2f".format(averageSpawnKillTime)}s") + lines?.add("Average Bosses Per Hour: ${"%.1f".format(averageBossesPerHour)}") + lines?.add("Average XP Per Hour: ${NumberFormat.getInstance().format(averageXPPerHour)}") + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/utils/SlayerTrackerUtil.kt b/src/main/kotlin/dulkirmod/utils/SlayerTrackerUtil.kt new file mode 100644 index 0000000..4dc772e --- /dev/null +++ b/src/main/kotlin/dulkirmod/utils/SlayerTrackerUtil.kt @@ -0,0 +1,58 @@ +package dulkirmod.utils + +import dulkirmod.config.DulkirConfig +import dulkirmod.events.SlayerTypeChangeEvent +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object SlayerTrackerUtil { + private var sessionStartTime = 0L + var sessionXP: Int = 0 + var averageSpawnKillTime: Float = 0f + var averageBossesPerHour: Float = 0f + var averageXPPerHour: Int = 0 + var currentSlayerType: String = "" + private var lastKillTime = 0L + + val slayerQuestStartRegex = "» Slay (\\d{1,3}(?:,\\d{3})*) Combat XP worth of (\\w+).".toRegex() + @SubscribeEvent + fun onSlayerTypeChange(event: SlayerTypeChangeEvent) { + // reset relevant tracking features + sessionXP = 0 + averageSpawnKillTime = 0f + averageBossesPerHour = 0f + averageXPPerHour = 0 + sessionStartTime = System.currentTimeMillis() + lastKillTime = sessionStartTime + } + + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW) + fun onChat(event: ClientChatReceivedEvent) { + if (event.type == 2.toByte()) { + return + } + val unformatted = Utils.stripColorCodes(event.message.unformattedText).trim() + if (unformatted matches slayerQuestStartRegex) { + val type = slayerQuestStartRegex.find(unformatted)?.groupValues?.get(2) + if (type == null) { + TextUtils.info("Failed to parse slayer type, please report to dulkir.") + return + } + if (type != currentSlayerType) { + MinecraftForge.EVENT_BUS.post(SlayerTypeChangeEvent()) + currentSlayerType = type + return + } + + sessionXP += DulkirConfig.slayerXP + val totalBosses = sessionXP/DulkirConfig.slayerXP + + averageSpawnKillTime = ((averageSpawnKillTime * (totalBosses - 1) + (System.currentTimeMillis() - lastKillTime) / 1000)) / totalBosses + lastKillTime = System.currentTimeMillis() + averageBossesPerHour = 3600 / averageSpawnKillTime + averageXPPerHour = (averageBossesPerHour * 500).toInt() + } + } +}
\ No newline at end of file |