blob: d542541ac12e95ccdec78d6b3ed0c7e85ec616f1 (
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
108
109
110
111
112
113
114
115
|
package at.lorenz.mod
import at.lorenz.mod.events.GuiRenderItemEvent
import at.lorenz.mod.utils.ItemUtils
import at.lorenz.mod.utils.ItemUtils.cleanName
import at.lorenz.mod.utils.LorenzDebug
import at.lorenz.mod.utils.LorenzUtils
import at.lorenz.mod.utils.LorenzUtils.between
import at.lorenz.mod.utils.LorenzUtils.matchRegex
import at.lorenz.mod.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
//TODO add
// if (!Utils.inSkyblock || item.stackSize != 1 || item.tagCompound?.hasKey("SkytilsNoItemOverlay") == true) return
if (item.stackSize != 1 || item.tagCompound?.hasKey("SkytilsNoItemOverlay") == true) 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 (LorenzMod.feature.item.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 (LorenzMod.feature.item.displayMasterSkullNumber) {
if (name.matchRegex("(.*)Master Skull - Tier .")) {
return name.substring(name.length - 1)
}
}
if (LorenzMod.feature.item.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 (LorenzMod.feature.item.displayNewYearCakeNumber) {
if (name.startsWith("New Year Cake")) {
return "§b" + name.split("(Year ", ")")[1]
}
}
if (LorenzMod.feature.item.displayPetLevel) {
if (ItemUtils.isPet(name)) {
try {
val level = name.between("Lvl ", "] ").toInt()
if (level != ItemUtils.maxPetLevel(name)) {
return "$level"
}
} catch (e: java.lang.NumberFormatException) {
e.printStackTrace()
LorenzDebug.log("name: '$name'")
LorenzUtils.warning("NumberFormatException at lorenzItemDisplayPetLevel")
}
}
}
if (LorenzMod.feature.item.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 (LorenzMod.feature.item.displayMinionTier) {
if (name.contains(" Minion ")) {
val array = name.split(" ")
val last = array[array.size - 1]
return last.romanToDecimal().toString()
}
}
return ""
}
}
|