aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt
blob: 68a86599c6567a54c647e71b4aea665023d3bcf3 (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
package dulkirmod.features.dungeons

import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.DulkirConfig
import dulkirmod.utils.ScoreBoardUtils
import dulkirmod.utils.TabListUtils
import dulkirmod.utils.WorldRenderUtils
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object ArcherHighlight {
    /**The following code is broken but interesting because with SBA it makes RGB PEOPLE
    @SubscribeEvent
    fun onRenderLiving(event: RenderLivingEvent.Pre<*>) {
        if (!DulkirConfig.archerBox) return
        if (TabListUtils.area != "Dungeon") return
        if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return
        if (event.entity !is EntityPlayer) return
        val name = event.entity.name ?: return
        if (name != TabListUtils.archerName) return
        if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return
        if (mc.thePlayer.name == name) return
        val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z)
        WorldRenderUtils.drawCustomBox(
            x - .5,
            1.0,
            y,
            2.0,
            z - .5,
            1.0,
            DulkirConfig.archBoxColor.toJavaColor(),
            3f,
            phase = false
        )
    }
    */

    @SubscribeEvent
    fun onRenderWorldLast(event: RenderWorldLastEvent) {
        if (!DulkirConfig.archerBox) return
        if (TabListUtils.area != "Dungeon") return
        if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return
        val players = mc.theWorld.playerEntities.filterNotNull()
        players.forEach {
            val name = it.name ?: return@forEach
            if (name != TabListUtils.archerName) return@forEach
            if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return@forEach
            if (mc.thePlayer.name == name) return@forEach
            val x = it.lastTickPosX + ((it.posX - it.lastTickPosX) * event.partialTicks)
            val y = it.lastTickPosY + ((it.posY - it.lastTickPosY) * event.partialTicks)
            val z = it.lastTickPosZ + ((it.posZ - it.lastTickPosZ) * event.partialTicks)
            WorldRenderUtils.drawCustomBox(
                x - .5,
                1.0,
                y,
                2.0,
                z - .5,
                1.0,
                DulkirConfig.archBoxColor.toJavaColor(),
                3f,
                phase = false
            )
        }
    }
}