blob: 6f2073969edbef90fdcc6b4c0ae2aadc862b3c5e (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
package at.hannibal2.skyhanni.items
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ItemDisplayOverlayFeatures {
@SubscribeEvent
fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.Post) {
val item = event.stack ?: return
if (!LorenzUtils.inSkyblock || item.stackSize != 1) return
val stackTip = getStackTip(item)
if (stackTip.isNotEmpty()) {
GlStateManager.disableLighting()
GlStateManager.disableDepth()
GlStateManager.disableBlend()
event.fr.drawStringWithShadow(
stackTip,
(event.x + 17 - event.fr.getStringWidth(stackTip)).toFloat(),
(event.y + 9).toFloat(),
16777215
)
GlStateManager.enableLighting()
GlStateManager.enableDepth()
}
}
private fun getStackTip(item: ItemStack): String {
val name = item.cleanName()
if (SkyHanniMod.feature.items.displayMasterStarNumber) {
when (name) {
"First Master Star" -> return "1"
"Second Master Star" -> return "2"
"Third Master Star" -> return "3"
"Fourth Master Star" -> return "4"
"Fifth Master Star" -> return "5"
}
}
if (SkyHanniMod.feature.items.displayMasterSkullNumber) {
if (name.matchRegex("(.*)Master Skull - Tier .")) {
return name.substring(name.length - 1)
}
}
if (SkyHanniMod.feature.items.displayDungeonHeadFloor) {
if (name.contains("Golden ") || name.contains("Diamond ")) {
when {
name.contains("Bonzo") -> return "1"
name.contains("Scarf") -> return "2"
name.contains("Professor") -> return "3"
name.contains("Thorn") -> return "4"
name.contains("Livid") -> return "5"
name.contains("Sadan") -> return "6"
name.contains("Necron") -> return "7"
}
}
}
if (SkyHanniMod.feature.items.displayNewYearCakeNumber) {
if (name.startsWith("New Year Cake (")) {
return "§b" + name.between("(Year ", ")")
}
}
if (SkyHanniMod.feature.items.displayPetLevel) {
if (ItemUtils.isPet(name)) {
val level = name.between("Lvl ", "] ").toInt()
if (level != ItemUtils.maxPetLevel(name)) {
return "$level"
}
}
}
if (SkyHanniMod.feature.items.displaySackName) {
if (ItemUtils.isSack(name)) {
val split = name.split(" ")
val sackName = split[split.size - 2]
return (if (name.contains("Enchanted")) "§5" else "") + sackName.substring(0, 2)
}
}
if (SkyHanniMod.feature.items.displayMinionTier) {
if (name.contains(" Minion ")) {
val array = name.split(" ")
val last = array[array.size - 1]
return last.romanToDecimal().toString()
}
}
return ""
}
}
|