aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-25 17:34:07 +0200
committernea <nea@nea.moe>2023-07-25 17:34:07 +0200
commit0aacb6b965852647fde85045882b6aa6cf58c287 (patch)
tree4be786b2a3765ffac8f9d50fc1d311a6b11c8d69 /src/main/kotlin/moe/nea/firmament/features
parent1a07394887e546a3381cc7548b9be287671d243d (diff)
downloadFirmament-0aacb6b965852647fde85045882b6aa6cf58c287.tar.gz
Firmament-0aacb6b965852647fde85045882b6aa6cf58c287.tar.bz2
Firmament-0aacb6b965852647fde85045882b6aa6cf58c287.zip
Add custom texture pack support
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt2
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt35
2 files changed, 37 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
index 86db2f0..96222da 100644
--- a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
@@ -29,6 +29,7 @@ import moe.nea.firmament.features.inventory.CraftingOverlay
import moe.nea.firmament.features.inventory.SaveCursorPosition
import moe.nea.firmament.features.inventory.SlotLocking
import moe.nea.firmament.features.inventory.storageoverlay.StorageOverlay
+import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures
import moe.nea.firmament.features.world.FairySouls
import moe.nea.firmament.util.data.DataHolder
@@ -58,6 +59,7 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature
loadFeature(CraftingOverlay)
loadFeature(ImagePreview)
loadFeature(SaveCursorPosition)
+ loadFeature(CustomSkyBlockTextures)
if (Firmament.DEBUG) {
loadFeature(DeveloperFeatures)
loadFeature(DebugView)
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()
+ }
+ }
+}