blob: ffe6a79aef4aa983d826f8ef9fdee3600977bb77 (
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
|
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CustomTextBox {
private val config get() = SkyHanniMod.feature.gui.customTextBox
private var display = listOf<String>()
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
display = config.text.get().format()
config.text.afterChange {
display = format()
}
}
private fun String.format() = replace("&", "§").split("\\n").toList()
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!config.enabled) return
if (!LorenzUtils.inSkyBlock) return
config.position.renderStrings(display, posLabel = "Custom Text Box")
}
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(2, "misc.textBox", "gui.customTextBox")
}
}
|