aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/events/CustomItemModelEvent.kt
blob: 11528fd344a5c6d9f220cdaf7b1ea7d430139218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package moe.nea.firmament.events

import net.minecraft.item.ItemStack
import net.minecraft.util.Identifier

// TODO: assert an order on these events
data class CustomItemModelEvent(
	val itemStack: ItemStack,
	var overrideModel: Identifier? = null,
) : FirmamentEvent() {
	companion object : FirmamentEventBus<CustomItemModelEvent>() {
		@JvmStatic
		fun getModelIdentifier(itemStack: ItemStack?): Identifier? {
			// TODO: Re-add memoization and add an error / warning if the model does not exist
			if (itemStack == null) return null
			return publish(CustomItemModelEvent(itemStack)).overrideModel
		}
	}

	fun overrideIfExists(overrideModel: Identifier) {
		this.overrideModel = overrideModel
	}
}