diff options
author | ronald <inglettronald@gmail.com> | 2023-07-29 14:47:34 -0500 |
---|---|---|
committer | ronald <inglettronald@gmail.com> | 2023-07-29 14:47:34 -0500 |
commit | b4c6da5d3ca2629e15f41f5407fe120c3b919f2d (patch) | |
tree | 7c0d64e3baf7d21bc88e258fa4ec8ff61e9345b3 /src/main/kotlin/com | |
parent | dc19ac82366d132123e92aaf7c236c1834d132c5 (diff) | |
download | DulkirMod-Fabric-b4c6da5d3ca2629e15f41f5407fe120c3b919f2d.tar.gz DulkirMod-Fabric-b4c6da5d3ca2629e15f41f5407fe120c3b919f2d.tar.bz2 DulkirMod-Fabric-b4c6da5d3ca2629e15f41f5407fe120c3b919f2d.zip |
Damage Splash Features and Blaze slayer fireball culling
Diffstat (limited to 'src/main/kotlin/com')
4 files changed, 102 insertions, 3 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index f0f8a8d..777cf6e 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -10,6 +10,7 @@ import com.dulkirfabric.features.* import com.dulkirfabric.features.chat.AbiPhoneDND import com.dulkirfabric.features.chat.BridgeBotFormatter import com.dulkirfabric.features.filters.CullExplosionParticles +import com.dulkirfabric.features.filters.DamageNumbers import com.dulkirfabric.features.filters.Lightning import com.dulkirfabric.features.slayer.BossTimer import com.dulkirfabric.features.slayer.Demonlord @@ -91,6 +92,7 @@ object Registrations { EVENT_BUS.subscribe(Lightning) EVENT_BUS.subscribe(Utils) EVENT_BUS.subscribe(BossTimer) + EVENT_BUS.subscribe(DamageNumbers) if (FabricLoader.getInstance().isDevelopmentEnvironment) EVENT_BUS.subscribe(RenderTest) diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index 8dbca32..c4cbd86 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -25,7 +25,6 @@ import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import me.shedaniel.clothconfig2.api.ConfigBuilder -import meteordevelopment.orbit.EventHandler import moe.nea.jarvis.api.Point import net.minecraft.client.gui.screen.Screen import net.minecraft.client.util.InputUtil @@ -119,6 +118,15 @@ class DulkirConfig { entryBuilder.mkToggle(Text.literal("Hide Lightning (SkyBlock only)"), configOptions::hideLightning) ) general.addEntry( + entryBuilder.mkToggle(Text.literal("Hide Non-Crits"), configOptions::hideNonCrits) + ) + general.addEntry( + entryBuilder.mkToggle(Text.literal("Hide Crits"), configOptions::hideCrits) + ) + general.addEntry( + entryBuilder.mkToggle(Text.literal("Truncate Crits"), configOptions::truncateDamage) + ) + general.addEntry( entryBuilder.startIntSlider(Text.literal("Anti Downtime Alarm"), configOptions.alarmTimeout, 0, 1000) .setSaveConsumer { configOptions.alarmTimeout = it @@ -328,6 +336,9 @@ class DulkirConfig { var hideLightning: Boolean = false, var cleanBlaze: Boolean= false, var timeSlayerBoss: Boolean = false, + var hideNonCrits: Boolean = false, + var truncateDamage: Boolean = false, + var hideCrits: Boolean = false ) @Serializable diff --git a/src/main/kotlin/com/dulkirfabric/features/filters/DamageNumbers.kt b/src/main/kotlin/com/dulkirfabric/features/filters/DamageNumbers.kt new file mode 100644 index 0000000..0f94a80 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/filters/DamageNumbers.kt @@ -0,0 +1,78 @@ +package com.dulkirfabric.features.filters + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.WorldRenderLastEvent +import meteordevelopment.orbit.EventHandler +import net.minecraft.entity.decoration.ArmorStandEntity +import net.minecraft.text.Text + +object DamageNumbers { + + private val nonCritFormat = """^(\d{1,3}(,\d{3})*|\d+)$""".toRegex() + private val trimPattern = "[✧,]".toRegex() + private val critColorList = listOf( + "§e", "§f", "§c", "§6" + ) + @EventHandler + fun worldLast(event: WorldRenderLastEvent) { + val ents = mc.world?.entities ?: return + ents.forEach { + if (it !is ArmorStandEntity) return@forEach + if (!it.isMarker) return@forEach + if (!it.hasCustomName()) return@forEach + if (!it.isCustomNameVisible) return@forEach + val name = it.customName?.string ?: return@forEach + if (name matches nonCritFormat && DulkirConfig.configOptions.hideNonCrits) { + it.isCustomNameVisible = false + } + if (name.startsWith('✧')) { + if (DulkirConfig.configOptions.hideCrits) { + it.isCustomNameVisible = false + return@forEach + } + if (!DulkirConfig.configOptions.truncateDamage) return@forEach + val critAmount = name.replace(trimPattern, "").toInt() + it.customName = Text.literal(truncate(critAmount).applyDulkirCritColors()) + } + } + } + + /** + * Truncate any positive int + */ + private fun truncate(value: Int): String { + val str = value.toString() + return when { + str.length > 9 -> { + val i = str.length - 9 + "✧ ${str.substring(0, i)}.${str[i]}B ✧" + } + + str.length > 6 -> { + val i = str.length - 6 + "✧ ${str.substring(0, i)}.${str[i]}M ✧" + } + + str.length > 3 -> { + val i = str.length - 3 + "✧ ${str.substring(0, i)}.${str[i]}K✧" + } + + else -> "✧ $str ✧" + } + } + + private fun String.applyDulkirCritColors(): String { + val sb = StringBuilder() + var i = 0 + for (char in this) { + if (char != ' ') { + sb.append(critColorList[i % critColorList.size]) + i++ + } + sb.append(char) + } + return sb.toString() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt b/src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt index b9d03d1..e79a5ae 100644 --- a/src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt +++ b/src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt @@ -3,16 +3,16 @@ package com.dulkirfabric.features.slayer import com.dulkirfabric.DulkirModFabric.mc import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.AddParticleEvent -import com.dulkirfabric.events.PlaySoundEvent +import com.dulkirfabric.events.EntityLoadEvent import com.dulkirfabric.events.SlayerBossEvents import com.dulkirfabric.events.WorldRenderLastEvent import com.dulkirfabric.util.TablistUtils import com.dulkirfabric.util.TextUtils -import com.dulkirfabric.util.Utils.debugSound import com.dulkirfabric.util.Utils.getInterpolatedPos import com.dulkirfabric.util.render.WorldRenderUtils import meteordevelopment.orbit.EventHandler import net.minecraft.entity.decoration.ArmorStandEntity +import net.minecraft.entity.projectile.SmallFireballEntity import net.minecraft.util.math.Box import java.awt.Color @@ -70,4 +70,12 @@ object Demonlord { if (!inBoss) return event.cancel() } + + @EventHandler + fun onEntityLoad(event: EntityLoadEvent) { + if (!DulkirConfig.configOptions.cleanBlaze) return + if (!inBoss) return + if (event.entity is SmallFireballEntity) + event.entity.kill() + } }
\ No newline at end of file |