From 07efb6ed8516352595fad0e520bea71a10117ffa Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 15 May 2022 14:13:13 +0700 Subject: [PATCH] Update datagen for previous commit --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 4 +- .../datagen/items/MatteryItemModelProvider.kt | 39 ++++++++-- .../blockstates/storage_cable.json | 74 +++++++++++++++++++ 3 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/storage_cable.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 2f4278571..f4191e5e9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -193,6 +193,8 @@ object DataGen { block(MBlocks.PLATE_PRESS) block(MBlocks.GRAVITATION_STABILIZER) block(MBlocks.GRAVITATION_STABILIZER_LENS) + + block(MBlocks.STORAGE_POWER_SUPPLIER) } with(itemModelProvider) { @@ -243,7 +245,7 @@ object DataGen { generated(MItems.PATTERN_DRIVE_CREATIVE) for (item in MItems.CARGO_CRATES) { - block(item, "${item.registryName!!.path}_closed") + // block(item, "${item.registryName!!.path}_closed") } block(MItems.CHEMICAL_GENERATOR, "chemical_generator_working") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index ac159e5f4..a52ee7320 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -4,9 +4,12 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraftforge.client.model.generators.ItemModelProvider import net.minecraftforge.forge.event.lifecycle.GatherDataEvent +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.datagen.DataGen -private data class SimpleItemModel(val item: String, val path: ResourceLocation) +private data class SimpleItemModel(val item: String, val path: ResourceLocation) { + val traceback = IllegalArgumentException("Failed to register model") +} class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { private val generated = ArrayList() @@ -14,16 +17,37 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event private val delegates = ArrayList() override fun registerModels() { - for ((item, path) in generated) { - withExistingParent(item, GENERATED).texture("layer0", path) + for (obj in generated) { + val (item, path) = obj + + try { + withExistingParent(item, GENERATED).texture("layer0", path) + } catch(err: Throwable) { + LOGGER.error(err, obj.traceback) + throw err + } } - for ((item, path) in handheld) { - withExistingParent(item, HANDHELD).texture("layer0", path) + for (obj in handheld) { + val (item, path) = obj + + try { + withExistingParent(item, HANDHELD).texture("layer0", path) + } catch(err: Throwable) { + LOGGER.error(err, obj.traceback) + throw err + } } - for ((item, path) in delegates) { - withExistingParent(item, path) + for (obj in delegates) { + val (item, path) = obj + + try { + withExistingParent(item, path) + } catch(err: Throwable) { + LOGGER.error(err, obj.traceback) + throw err + } } } @@ -77,5 +101,6 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event companion object { private val GENERATED = ResourceLocation("minecraft", "item/generated") private val HANDHELD = ResourceLocation("minecraft", "item/handheld") + private val LOGGER = LogManager.getLogger() } } diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/storage_cable.json b/src/main/resources/assets/overdrive_that_matters/blockstates/storage_cable.json new file mode 100644 index 000000000..ae8a815be --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/storage_cable.json @@ -0,0 +1,74 @@ +{ + "multipart": [ + { + "apply": { + "model": "overdrive_that_matters:block/storage_cable_core" + } + }, + + { + "when": { + "connect_south": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection" + } + }, + + { + "when": { + "connect_west": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 90 + } + }, + + { + "when": { + "connect_north": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 180 + } + }, + + { + "when": { + "connect_east": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 270 + } + }, + + { + "when": { + "connect_up": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 90 + } + }, + + { + "when": { + "connect_down": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 270 + } + } + ] +} \ No newline at end of file