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
|
package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.name
import net.minecraft.item.ItemStack
object SkyBlockItemModifierUtils {
private val drillPartTypes = listOf("drill_part_upgrade_module", "drill_part_engine", "drill_part_fuel_tank")
fun ItemStack.getHotPotatoCount(): Int {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "hot_potato_count") continue
return extraAttributes.getInteger(attributes)
}
}
return 0
}
fun ItemStack.getFarmingForDummiesCount(): Int {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "farming_for_dummies_count") continue
return extraAttributes.getInteger(attributes)
}
}
return 0
}
fun ItemStack.getSilexCount(): Int {
var silexTier = 0
for ((name, amount) in getEnchantments()) {
if (name == "efficiency") {
if (amount > 5) {
silexTier = amount - 5
}
}
}
if (getInternalName() == "STONK_PICKAXE") {
silexTier--
}
return silexTier
}
fun ItemStack.getTransmissionTunerCount(): Int {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "tuned_transmission") continue
return extraAttributes.getInteger(attributes)
}
}
return 0
}
fun ItemStack.getManaDisintegrators(): Int {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "mana_disintegrator_count") continue
return extraAttributes.getInteger(attributes)
}
}
return 0
}
fun ItemStack.getMasterStars(): Int {
val stars = mapOf(
"➊" to 1,
"➋" to 2,
"➌" to 3,
"➍" to 4,
"➎" to 5,
)
val itemName = name!!
for ((icon, number) in stars) {
if (itemName.endsWith(icon)) {
return number
}
}
return 0
}
fun ItemStack.getDrillUpgrades(): List<String> {
val list = mutableListOf<String>()
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes in drillPartTypes) {
val upgradeItem = extraAttributes.getString(attributes)
list.add(upgradeItem.uppercase())
}
}
}
return list
}
fun ItemStack.getPowerScroll(): String? {
return tagCompound?.getCompoundTag("ExtraAttributes")?.getString("power_ability_scroll")
?.takeUnless { it.isBlank() }
}
fun ItemStack.getHelmetSkin(): String? {
return tagCompound?.getCompoundTag("ExtraAttributes")?.getString("skin")?.takeUnless { it.isBlank() }
}
fun ItemStack.getArmorDye(): String? {
return tagCompound?.getCompoundTag("ExtraAttributes")?.getString("dye_item")?.takeUnless { it.isBlank() }
}
fun ItemStack.getAbilityScrolls(): List<String> {
val list = mutableListOf<String>()
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes == "ability_scroll") {
val tagList = extraAttributes.getTagList(attributes, 8)
for (i in 0..3) {
val text = tagList.get(i).toString()
if (text == "END") break
var internalName = text.replace("\"", "")
list.add(internalName)
}
}
}
}
return list
}
fun ItemStack.getReforgeName(): String? {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "modifier") continue
return extraAttributes.getString(attributes)
}
}
return null
}
fun ItemStack.isRecombobulated(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("rarity_upgrades")
}
return false
}
fun ItemStack.hasJalapenoBook(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("jalapeno_count")
}
return false
}
fun ItemStack.hasEtherwarp(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("ethermerge")
}
return false
}
fun ItemStack.hasWoodSingularity(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("wood_singularity_count")
}
return false
}
fun ItemStack.hasArtOfWar(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("art_of_war_count")
}
return false
}
// TODO untested
fun ItemStack.hasBookOfStats(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("stats_book")
}
return false
}
fun ItemStack.hasArtOfPiece(): Boolean {
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
return extraAttributes.hasKey("artOfPeaceApplied")
}
return false
}
fun ItemStack.getEnchantments(): Map<String, Int> {
val map = mutableMapOf<String, Int>()
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "enchantments") continue
val enchantments = extraAttributes.getCompoundTag(attributes)
for (key in enchantments.keySet) {
map[key] = enchantments.getInteger(key)
}
}
}
return map
}
fun ItemStack.getGemstones(): List<GemstoneSlot> {
val list = mutableListOf<GemstoneSlot>()
for (tags in tagCompound.keySet) {
if (tags != "ExtraAttributes") continue
val extraAttributes = tagCompound.getCompoundTag(tags)
for (attributes in extraAttributes.keySet) {
if (attributes != "gems") continue
val gemstones = extraAttributes.getCompoundTag(attributes)
for (key in gemstones.keySet) {
if (key.endsWith("_gem")) continue
if (key == "unlocked_slots") continue
val value = gemstones.getString(key)
if (value == "") continue
val rawType = key.split("_")[0]
val type = GemstoneType.getByName(rawType)
val tier = GemstoneTier.getByName(value)
if (tier == null) {
LorenzUtils.debug("Gemstone tier is null for item $name: ('$key' = '$value')")
continue
}
if (type != null) {
list.add(GemstoneSlot(type, tier))
} else {
val newKey = gemstones.getString(key + "_gem")
val newType = GemstoneType.getByName(newKey)
if (newType == null) {
LorenzUtils.debug("Gemstone type is null for item $name: ('$newKey' with '$key' = '$value')")
continue
}
list.add(GemstoneSlot(newType, tier))
}
}
}
}
return list
}
class GemstoneSlot(val type: GemstoneType, val tier: GemstoneTier) {
fun getInternalName() = "${tier}_${type}_GEM"
}
enum class GemstoneTier(val displayName: String) {
ROUGH("Rough"),
FLAWED("Flawed"),
FINE("Fine"),
FLAWLESS("Flawless"),
PERFECT("Perfect"),
;
companion object {
fun getByName(name: String) = GemstoneTier.values().firstOrNull { it.name == name }
}
}
enum class GemstoneType(val displayName: String) {
JADE("Jade"),
AMBER("Amber"),
TOPAZ("Topaz"),
SAPPHIRE("Sapphire"),
AMETHYST("Amethyst"),
JASPER("Jasper"),
RUBY("Ruby"),
OPAL("Opal"),
;
companion object {
fun getByName(name: String) = values().firstOrNull { it.name == name }
}
}
}
|