Fix up most of the remaining event handlers
[no changelog]
This commit is contained in:
@@ -16,6 +16,7 @@ import net.minecraft.client.render.RenderLayer
|
||||
import net.minecraft.client.util.ModelIdentifier
|
||||
import net.minecraft.component.type.ProfileComponent
|
||||
import net.minecraft.util.Identifier
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.events.CustomItemModelEvent
|
||||
import moe.nea.firmament.events.TickEvent
|
||||
import moe.nea.firmament.features.FirmamentFeature
|
||||
@@ -38,20 +39,21 @@ object CustomSkyBlockTextures : FirmamentFeature {
|
||||
override val config: ManagedConfig
|
||||
get() = TConfig
|
||||
|
||||
override fun onLoad() {
|
||||
CustomItemModelEvent.subscribe {
|
||||
if (!TConfig.enabled) return@subscribe
|
||||
val id = it.itemStack.skyBlockId ?: return@subscribe
|
||||
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory")
|
||||
}
|
||||
TickEvent.subscribe {
|
||||
if (TConfig.cacheDuration < 1 || it.tickCount % TConfig.cacheDuration == 0) {
|
||||
CustomItemModelEvent.clearCache()
|
||||
skullTextureCache.clear()
|
||||
}
|
||||
@Subscribe
|
||||
fun onTick(it: TickEvent) {
|
||||
if (TConfig.cacheDuration < 1 || it.tickCount % TConfig.cacheDuration == 0) {
|
||||
CustomItemModelEvent.clearCache()
|
||||
skullTextureCache.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onCustomModelId(it: CustomItemModelEvent) {
|
||||
if (!TConfig.enabled) return
|
||||
val id = it.itemStack.skyBlockId ?: return
|
||||
it.overrideModel = ModelIdentifier("firmskyblock", id.identifier.path, "inventory")
|
||||
}
|
||||
|
||||
private val skullTextureCache = mutableMapOf<IdentityCharacteristics<ProfileComponent>, Any>()
|
||||
private val sentinelPresentInvalid = Object()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user