-
-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy pathPocketSackInASackDisplay.kt
62 lines (53 loc) · 2.29 KB
/
PocketSackInASackDisplay.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
59
60
61
62
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object PocketSackInASackDisplay {
private val config get() = SkyHanniMod.feature.inventory.pocketSackInASack
private const val MAX_STITCHES = 3
@SubscribeEvent
fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) {
val stack = event.stack ?: return
if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return
if (!config.showOverlay) return
val pocketSackInASackApplied = stack.getAppliedPocketSackInASack() ?: return
val stackTip = "§a$pocketSackInASackApplied"
val x = event.x + 13
val y = event.y + 1
event.drawSlotText(x, y, stackTip, .9f)
}
@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.replaceLore) return
val itemStack = event.itemStack
val applied = itemStack.getAppliedPocketSackInASack() ?: return
if (!ItemUtils.isSack(itemStack)) return
val iterator = event.toolTip.listIterator()
var next = false
for (line in iterator) {
if (line.contains("7This sack is")) {
val color = if (applied == MAX_STITCHES) "§a" else "§b"
iterator.set("§7This sack is stitched $color$applied§7/$color$MAX_STITCHES")
next = true
continue
}
if (next) {
iterator.set("§7times with a §cPocket Sack-in-a-Sack§7.")
return
}
}
}
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(31, "misc.pocketSackInASack", "inventory.pocketSackInASack")
}
}