From 2e571210c948d90a7d0ea8b07184102ceb401962 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 17 Feb 2024 13:36:37 +0100 Subject: Fix missing ids for runes and enchantment books --- .../features/texturepack/CustomSkyBlockTextures.kt | 2 +- .../kotlin/moe/nea/firmament/util/SkyblockId.kt | 27 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt index f363878..64dec99 100644 --- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt @@ -1,5 +1,6 @@ /* * SPDX-FileCopyrightText: 2023 Linnea Gräf + * SPDX-FileCopyrightText: 2024 Linnea Gräf * * 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() diff --git a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt index 37a1f0c..fb63eba 100644 --- a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt +++ b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt @@ -1,5 +1,6 @@ /* * SPDX-FileCopyrightText: 2023 Linnea Gräf + * SPDX-FileCopyrightText: 2024 Linnea Gräf * * 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) } } } + -- cgit