-
-
Notifications
You must be signed in to change notification settings - Fork 208
/
TerracottaPhase.kt
58 lines (48 loc) · 2.11 KB
/
TerracottaPhase.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
51
52
53
54
55
56
57
58
package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.entity.EntityLivingBase
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object TerracottaPhase {
private val config get() = SkyHanniMod.feature.dungeon.terracottaPhase
private var inTerracottaPhase = false
private val patternGroup = RepoPattern.group("dungeon.terracotta")
private val terracottaStartPattern by patternGroup.pattern(
"start",
"§c\\[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me\\? Sadan\\?!",
)
private val terracottaEndPattern by patternGroup.pattern(
"end",
"§c\\[BOSS] Sadan§r§f: ENOUGH!",
)
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (terracottaStartPattern.matches(event.message)) {
inTerracottaPhase = true
} else if (terracottaEndPattern.matches(event.message)) {
inTerracottaPhase = false
}
}
@SubscribeEvent(priority = EventPriority.HIGH)
fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre<EntityLivingBase>) {
if (isActive() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) {
event.cancel()
}
}
@SubscribeEvent
fun onReceiveParticle(event: ReceiveParticleEvent) {
if (isActive() && config.hideParticles) {
event.cancel()
}
}
private fun isActive() = inTerracottaPhase && isEnabled()
private fun isEnabled() = DungeonAPI.inBossRoom && DungeonAPI.getCurrentBoss() == DungeonFloor.F6
}