Fix missing ids for runes and enchantment books

This commit is contained in:
Linnea Gräf
2024-02-17 13:36:37 +01:00
parent a20e3696ec
commit 2e571210c9
2 changed files with 27 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
* SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -44,7 +45,6 @@ object CustomSkyBlockTextures : FirmamentFeature {
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory")
}
TickEvent.subscribe {
throw RuntimeException()
if (TConfig.cacheDuration < 1 || it.tickCount % TConfig.cacheDuration == 0) {
CustomItemModelEvent.clearCache()
skullTextureCache.clear()

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
* SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -94,12 +95,36 @@ val ItemStack.petData: HypixelPetInfo?
val ItemStack.skyBlockId: SkyblockId?
get() {
return when (val id = extraAttributes.getString("id")) {
"" -> {
null
}
"PET" -> {
petData?.skyblockId ?: SkyblockId.PET_NULL
}
// TODO: RUNE, ENCHANTED_BOOK, PARTY_HAT_CRAB{,_ANIMATED}, ABICASE
"RUNE", "UNIQUE_RUNE" -> {
val runeData = extraAttributes.getCompound("runes")
val runeKind = runeData.keys.singleOrNull()
if (runeKind == null) SkyblockId("RUNE")
else SkyblockId("${runeKind.uppercase()}_RUNE;${runeData.getInt(runeKind)}")
}
"ABICASE" -> {
SkyblockId("ABICASE_${extraAttributes.getString("model").uppercase()}")
}
"ENCHANTED_BOOK" -> {
val enchantmentData = extraAttributes.getCompound("enchantments")
val enchantName = enchantmentData.keys.singleOrNull()
if (enchantName == null) SkyblockId("ENCHANTED_BOOK")
else SkyblockId("${enchantName.uppercase()};${enchantmentData.getInt(enchantName)}")
}
// TODO: PARTY_HAT_CRAB{,_ANIMATED,_SLOTH}
else -> {
SkyblockId(id)
}
}
}