Add custom texture pack support
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user