aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt
blob: 257a2002c2613f34f13b81578f2369a3363f68c6 (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
package com.dulkirfabric.features

import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.LongUpdateEvent
import com.dulkirfabric.events.WorldRenderLastEvent
import com.dulkirfabric.util.ScoreBoardUtils
import com.dulkirfabric.util.TablistUtils
import com.dulkirfabric.util.Utils
import com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.text.Style
import net.minecraft.text.Text
import net.minecraft.util.Formatting
import net.minecraft.util.math.Vec3d

object EffigyDisplay {
    private var effigyWaypoints = arrayOf(
        Effigy(Vec3d(150.5, 76.0, 95.5)),
        Effigy(Vec3d(193.5, 90.0, 119.5)),
        Effigy(Vec3d(235.5, 107.0, 147.5)),
        Effigy(Vec3d(293.5, 93.0, 134.5)),
        Effigy(Vec3d(262.5, 96.0, 94.5)),
        Effigy(Vec3d(240.5, 126.0, 118.5))
    )

    private val c7OnlyRegex = Regex("[^c7]")

    @EventHandler
    fun onRender(event: WorldRenderLastEvent) {
        // if we have any waypoints that need rendering, Do so.
        for (effigy in effigyWaypoints) {
            if (effigy.render) {
                WorldRenderUtils.renderWaypoint(
                    Text.literal("Inactive").setStyle(Style.EMPTY.withColor(Formatting.GOLD)), event.context, effigy.coords
                )
            }
        }
    }
    @EventHandler
    fun checkEffigies(event: LongUpdateEvent) {
        if (!DulkirConfig.configOptions.inactiveEffigyDisplay) return
        if (!Utils.isInSkyblock()) return
        if (TablistUtils.area != "The Rift") {
            effigyWaypoints.forEach { it.render = false }
            return
        }
        val lines = ScoreBoardUtils.getLinesWithColor() ?: return
        if (lines.size <= 7) return
        if (!lines[3].contains("Stillgore")) return
        val effigyStatusLine = lines[6].replace(c7OnlyRegex, "").substring(1)
        if (effigyStatusLine.length != 6) return
        for (i in 0..5) {
            effigyWaypoints[i].render = (effigyStatusLine[i] == '7')
        }
    }

    /**
     * data class for storing the effigy coordinates and whether they need to be rendered
     */
    data class Effigy(val coords: Vec3d, var render: Boolean = false)
}