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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.CollectionAPI
import at.hannibal2.skyhanni.api.SkillAPI
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BESTIARY_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BINGO_GOAL_RANK
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BOTTLE_OF_JYRRE
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.COLLECTION_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DARK_CACAO_TRUFFLE
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_HEAD_FLOOR_NUMBER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_POTION_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.EDITION_NUMBER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.ENCHANTING_EXP
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.KUUDRA_KEY
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.LARVA_HOOK
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.MASTER_SKULL_TIER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.MASTER_STAR_TIER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.MINION_TIER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.NEW_YEAR_CAKE
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.PET_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.RANCHERS_BOOTS_SPEED
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKILL_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKYBLOCK_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.VACUUM_GARDEN
import at.hannibal2.skyhanni.data.PetAPI
import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.pests.PestAPI
import at.hannibal2.skyhanni.features.skillprogress.SkillProgress
import at.hannibal2.skyhanni.features.skillprogress.SkillType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ConfigUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEdition
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getNewYearCake
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getRanchersSpeed
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object ItemDisplayOverlayFeatures {
private val config get() = SkyHanniMod.feature.inventory
private val patternGroup = RepoPattern.group("inventory.item.overlay")
private val masterSkullPattern by patternGroup.pattern(
"masterskull",
"(.*)Master Skull - Tier .",
)
private val gardenVacuumPatterm by patternGroup.pattern(
"vacuum",
"§7Vacuum Bag: §6(?<amount>\\d*) Pests?",
)
private val harvestPattern by patternGroup.pattern(
"harvest",
"§7§7You may harvest §6(?<amount>.).*",
)
private val dungeonPotionPattern by patternGroup.pattern(
"dungeonpotion",
"Dungeon (?<level>.*) Potion",
)
private val bingoGoalRankPattern by patternGroup.pattern(
"bingogoalrank",
"(§.)*You were the (§.)*(?<rank>[\\w]+)(?<ordinal>(st|nd|rd|th)) (§.)*to",
)
/**
* REGEX-TEST: §7Your SkyBlock Level: §8[§a156§8]
* REGEX-TEST: §7Your SkyBlock Level: §8[§5399§8]
*/
private val skyblockLevelPattern by patternGroup.pattern(
"skyblocklevel",
"§7Your SkyBlock Level: §8\\[(?<level>§.\\d+)§8]",
)
private val bestiaryStackPattern by patternGroup.pattern(
"bestiarystack",
"§7Progress to Tier (?<tier>[\\dIVXC]+): §b[\\d.]+%",
)
/**
* REGEX-TEST: 5k Enchanting Exp
* REGEX-TEST: 5.5k Enchanting Exp
*/
private val enchantingExpPattern by patternGroup.pattern(
"enchantingexp",
"(?<exp>.*)k Enchanting Exp",
)
@SubscribeEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
event.stackTip = getStackTip(event.stack) ?: return
}
private fun getStackTip(item: ItemStack): String? {
val itemName = item.cleanName()
val internalName = item.getInternalName()
val chestName = InventoryUtils.openInventoryName()
val lore = item.getLore()
if (MASTER_STAR_TIER.isSelected()) {
when (internalName) {
"FIRST_MASTER_STAR".asInternalName() -> return "1"
"SECOND_MASTER_STAR".asInternalName() -> return "2"
"THIRD_MASTER_STAR".asInternalName() -> return "3"
"FOURTH_MASTER_STAR".asInternalName() -> return "4"
"FIFTH_MASTER_STAR".asInternalName() -> return "5"
}
}
if (MASTER_SKULL_TIER.isSelected()) {
masterSkullPattern.matchMatcher(itemName) {
return itemName.substring(itemName.length - 1)
}
}
if (DUNGEON_HEAD_FLOOR_NUMBER.isSelected() && (itemName.contains("Golden ") || itemName.contains("Diamond "))) {
when {
itemName.contains("Bonzo") -> return "1"
itemName.contains("Scarf") -> return "2"
itemName.contains("Professor") -> return "3"
itemName.contains("Thorn") -> return "4"
itemName.contains("Livid") -> return "5"
itemName.contains("Sadan") -> return "6"
itemName.contains("Necron") -> return "7"
}
}
if (NEW_YEAR_CAKE.isSelected() && internalName == "NEW_YEAR_CAKE".asInternalName()) {
val year = item.getNewYearCake()?.toString() ?: ""
return "§b$year"
}
if (PET_LEVEL.isSelected()) {
if (item.getItemCategoryOrNull() == ItemCategory.PET) {
val level = item.getPetLevel()
if (level != ItemUtils.maxPetLevel(itemName)) {
return level.toString()
}
}
}
if (MINION_TIER.isSelected() && itemName.contains(" Minion ") &&
!itemName.contains("Recipe") && lore.any { it.contains("Place this minion") }
) {
val array = itemName.split(" ")
val last = array[array.size - 1]
return last.romanToDecimal().toString()
}
if (config.displaySackName && ItemUtils.isSack(item)) {
val sackName = grabSackName(itemName)
return (if (itemName.contains("Enchanted")) "§5" else "") + sackName.substring(0, 2)
}
if (KUUDRA_KEY.isSelected() && itemName.contains("Kuudra Key")) {
return when (internalName) {
"KUUDRA_TIER_KEY".asInternalName() -> "§a1"
"KUUDRA_HOT_TIER_KEY".asInternalName() -> "§22"
"KUUDRA_BURNING_TIER_KEY".asInternalName() -> "§e3"
"KUUDRA_FIERY_TIER_KEY".asInternalName() -> "§64"
"KUUDRA_INFERNAL_TIER_KEY".asInternalName() -> "§c5"
else -> "§4?"
}
}
if (SKILL_LEVEL.isSelected() &&
InventoryUtils.openInventoryName() == "Your Skills" &&
lore.any { it.contains("Click to view!") }
) {
if (CollectionAPI.isCollectionTier0(lore)) return "0"
val split = itemName.split(" ")
if (!itemName.contains("Dungeon")) {
val skillName = split.first()
val text = split.last()
if (split.size < 2) return "0"
val level = "" + text.romanToDecimalIfNecessary()
val skill = SkillType.getByNameOrNull(skillName) ?: return level
val skillInfo = SkillAPI.storage?.get(skill) ?: return level
return if (SkillProgress.config.overflowConfig.enableInSkillMenuAsStackSize)
"" + skillInfo.overflowLevel else level
}
}
if (COLLECTION_LEVEL.isSelected() && InventoryUtils.openInventoryName().endsWith(" Collections")) {
if (lore.any { it.contains("Click to view!") }) {
if (CollectionAPI.isCollectionTier0(lore)) return "0"
val name = item.name
if (name.startsWith("§e")) {
val text = name.split(" ").last()
return "" + text.romanToDecimalIfNecessary()
}
}
}
if (RANCHERS_BOOTS_SPEED.isSelected() && internalName == "RANCHERS_BOOTS&q
|