aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/filters/DamageNumbers.kt78
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt12
2 files changed, 88 insertions, 2 deletions
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