aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt
blob: e79a5aeacfc120f9154ebefe74f04d1bac507a85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.dulkirfabric.features.slayer

import com.dulkirfabric.DulkirModFabric.mc
import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.AddParticleEvent
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.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

object Demonlord {
    private val phaseColors = listOf(
        "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)
    )
    private val box = Box(-.5, -.4, -.5, .5, -1.9, .5)
    private var inBoss: Boolean = false
    private var lastSpawnTime: Long = 0

    @EventHandler
    fun attunementHighlight(event: WorldRenderLastEvent) {
        if (TablistUtils.persistentInfo.area != "Crimson Isle") return
        val ents = mc.world?.entities ?: return
        ents.forEach { ent ->
            if (ent is ArmorStandEntity && ent.hasCustomName()) {
                val name = TextUtils.stripColorCodes(ent.customName?.string ?: return@forEach)
                val color = phaseColors.firstOrNull { name.contains(it.first) }?.second ?: return@forEach
                val pos = ent.getInterpolatedPos(event.context.tickDelta())
                WorldRenderUtils.drawWireFrame(
                    event.context,
                    box.offset(pos.x, pos.y, pos.z),
                    color,
                    8f
                )
            }
        }
    }

    @EventHandler
    fun onSlayerStart(event: SlayerBossEvents.Spawn) {
        if (event.type.contains("Demonlord")) {
            inBoss = true
            lastSpawnTime = event.timestamp
        }
    }

    @EventHandler
    fun onSlayerKill(event: SlayerBossEvents.Kill) {
        inBoss = false
    }

    @EventHandler
    fun onSlayerFail(event: SlayerBossEvents.Fail) {
        inBoss = false
    }

    @EventHandler
    fun onParticle(event: AddParticleEvent) {
        if (!DulkirConfig.configOptions.cleanBlaze) return
        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()
    }
}