From 0aacb6b965852647fde85045882b6aa6cf58c287 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 25 Jul 2023 17:34:07 +0200 Subject: Add custom texture pack support --- .../features/texturepack/CustomSkyBlockTextures.kt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt (limited to 'src/main/kotlin/moe/nea/firmament/features/texturepack') diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt new file mode 100644 index 0000000..0b25e44 --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt @@ -0,0 +1,35 @@ +package moe.nea.firmament.features.texturepack + +import net.minecraft.client.util.ModelIdentifier +import moe.nea.firmament.events.CustomItemModelEvent +import moe.nea.firmament.events.TickEvent +import moe.nea.firmament.features.FirmamentFeature +import moe.nea.firmament.gui.config.ManagedConfig +import moe.nea.firmament.util.extraAttributes + +object CustomSkyBlockTextures : FirmamentFeature { + override val identifier: String + get() = "custom-skyblock-textures" + + object TConfig : ManagedConfig(identifier) { + val enabled by toggle("enabled") { true } + val cacheDuration by integer("cache-duration", 0, 20) { 1 } + } + + override val config: ManagedConfig + get() = TConfig + + override fun onLoad() { + CustomItemModelEvent.subscribe { + if (!TConfig.enabled) return@subscribe + val extra = it.itemStack.extraAttributes + val id = extra.getString("id") + if (id.isNotBlank()) + it.overrideModel = ModelIdentifier("firmskyblock", id.lowercase(), "inventory") + } + TickEvent.subscribe { + if (it.tickCount % TConfig.cacheDuration == 0) + CustomItemModelEvent.clearCache() + } + } +} -- cgit