Handheld models
This commit is contained in:
parent
f92dd0ad9e
commit
f726a9b6d5
@ -144,7 +144,7 @@ object DataGen {
|
||||
component(Items.TRITANIUM_INGOT)
|
||||
resource(Items.TRITANIUM_ORE_CLUMP)
|
||||
|
||||
generated(*Items.TRITANIUM_TOOLS)
|
||||
handheld(*Items.TRITANIUM_TOOLS)
|
||||
|
||||
generatedTiered(Items.BATTERIES, "battery_tier")
|
||||
generated(Items.BATTERY_CREATIVE)
|
||||
|
@ -6,33 +6,45 @@ import net.minecraftforge.client.model.generators.ItemModelProvider
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent
|
||||
import ru.dbotthepony.mc.otm.datagen.DataGen
|
||||
|
||||
private data class ItemModelGenerated(val item: String, val path: ResourceLocation)
|
||||
private data class ItemModelDelegate(val item: String, val path: ResourceLocation)
|
||||
private data class SimpleItemModel(val item: String, val path: ResourceLocation)
|
||||
|
||||
class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) {
|
||||
private val generated = ArrayList<ItemModelGenerated>()
|
||||
private val delegates = ArrayList<ItemModelDelegate>()
|
||||
private val generated = ArrayList<SimpleItemModel>()
|
||||
private val handheld = ArrayList<SimpleItemModel>()
|
||||
private val delegates = ArrayList<SimpleItemModel>()
|
||||
|
||||
override fun registerModels() {
|
||||
for ((item, path) in generated) {
|
||||
withExistingParent(item, GENERATED).texture("layer0", path)
|
||||
}
|
||||
|
||||
for ((item, path) in handheld) {
|
||||
withExistingParent(item, HANDHELD).texture("layer0", path)
|
||||
}
|
||||
|
||||
for ((item, path) in delegates) {
|
||||
withExistingParent(item, path)
|
||||
}
|
||||
}
|
||||
|
||||
fun block(item: Item) = delegates.add(ItemModelDelegate(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/${item.registryName!!.path}")))
|
||||
fun block(item: Item, path: String) = delegates.add(ItemModelDelegate(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/$path")))
|
||||
fun block(item: Item) = delegates.add(SimpleItemModel(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/${item.registryName!!.path}")))
|
||||
fun block(item: Item, path: String) = delegates.add(SimpleItemModel(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/$path")))
|
||||
fun blocks(vararg items: Item) = items.forEach(this::block)
|
||||
|
||||
fun generated(item: Item, texture: ResourceLocation) {
|
||||
generated.add(ItemModelGenerated(item.registryName!!.path, texture))
|
||||
generated.add(SimpleItemModel(item.registryName!!.path, texture))
|
||||
}
|
||||
|
||||
fun handheld(item: Item, texture: ResourceLocation) {
|
||||
handheld.add(SimpleItemModel(item.registryName!!.path, texture))
|
||||
}
|
||||
|
||||
fun generated(vararg items: Item) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) }
|
||||
fun handheld(vararg items: Item) = items.forEach { handheld(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) }
|
||||
|
||||
fun generated(item: Item, prefix: String) = generated(item, ResourceLocation(DataGen.MOD_ID, "item/${prefix}${item.registryName!!.path}"))
|
||||
fun handheld(item: Item, prefix: String) = handheld(item, ResourceLocation(DataGen.MOD_ID, "item/${prefix}${item.registryName!!.path}"))
|
||||
|
||||
fun component(item: Item) = generated(item, "component/")
|
||||
fun components(vararg items: Item) = items.forEach(this::component)
|
||||
fun resource(item: Item) = generated(item, "resources/")
|
||||
@ -49,5 +61,6 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event
|
||||
|
||||
companion object {
|
||||
private val GENERATED = ResourceLocation("minecraft", "item/generated")
|
||||
private val HANDHELD = ResourceLocation("minecraft", "item/handheld")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user