-
-
Notifications
You must be signed in to change notification settings - Fork 215
/
Copy pathFirePillarDisplay.kt
50 lines (39 loc) · 1.64 KB
/
FirePillarDisplay.kt
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
package at.hannibal2.skyhanni.features.slayer.blaze
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object FirePillarDisplay {
private val config get() = SkyHanniMod.feature.slayer.blazes
/**
* REGEX-TEST: §6§l2s §c§l8 hits
*/
private val entityNamePattern by RepoPattern.pattern(
"slayer.blaze.firepillar.entityname",
"§6§l(?<seconds>.*)s §c§l8 hits",
)
private var display = ""
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
val seconds = entityNamePattern.firstMatcher(EntityUtils.getEntities<EntityArmorStand>().map { it.name }) { group("seconds") }
display = seconds?.let {
"§cFire Pillar: §b${seconds}s"
}.orEmpty()
}
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
config.firePillarDisplayPosition.renderString(display, posLabel = "Fire Pillar")
}
fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.firePillarDisplay
}