blob: 0b25e4473d6b058546d1f1d6e83c8ec888002ced (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
}
}
}
|