From b68ef58d0cbc071a5b653db96f2397f49a986d1f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Sep 2022 11:34:26 +0700 Subject: [PATCH] Split datagen code to multiple files --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 531 +----------------- .../mc/otm/datagen/DecorativeData.kt | 111 ++++ .../mc/otm/datagen/blocks/BlockStates.kt | 152 +++++ .../otm/datagen/blocks/ComplexBlockStates.kt | 97 ++++ .../blocks/MatteryBlockStateProvider.kt | 150 ++--- .../mc/otm/datagen/items/ItemModels.kt | 95 ++++ .../datagen/recipes/CraftingTableRecipes.kt | 82 +-- .../otm/datagen/recipes/DecorativesRecipes.kt | 166 ++++++ .../datagen/recipes/MatteryRecipeProvider.kt | 20 +- .../otm/datagen/recipes/PlatePressRecipes.kt | 19 + 10 files changed, 763 insertions(+), 660 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt 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 04687c594..5eaa053a8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -1,11 +1,6 @@ package ru.dbotthepony.mc.otm.datagen -import net.minecraft.client.renderer.block.model.BlockModel -import net.minecraft.core.Direction -import net.minecraft.data.recipes.ShapedRecipeBuilder -import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.DyeColor import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.IronBarsBlock import net.minecraft.world.level.block.state.properties.BlockStateProperties @@ -16,10 +11,6 @@ import net.minecraftforge.fml.common.Mod import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.* -import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock -import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock -import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider @@ -30,14 +21,18 @@ import ru.dbotthepony.mc.otm.datagen.lang.AddEnglishLanguage import ru.dbotthepony.mc.otm.datagen.loot.LootTables import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider import ru.dbotthepony.mc.otm.datagen.recipes.MatteryRecipeProvider -import ru.dbotthepony.mc.otm.datagen.recipes.has import ru.dbotthepony.mc.otm.registry.* import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.blocks.addBlockStates +import ru.dbotthepony.mc.otm.datagen.blocks.addComplexBlockStates +import ru.dbotthepony.mc.otm.datagen.items.addItemModels import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.loot.addLootModifiers import ru.dbotthepony.mc.otm.datagen.loot.addLootTables import ru.dbotthepony.mc.otm.datagen.models.MatteryModelBuilder import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.addTags import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock @@ -55,37 +50,37 @@ object DataGen { private lateinit var lootModifier: LootModifiers private lateinit var languageProvider: MatteryLanguageProvider - private fun decorativeCubeAll(vararg blocks: Block) { + fun decorativeCubeAll(vararg blocks: Block) { blockModelProvider.decorativeCubeAll(*blocks) blockStateProvider.simpleBlockM(*blocks) } - private fun decorativeCubeAll(subdir: String, vararg blocks: Block) { + fun decorativeCubeAll(subdir: String, vararg blocks: Block) { blockModelProvider.decorativeCubeAll(subdir, *blocks) blockStateProvider.simpleBlockM(*blocks) } - private fun decorativeCubeAll(subdir: String, suffix: String, vararg blocks: Block) { + fun decorativeCubeAll(subdir: String, suffix: String, vararg blocks: Block) { blockModelProvider.decorativeCubeAll(subdir, suffix, *blocks) blockStateProvider.simpleBlockM(*blocks) } - private fun decorativeCubeAll(blocks: List) { + fun decorativeCubeAll(blocks: List) { blockModelProvider.decorativeCubeAll(blocks) blockStateProvider.simpleBlockM(blocks) } - private fun resourceCubeAll(vararg blocks: Block) { + fun resourceCubeAll(vararg blocks: Block) { blockModelProvider.resourceCubeAll(*blocks) blockStateProvider.simpleBlockM(*blocks) } - private fun decorativeColumn(block: Block, side: String, top: String) { + fun decorativeColumn(block: Block, side: String, top: String) { blockModelProvider.decorativeColumn(block, side, top) blockStateProvider.simpleBlockM(block) } - private fun pane(block: Block, textureSide: ResourceLocation, textureRailing: ResourceLocation) { + fun pane(block: Block, textureSide: ResourceLocation, textureRailing: ResourceLocation) { val name = block.registryName?.path ?: throw IllegalStateException("Invalid state of glass pane $block") val post = name @@ -110,10 +105,10 @@ object DataGen { } } - blockStateProvider.lambda { + blockStateProvider.exec { check(mdl_post != null) { "DataGen execution order is screwed lmaooooooo" } - with(it.getMultipartBuilder(block)) { + with(blockStateProvider.getMultipartBuilder(block)) { part().modelFile(mdl_post!!).addModel() part().modelFile(mdl_side!!).addModel().condition(IronBarsBlock.NORTH, true) part().modelFile(mdl_side!!).rotationY(90).addModel().condition(IronBarsBlock.EAST, true) @@ -127,7 +122,7 @@ object DataGen { } } - private fun decoratives(list: ColoredDecorativeBlock) { + fun decoratives(list: ColoredDecorativeBlock) { for (block in list.blocks.values) { decorativeCubeAll(block) } @@ -137,7 +132,7 @@ object DataGen { } } - private fun decoratives(list: DecorativeBlock) { + fun decoratives(list: DecorativeBlock) { for (block in list.allBlocks.values) { decorativeCubeAll(block) } @@ -147,7 +142,7 @@ object DataGen { } } - private fun decoratives(subdir: String, list: ColoredDecorativeBlock) { + fun decoratives(subdir: String, list: ColoredDecorativeBlock) { for (block in list.blocks.values) { decorativeCubeAll(subdir, block) } @@ -157,7 +152,7 @@ object DataGen { } } - private fun decoratives(subdir: String, list: DecorativeBlock) { + fun decoratives(subdir: String, list: DecorativeBlock) { for (block in list.allBlocks.values) { decorativeCubeAll(subdir, block) } @@ -167,7 +162,7 @@ object DataGen { } } - private fun decoratives(subdir: String, suffix: String, list: ColoredDecorativeBlock) { + fun decoratives(subdir: String, suffix: String, list: ColoredDecorativeBlock) { for (block in list.blocks.values) { decorativeCubeAll(subdir, suffix, block) } @@ -177,7 +172,7 @@ object DataGen { } } - private fun decoratives(subdir: String, suffix: String, list: DecorativeBlock) { + fun decoratives(subdir: String, suffix: String, list: DecorativeBlock) { for (block in list.allBlocks.values) { decorativeCubeAll(subdir, suffix, block) } @@ -221,98 +216,10 @@ object DataGen { event.generator.addProvider(true, lootTableProvider) event.generator.addProvider(true, lootModifier) - for ((color, block) in MRegistry.DECORATIVE_CRATE.allBlocks) { - if (color == null) { - blockModelProvider.decorativeCubeAll(block, "crates/crate_colorless_borderless") - } else { - blockModelProvider.decorativeCubeAll(block, "crates/crate_borderless_${color.name.lowercase()}") - } - - blockStateProvider.simpleBlockM(block) - } - - decorativeCubeAll(MBlocks.CARBON_FIBRE_BLOCK) - - decoratives(MRegistry.TRITANIUM_BLOCK) - decoratives(MRegistry.FLOOR_TILES) - decoratives(MRegistry.UNREFINED_FLOOR_TILES) - decoratives(MRegistry.VENT) - decoratives(MRegistry.VENT_ALTERNATIVE) - - blockModelProvider.decorativeGlassAll(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) - blockStateProvider.simpleBlockM(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) - - for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { - decorativeColumn(block, "stripe/${block.registryName!!.path}", "tritanium_block_${colors.first.name.lowercase()}") - } - blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_ORE) blockModelProvider.resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK) blockModelProvider.resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE) - decorativeCubeAll(MBlocks.DANGER_STRIPE_BLOCK) - decorativeColumn(MBlocks.METAL_BEAM, "metal_beam_side", "metal_beam_top") - - var labLampOn: MatteryModelBuilder? = null - var labLampOff: MatteryModelBuilder? = null - - blockModelProvider.exec { - labLampOn = it.cube( - MBlocks.LABORATORY_LAMP.registryName!!.path, - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/laboratory_lamp_front"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ) - - labLampOff = it.cube( - MBlocks.LABORATORY_LAMP.registryName!!.path + "_unlit", - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/laboratory_lamp_front_off"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ResourceLocation(MOD_ID, "block/decorative/metal_beam_top"), - ) - } - - itemModelProvider.block(MItems.LABORATORY_LAMP) - itemModelProvider.block(MItems.DANGER_STRIPE_BLOCK) - itemModelProvider.block(MItems.METAL_BEAM) - - blockStateProvider.lambda { - it.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { - return@forAllStates ConfiguredModel.builder() - .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate()) - .rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate()) - .build() - } - } - - blockModelProvider.exec { - for (crate in MRegistry.CARGO_CRATES.blocks.values) { - it.withExistingParent("${crate.registryName!!.path}_closed", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_closed")) - .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") - .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") - - it.withExistingParent("${crate.registryName!!.path}_open", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_open")) - .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") - .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") - } - } - - decorativeColumn(MBlocks.TRITANIUM_STRIPED_BLOCK, "tritanium_striped_block", "tritanium_block") - - for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks) { - val name = MRegistry.INDUSTRIAL_GLASS.allBlocks[color]!!.registryName!!.path - val textureSide = ResourceLocation(MOD_ID, "block/decorative/$name") - val textureRailing = ResourceLocation(MOD_ID, "block/decorative/industrial_glass_frame") - pane(glass, textureSide, textureRailing) - } - with(blockModelProvider) { exec { copy("block/battery/battery1", "block/battery/battery0").also { it.offset(-4f, 0f, 0f) } @@ -340,400 +247,20 @@ object DataGen { } } - with(blockStateProvider) { - block(MBlocks.BLACK_HOLE) - block(MBlocks.ANDROID_STATION) - - ore(MBlocks.DEEPSLATE_TRITANIUM_ORE) - ore(MBlocks.TRITANIUM_ORE) - ore(MBlocks.TRITANIUM_RAW_BLOCK) - - block(MBlocks.CHEMICAL_GENERATOR) - block(MBlocks.MATTER_SCANNER) - block(MBlocks.ITEM_MONITOR) - - lambda { - with(getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { - for (dir in RotatableMatteryBlock.FACING.possibleValues) { - for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, dir) - .condition(WorkerState.WORKER_STATE, enum) - .end() - } - } - - for (dir in RotatableMatteryBlock.FACING.possibleValues) { - for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, dir) - .condition(enum, false) - .end() - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, dir) - .condition(enum, true) - .end() - } - } - } - } - - block(MBlocks.MATTER_DECOMPOSER) - block(MBlocks.MATTER_REPLICATOR) - block(MBlocks.PLATE_PRESS) - block(MBlocks.GRAVITATION_STABILIZER) - block(MBlocks.GRAVITATION_STABILIZER_LENS) - - block(MBlocks.STORAGE_POWER_SUPPLIER) - block(MBlocks.MATTER_RECYCLER) - - lambda { - for (crate in MRegistry.CARGO_CRATES.allBlocks.values) { - getVariantBuilder(crate).forAllStates { - return@forAllStates arrayOf( - ConfiguredModel.builder() - .modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue(CargoCrateBlock.IS_OPEN)) "open" else "closed"}"))) - .rotationY(it.getValue(RotatableMatteryBlock.FACING).toYRotBlockstate()) - .buildLast() - ) - } - } - } - - lambda { - with(it.getMultipartBuilder(MBlocks.STORAGE_BUS)) { - for (dir in Direction.values()) { - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) - .end() - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) - .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) - .end() - } - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) - .addModel().end() - } - - with(it.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { - for (dir in Direction.values()) { - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) - .end() - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) - .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) - .end() - } - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) - .addModel().end() - } - - with(it.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { - for (dir in Direction.values()) { - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) - .end() - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) - .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) - .end() - } - - part().modelFile(models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) - .addModel().end() - } - } - } - - with(itemModelProvider) { - block(MItems.ANDROID_STATION, "android_station_working") - block(MItems.BATTERY_BANK) - block(MItems.MATTER_CAPACITOR_BANK) - block(MItems.PATTERN_STORAGE) - block(MItems.BLACK_HOLE) - block(MItems.CARBON_FIBRE_BLOCK) - block(MItems.DEEPSLATE_TRITANIUM_ORE) - block(MItems.TRITANIUM_ORE) - block(MItems.TRITANIUM_STRIPED_BLOCK) - block(MItems.TRITANIUM_RAW_BLOCK) - block(MItems.ITEM_MONITOR) - - MRegistry.VENT.allItems.values.forEach(this::block) - MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(this::block) - MRegistry.TRITANIUM_BLOCK.allItems.values.forEach(this::block) - MRegistry.INDUSTRIAL_GLASS.allItems.values.forEach(this::block) - - for (block in MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) { - block(block) - } - - for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allItems) { - generatedTranslucent(glass, ResourceLocation(MOD_ID, "block/decorative/${MRegistry.INDUSTRIAL_GLASS.allItems[color]!!.registryName!!.path}")) - } - - blocks(MRegistry.DECORATIVE_CRATE.allItems.values) - - components(MItems.DATAGEN_COMPONENTS) - - generated(MItems.PILL_ANDROID) - generated(MItems.PILL_HUMANE) - generated(MItems.PILL_OBLIVION) - generated(MItems.PILL_HEAL) - generated(MItems.NUTRIENT_PASTE) - - for (item in MItems.EXOSUIT_INVENTORY_UPGRADES) { - KOT(item) - } - - KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_CREATIVE) - KOT(MItems.EXOSUIT_CRAFTING_UPGRADE) - KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_BIG) - KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_HUGE) - - component(MItems.TRITANIUM_INGOT) - resource(MItems.TRITANIUM_ORE_CLUMP) - - generated(MItems.EXOSUIT_PROBE) - - handheld(MItems.TRITANIUM_TOOLS) - generated(MItems.TRITANIUM_ARMOR) - - generatedTiered(MItems.BATTERIES, "battery_tier") - generated(MItems.BATTERY_CREATIVE) - - generated(MItems.MATTER_CAPACITOR_BASIC, ResourceLocation(MOD_ID, "item/matter_capacitor_tier1")) - generated(MItems.MATTER_CAPACITOR_NORMAL, ResourceLocation(MOD_ID, "item/matter_capacitor_tier2")) - generated(MItems.MATTER_CAPACITOR_DENSE, ResourceLocation(MOD_ID, "item/matter_capacitor_tier3")) - generated(MItems.MATTER_CAPACITOR_CREATIVE) - - generated(MItems.QUANTUM_BATTERY) - generated(MItems.QUANTUM_CAPACITOR) - generated(MItems.QUANTUM_BATTERY_CREATIVE) - - generated(MItems.PATTERN_DRIVE_CREATIVE) - - generated(MItems.MATTER_DUST) - - for (item in MRegistry.CARGO_CRATES.allItems.values) { - block(item, "${item.registryName!!.path}_closed") - } - - block(MItems.CHEMICAL_GENERATOR, "chemical_generator_working") - block(MItems.ENERGY_COUNTER, "energy_counter_down") - block(MItems.MATTER_BOTTLER, "matter_bottler_working") - block(MItems.MATTER_CABLE, "matter_cable_core") - block(MItems.MATTER_DECOMPOSER, "matter_decomposer_working") - - block(MItems.PLATE_PRESS, "plate_press_idle") - block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") - block(MItems.MATTER_RECYCLER, "matter_recycler_working") - - block(MItems.STORAGE_BUS) - block(MItems.STORAGE_IMPORTER) - block(MItems.STORAGE_EXPORTER) - } - - blockStateProvider.lambda { provider -> - with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { - for (facing in RotatableMatteryBlock.FACING.possibleValues) { - part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) - .rotationY(facing.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, facing) - .condition(DriveViewerBlock.DRIVE_PRESENT, true) - - for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { - part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) - .rotationY(facing.toYRotBlockstate()) - .addModel() - .condition(WorkerState.SEMI_WORKER_STATE, workState) - .condition(RotatableMatteryBlock.FACING, facing) - } - } - } - - with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { - for (facing in RotatableMatteryBlock.FACING.possibleValues) { - for (i in 0 .. 7) { - part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) - .rotationY(facing.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, facing) - .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) - } - - part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) - .rotationY(facing.toYRotBlockstate()) - .addModel() - .condition(RotatableMatteryBlock.FACING, facing) - } - } - - with(provider.getMultipartBuilder(MBlocks.ENERGY_COUNTER)) { - // даваааййй - val up = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_up")) - val down = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_down")) - val west = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_west")) - val east = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_east")) - - // ДАААА ДАВАЙЙ ДАААВАААЙЙЙЙЙЙ - val north = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north")) - val north_down = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_down")) - val north_east = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_east")) - val north_west = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_west")) - val south = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south")) - val south_down = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_down")) - val south_east = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_east")) - val south_west = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west")) - - for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) { - part().modelFile(down).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir) - part().modelFile(up).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir) - } - - // низкий поклон за полностью рабочий поворот вокруг оси Z - part().modelFile(north).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) - part().modelFile(north_down).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) - part().modelFile(north_east).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.EAST) - part().modelFile(north_west).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.WEST) - - part().modelFile(south).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) - part().modelFile(south_down).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) - part().modelFile(south_east).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.EAST) - part().modelFile(south_west).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.WEST) - - for (dir in arrayOf(Direction.WEST, Direction.EAST)) { - val mdl = if (dir === Direction.WEST) west else east - - part().modelFile(mdl).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.NORTH) - part().modelFile(mdl).rotationX(-90).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) - part().modelFile(mdl).rotationX(180).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.SOUTH) - part().modelFile(mdl).rotationX(90).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) - } - } - } + addDecorativeData(blockStateProvider, itemModelProvider, blockModelProvider) + addBlockStates(blockStateProvider) + addItemModels(itemModelProvider) + blockStateProvider.exec { addComplexBlockStates(blockStateProvider) } addLootTables(lootTableProvider) - recipeProvider.lambda { _, consumer -> addCraftingTableRecipes(consumer) } - - with(recipeProvider) { - val baselineMetals = arrayOf("iron", "silver", "bronze", "lead", "constantan") - val softMetals = arrayOf("gold", "aluminum", "aluminium", "brass", "copper", "electrum") - val hardMetals = arrayOf("tritanium", "steel", "tungsten", "uranium") - - for (thing in baselineMetals) { - plate(thing) - } - - for (thing in softMetals) { - plate(thing, workTicks = 140) - } - - for (thing in hardMetals) { - plate(thing, workTicks = 300) - } - - lambda { _, consumer -> - ShapelessRecipeBuilder(MRegistry.INDUSTRIAL_GLASS.item, 8) - .requires(net.minecraft.world.item.Items.GLASS, 8) - .requires(MItemTags.PLATE_TRITANIUM) - .unlockedBy("has_plate", has(MItemTags.PLATE_TRITANIUM)) - .unlockedBy("has_glass", has(net.minecraft.world.item.Items.GLASS)) - .save(consumer) - - ShapedRecipeBuilder(MRegistry.INDUSTRIAL_GLASS_PANE.item, 16) - .define('#', MRegistry.INDUSTRIAL_GLASS.item) - .pattern("###").pattern("###") - .unlockedBy("has_tritanium_glass", has(MRegistry.INDUSTRIAL_GLASS.item)) - .save(consumer) - - val mappingUpgradeVanilla = mapOf( - DyeColor.WHITE to net.minecraft.world.item.Items.WHITE_STAINED_GLASS, - DyeColor.ORANGE to net.minecraft.world.item.Items.ORANGE_STAINED_GLASS, - DyeColor.MAGENTA to net.minecraft.world.item.Items.MAGENTA_STAINED_GLASS, - DyeColor.LIGHT_BLUE to net.minecraft.world.item.Items.LIGHT_BLUE_STAINED_GLASS, - DyeColor.YELLOW to net.minecraft.world.item.Items.YELLOW_STAINED_GLASS, - DyeColor.LIME to net.minecraft.world.item.Items.LIME_STAINED_GLASS, - DyeColor.PINK to net.minecraft.world.item.Items.PINK_STAINED_GLASS, - DyeColor.GRAY to net.minecraft.world.item.Items.GRAY_STAINED_GLASS, - DyeColor.LIGHT_GRAY to net.minecraft.world.item.Items.LIGHT_GRAY_STAINED_GLASS, - DyeColor.CYAN to net.minecraft.world.item.Items.CYAN_STAINED_GLASS, - DyeColor.PURPLE to net.minecraft.world.item.Items.PURPLE_STAINED_GLASS, - DyeColor.BLUE to net.minecraft.world.item.Items.BLUE_STAINED_GLASS, - DyeColor.BROWN to net.minecraft.world.item.Items.BROWN_STAINED_GLASS, - DyeColor.GREEN to net.minecraft.world.item.Items.GREEN_STAINED_GLASS, - DyeColor.RED to net.minecraft.world.item.Items.RED_STAINED_GLASS, - DyeColor.BLACK to net.minecraft.world.item.Items.BLACK_STAINED_GLASS, - ) - - for (color in DyeColor.values()) { - val item = MRegistry.INDUSTRIAL_GLASS.items[color]!! - val paneItem = MRegistry.INDUSTRIAL_GLASS_PANE.items[color]!! - val mappedVanilla = mappingUpgradeVanilla[color]!! - - // обычная покраска - ShapelessRecipeBuilder(item, 8) - .requires(MRegistry.INDUSTRIAL_GLASS.item, 8) - .requires(color.tag) - .unlockedBy("has_tritanium_glass", has(MRegistry.INDUSTRIAL_GLASS.item)) - .save(consumer) - - // апгрейд ванильного крашенного стекла - ShapelessRecipeBuilder(item, 8) - .requires(mappedVanilla, 8) - .requires(MItemTags.PLATE_TRITANIUM) - .unlockedBy("has_plate", has(MItemTags.PLATE_TRITANIUM)) - .unlockedBy("has_colored_glass", has(mappedVanilla)) - .save(consumer, ResourceLocation(MOD_ID, "${item.registryName!!.path}_upgrade")) - - ShapelessRecipeBuilder(paneItem, 8) - .requires(MRegistry.INDUSTRIAL_GLASS_PANE.item, 8) - .requires(color.tag) - .unlockedBy("has_tritanium_glass_pane", has(MRegistry.INDUSTRIAL_GLASS_PANE.item)) - .save(consumer) - - ShapedRecipeBuilder(paneItem, 16) - .define('#', item) - .pattern("###").pattern("###") - .unlockedBy("has_colored_tritanium_glass", has(paneItem)) - .save(consumer, ResourceLocation(MOD_ID, "${paneItem.registryName!!.path}_alt")) - } - } + recipeProvider.exec { _, consumer -> + addCraftingTableRecipes(consumer) + addDecorativesRecipes(recipeProvider, consumer) } + addPlatePressRecipes(recipeProvider) + lootModifier.lambda { addLootModifiers(it) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt new file mode 100644 index 000000000..aea07bb2b --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -0,0 +1,111 @@ +package ru.dbotthepony.mc.otm.datagen + +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.level.block.state.properties.BlockStateProperties +import net.minecraftforge.client.model.generators.ConfiguredModel +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider +import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider +import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider +import ru.dbotthepony.mc.otm.datagen.models.MatteryModelBuilder +import ru.dbotthepony.mc.otm.registry.MBlocks +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MNames +import ru.dbotthepony.mc.otm.registry.MRegistry + +fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelProvider: MatteryItemModelProvider, blockModelProvider: MatteryBlockModelProvider) { + for ((color, block) in MRegistry.DECORATIVE_CRATE.allBlocks) { + if (color == null) { + blockModelProvider.decorativeCubeAll(block, "crates/crate_colorless_borderless") + } else { + blockModelProvider.decorativeCubeAll(block, "crates/crate_borderless_${color.name.lowercase()}") + } + + blockStateProvider.simpleBlockM(block) + } + + DataGen.decorativeCubeAll(MBlocks.CARBON_FIBRE_BLOCK) + + DataGen.decoratives(MRegistry.TRITANIUM_BLOCK) + DataGen.decoratives(MRegistry.FLOOR_TILES) + DataGen.decoratives(MRegistry.UNREFINED_FLOOR_TILES) + DataGen.decoratives(MRegistry.VENT) + DataGen.decoratives(MRegistry.VENT_ALTERNATIVE) + + blockModelProvider.decorativeGlassAll(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + blockStateProvider.simpleBlockM(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { + DataGen.decorativeColumn( + block, + "stripe/${block.registryName!!.path}", + "tritanium_block_${colors.first.name.lowercase()}" + ) + } + + DataGen.decorativeCubeAll(MBlocks.DANGER_STRIPE_BLOCK) + DataGen.decorativeColumn(MBlocks.METAL_BEAM, "metal_beam_side", "metal_beam_top") + + var labLampOn: MatteryModelBuilder? = null + var labLampOff: MatteryModelBuilder? = null + + blockModelProvider.exec { + labLampOn = it.cube( + MBlocks.LABORATORY_LAMP.registryName!!.path, + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/laboratory_lamp_front"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ) + + labLampOff = it.cube( + MBlocks.LABORATORY_LAMP.registryName!!.path + "_unlit", + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/laboratory_lamp_front_off"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top"), + ) + } + + itemModelProvider.block(MItems.LABORATORY_LAMP) + itemModelProvider.block(MItems.DANGER_STRIPE_BLOCK) + itemModelProvider.block(MItems.METAL_BEAM) + + blockStateProvider.exec { + blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { + return@forAllStates ConfiguredModel.builder() + .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) + .rotationX(it[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate()) + .rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate()) + .build() + } + } + + blockModelProvider.exec { + for (crate in MRegistry.CARGO_CRATES.blocks.values) { + it.withExistingParent("${crate.registryName!!.path}_closed", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_closed")) + .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") + .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") + + it.withExistingParent("${crate.registryName!!.path}_open", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_open")) + .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") + .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") + } + } + + DataGen.decorativeColumn(MBlocks.TRITANIUM_STRIPED_BLOCK, "tritanium_striped_block", "tritanium_block") + + for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks) { + val name = MRegistry.INDUSTRIAL_GLASS.allBlocks[color]!!.registryName!!.path + val textureSide = ResourceLocation(DataGen.MOD_ID, "block/decorative/$name") + val textureRailing = ResourceLocation(DataGen.MOD_ID, "block/decorative/industrial_glass_frame") + DataGen.pane(glass, textureSide, textureRailing) + } +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt new file mode 100644 index 000000000..f454073fa --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -0,0 +1,152 @@ +package ru.dbotthepony.mc.otm.datagen.blocks + +import net.minecraft.resources.ResourceLocation +import net.minecraftforge.client.model.generators.ConfiguredModel +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.block.CableBlock +import ru.dbotthepony.mc.otm.block.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate +import ru.dbotthepony.mc.otm.datagen.toXRotBlockstateInv +import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate +import ru.dbotthepony.mc.otm.datagen.toYRotBlockstateInv +import ru.dbotthepony.mc.otm.registry.MBlocks +import ru.dbotthepony.mc.otm.registry.MRegistry + +fun addBlockStates(provider: MatteryBlockStateProvider) { + provider.block(MBlocks.BLACK_HOLE) + provider.block(MBlocks.ANDROID_STATION) + + provider.ore(MBlocks.DEEPSLATE_TRITANIUM_ORE) + provider.ore(MBlocks.TRITANIUM_ORE) + provider.ore(MBlocks.TRITANIUM_RAW_BLOCK) + + provider.block(MBlocks.CHEMICAL_GENERATOR) + provider.block(MBlocks.MATTER_SCANNER) + provider.block(MBlocks.ITEM_MONITOR) + + provider.exec { + with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { + for (dir in RotatableMatteryBlock.FACING.possibleValues) { + for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, dir) + .condition(WorkerState.WORKER_STATE, enum) + .end() + } + } + + for (dir in RotatableMatteryBlock.FACING.possibleValues) { + for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, dir) + .condition(enum, false) + .end() + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, dir) + .condition(enum, true) + .end() + } + } + } + } + + provider.block(MBlocks.MATTER_DECOMPOSER) + provider.block(MBlocks.MATTER_REPLICATOR) + provider.block(MBlocks.PLATE_PRESS) + provider.block(MBlocks.GRAVITATION_STABILIZER) + provider.block(MBlocks.GRAVITATION_STABILIZER_LENS) + + provider.block(MBlocks.STORAGE_POWER_SUPPLIER) + provider.block(MBlocks.MATTER_RECYCLER) + + provider.exec { + for (crate in MRegistry.CARGO_CRATES.allBlocks.values) { + provider.getVariantBuilder(crate).forAllStates { + return@forAllStates arrayOf( + ConfiguredModel.builder() + .modelFile(provider.models().getExistingFile( + ResourceLocation( + OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue( + CargoCrateBlock.IS_OPEN)) "open" else "closed"}") + )) + .rotationY(it.getValue(RotatableMatteryBlock.FACING).toYRotBlockstate()) + .buildLast() + ) + } + } + + with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { + for (dir in net.minecraft.core.Direction.values()) { + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) + .rotationX(dir.toXRotBlockstate()) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING_FULL, dir) + .end() + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + .rotationX(dir.toXRotBlockstateInv()) + .rotationY(dir.toYRotBlockstateInv()) + .addModel() + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .end() + } + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + .addModel().end() + } + + with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { + for (dir in net.minecraft.core.Direction.values()) { + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) + .rotationX(dir.toXRotBlockstate()) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING_FULL, dir) + .end() + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + .rotationX(dir.toXRotBlockstateInv()) + .rotationY(dir.toYRotBlockstateInv()) + .addModel() + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .end() + } + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + .addModel().end() + } + + with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { + for (dir in net.minecraft.core.Direction.values()) { + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) + .rotationX(dir.toXRotBlockstate()) + .rotationY(dir.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING_FULL, dir) + .end() + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + .rotationX(dir.toXRotBlockstateInv()) + .rotationY(dir.toYRotBlockstateInv()) + .addModel() + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .end() + } + + part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + .addModel().end() + } + } +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt new file mode 100644 index 000000000..1196a1e24 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -0,0 +1,97 @@ +package ru.dbotthepony.mc.otm.datagen.blocks + +import net.minecraft.core.Direction +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.block.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock +import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock +import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID +import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate +import ru.dbotthepony.mc.otm.registry.MBlocks + +fun addComplexBlockStates(provider: MatteryBlockStateProvider) { + with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { + for (facing in RotatableMatteryBlock.FACING.possibleValues) { + part() + .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) + .rotationY(facing.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, facing) + .condition(DriveViewerBlock.DRIVE_PRESENT, true) + + for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { + part() + .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) + .rotationY(facing.toYRotBlockstate()) + .addModel() + .condition(WorkerState.SEMI_WORKER_STATE, workState) + .condition(RotatableMatteryBlock.FACING, facing) + } + } + } + + with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { + for (facing in RotatableMatteryBlock.FACING.possibleValues) { + for (i in 0 .. 7) { + part() + .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) + .rotationY(facing.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, facing) + .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) + } + + part() + .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) + .rotationY(facing.toYRotBlockstate()) + .addModel() + .condition(RotatableMatteryBlock.FACING, facing) + } + } + + with(provider.getMultipartBuilder(MBlocks.ENERGY_COUNTER)) { + // даваааййй + val up = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_up")) + val down = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_down")) + val west = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_west")) + val east = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_east")) + + // ДАААА ДАВАЙЙ ДАААВАААЙЙЙЙЙЙ + val north = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north")) + val northDown = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_down")) + val northEast = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_east")) + val northWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_west")) + val south = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south")) + val southDown = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_down")) + val southEast = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_east")) + val southWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west")) + + for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) { + part().modelFile(down).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir) + part().modelFile(up).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir) + } + + // низкий поклон за полностью рабочий поворот вокруг оси Z + part().modelFile(north).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) + part().modelFile(northDown).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) + part().modelFile(northEast).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.EAST) + part().modelFile(northWest).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.NORTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.WEST) + + part().modelFile(south).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) + part().modelFile(southDown).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) + part().modelFile(southEast).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.EAST) + part().modelFile(southWest).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.SOUTH).condition(EnergyCounterBlock.IF_DIRECTION, Direction.WEST) + + for (dir in arrayOf(Direction.WEST, Direction.EAST)) { + val mdl = if (dir === Direction.WEST) west else east + + part().modelFile(mdl).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.NORTH) + part().modelFile(mdl).rotationX(-90).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.UP) + part().modelFile(mdl).rotationX(180).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.SOUTH) + part().modelFile(mdl).rotationX(90).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) + } + } +} \ No newline at end of file diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index 122d12205..441942236 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -13,9 +13,10 @@ import ru.dbotthepony.mc.otm.datagen.getValueNullable import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.core.registryName +import java.util.LinkedList -typealias AdvancedBlockStateFunction = (BlockState, ConfiguredModel.Builder<*>, String) -> String? -private data class AdvancedBlockStateEntry(val block: Block, val func: AdvancedBlockStateFunction) +typealias BlockStateTransform = (state: BlockState, builder: ConfiguredModel.Builder<*>, path: String) -> String? +private val EMPTY: BlockStateTransform = { _, _, _ -> null } private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String { @Suppress("NAME_SHADOWING") var modelPath = modelPath @@ -40,89 +41,100 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu return modelPath } -private typealias Lambda = (MatteryBlockStateProvider) -> Unit - class MatteryBlockStateProvider(event: GatherDataEvent) : BlockStateProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { - private val blocks = ArrayList() + private val callbacks = LinkedList<() -> Unit>() - fun block(vararg block: Block) = block.forEach { blocks.add(AdvancedBlockStateEntry(it) { _, _, _ -> null }) } - fun block(block: Block, func: AdvancedBlockStateFunction) = blocks.add(AdvancedBlockStateEntry(block, func)) + fun exec(lambda: () -> Unit): MatteryBlockStateProvider { + callbacks.add(lambda) + return this + } - fun block(blocks: List) { - for (block in blocks) { - this.blocks.add(AdvancedBlockStateEntry(block) { _, _, _ -> null }) + fun block(block: Block, func: BlockStateTransform) = exec { + getVariantBuilder(block).forAllStates { + val builder = ConfiguredModel.builder() + var modelPath = initialTransform(it, "block/${block.registryName!!.path}", builder) + modelPath = func(it, builder, modelPath) ?: modelPath + + builder.modelFile(models().getExistingFile(ResourceLocation(DataGen.MOD_ID, modelPath))) + + return@forAllStates builder.build() } } - private val simpleBlocks = ArrayList() - private val ores = ArrayList() - private val lambdas = ArrayList() + fun block(blocks: Collection): MatteryBlockStateProvider { + for (block in blocks) { + this.block(block, EMPTY) + } - fun simpleBlockM(vararg blocks: Block) { - this.simpleBlocks.addAll(blocks) + return this } - fun simpleBlockM(blocks: Collection) { - this.simpleBlocks.addAll(blocks) + fun block(vararg blocks: Block): MatteryBlockStateProvider { + for (block in blocks) { + this.block(block, EMPTY) + } + + return this } - fun ore(vararg blocks: Block) { - ores.addAll(blocks) + fun simpleBlockM(vararg blocks: Block): MatteryBlockStateProvider { + for (block in blocks) { + exec { + getVariantBuilder(block).forAllStates { + check(block.registryName != null) {"$block registry name is null!"} + return@forAllStates arrayOf(ConfiguredModel(models().getExistingFile(block.registryName))) + } + } + } + + return this } - fun lambda(lambda: Lambda) { - lambdas.add(lambda) + fun simpleBlockM(blocks: Collection): MatteryBlockStateProvider { + blocks.forEach(this::simpleBlockM) + return this + } + + fun ore(blocks: Collection): MatteryBlockStateProvider { + blocks.forEach(this::ore) + return this + } + + fun ore(vararg blocks: Block): MatteryBlockStateProvider { + for (block in blocks) { + exec { + var first = true + + getVariantBuilder(block).forAllStates { + check(first) { "$block has more than one BlockState" } + first = false + + val localModel = models().getExistingFile(block.registryName ?: throw NullPointerException("$block has no registry name")) + + val generated = ArrayList() + + for (x in intArrayOf(0, 90, 180)) { + for (y in intArrayOf(0, 90, 180, 270)) { + generated.add(with(ConfiguredModel.builder()) { + rotationX(x) + rotationY(y) + modelFile(localModel) + return@with buildLast() + }) + } + } + + return@forAllStates generated.toTypedArray() + } + } + } + + return this } override fun registerStatesAndModels() { - for (block in simpleBlocks) { - getVariantBuilder(block).forAllStates { - check(block.registryName != null) {"$block registry name is null!"} - return@forAllStates arrayOf(ConfiguredModel(models().getExistingFile(block.registryName))) - } - } - - for (block in ores) { - var first = true - - getVariantBuilder(block).forAllStates { - check(first) {"$block has more than one BlockState"} - first = false - - check(block.registryName != null) {"$block registry name is null!"} - val localModel = models().getExistingFile(block.registryName) - - val generated = ArrayList() - - for (x in arrayOf(0, 90, 180)) { - for (y in arrayOf(0, 90, 180, 270)) { - generated.add(with(ConfiguredModel.builder()) { - rotationX(x) - rotationY(y) - modelFile(localModel) - return@with buildLast() - }) - } - } - - return@forAllStates generated.toTypedArray() - } - } - - for ((block, func) in blocks) { - getVariantBuilder(block).forAllStates { - val builder = ConfiguredModel.builder() - var modelPath = initialTransform(it, "block/${block.registryName!!.path}", builder) - modelPath = func(it, builder, modelPath) ?: modelPath - - builder.modelFile(models().getExistingFile(ResourceLocation(DataGen.MOD_ID, modelPath))) - - return@forAllStates arrayOf(builder.buildLast()) - } - } - - for (lambda in lambdas) { - lambda(this) + for (callback in callbacks) { + callback.invoke() } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt new file mode 100644 index 000000000..4f18a9405 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -0,0 +1,95 @@ +package ru.dbotthepony.mc.otm.datagen.items + +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MRegistry + +fun addItemModels(provider: MatteryItemModelProvider) { + provider.block(MItems.ANDROID_STATION, "android_station_working") + provider.block(MItems.BATTERY_BANK) + provider.block(MItems.MATTER_CAPACITOR_BANK) + provider.block(MItems.PATTERN_STORAGE) + provider.block(MItems.BLACK_HOLE) + provider.block(MItems.CARBON_FIBRE_BLOCK) + provider.block(MItems.DEEPSLATE_TRITANIUM_ORE) + provider.block(MItems.TRITANIUM_ORE) + provider.block(MItems.TRITANIUM_STRIPED_BLOCK) + provider.block(MItems.TRITANIUM_RAW_BLOCK) + provider.block(MItems.ITEM_MONITOR) + + MRegistry.VENT.allItems.values.forEach(provider::block) + MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block) + MRegistry.TRITANIUM_BLOCK.allItems.values.forEach(provider::block) + MRegistry.INDUSTRIAL_GLASS.allItems.values.forEach(provider::block) + + for (block in MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) { + provider.block(block) + } + + for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allItems) { + provider.generatedTranslucent(glass, ResourceLocation(DataGen.MOD_ID, "block/decorative/${MRegistry.INDUSTRIAL_GLASS.allItems[color]!!.registryName!!.path}")) + } + + provider.blocks(MRegistry.DECORATIVE_CRATE.allItems.values) + + provider.components(MItems.DATAGEN_COMPONENTS) + + provider.generated(MItems.PILL_ANDROID) + provider.generated(MItems.PILL_HUMANE) + provider.generated(MItems.PILL_OBLIVION) + provider.generated(MItems.PILL_HEAL) + provider.generated(MItems.NUTRIENT_PASTE) + + for (item in MItems.EXOSUIT_INVENTORY_UPGRADES) { + provider.KOT(item) + } + + provider.KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_CREATIVE) + provider.KOT(MItems.EXOSUIT_CRAFTING_UPGRADE) + provider.KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_BIG) + provider.KOT(MItems.EXOSUIT_INVENTORY_UPGRADE_HUGE) + + provider.component(MItems.TRITANIUM_INGOT) + provider.resource(MItems.TRITANIUM_ORE_CLUMP) + + provider.generated(MItems.EXOSUIT_PROBE) + + provider.handheld(MItems.TRITANIUM_TOOLS) + provider.generated(MItems.TRITANIUM_ARMOR) + + provider.generatedTiered(MItems.BATTERIES, "battery_tier") + provider.generated(MItems.BATTERY_CREATIVE) + + provider.generated(MItems.MATTER_CAPACITOR_BASIC, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier1")) + provider.generated(MItems.MATTER_CAPACITOR_NORMAL, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier2")) + provider.generated(MItems.MATTER_CAPACITOR_DENSE, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier3")) + provider.generated(MItems.MATTER_CAPACITOR_CREATIVE) + + provider.generated(MItems.QUANTUM_BATTERY) + provider.generated(MItems.QUANTUM_CAPACITOR) + provider.generated(MItems.QUANTUM_BATTERY_CREATIVE) + + provider.generated(MItems.PATTERN_DRIVE_CREATIVE) + + provider.generated(MItems.MATTER_DUST) + + for (item in MRegistry.CARGO_CRATES.allItems.values) { + provider.block(item, "${item.registryName!!.path}_closed") + } + + provider.block(MItems.CHEMICAL_GENERATOR, "chemical_generator_working") + provider.block(MItems.ENERGY_COUNTER, "energy_counter_down") + provider.block(MItems.MATTER_BOTTLER, "matter_bottler_working") + provider.block(MItems.MATTER_CABLE, "matter_cable_core") + provider.block(MItems.MATTER_DECOMPOSER, "matter_decomposer_working") + + provider.block(MItems.PLATE_PRESS, "plate_press_idle") + provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") + provider.block(MItems.MATTER_RECYCLER, "matter_recycler_working") + + provider.block(MItems.STORAGE_BUS) + provider.block(MItems.STORAGE_IMPORTER) + provider.block(MItems.STORAGE_EXPORTER) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index e493dba8b..ede9927e6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.function.Consumer fun addCraftingTableRecipes(consumer: Consumer) { @@ -75,68 +76,6 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.PLATE_TRITANIUM) .build(consumer) - for ((color, item) in MRegistry.TRITANIUM_BLOCK.items) { - MatteryRecipe(item, 8) - .row(MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item) - .row(MRegistry.TRITANIUM_BLOCK.item, color.tag, MRegistry.TRITANIUM_BLOCK.item) - .row(MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item) - .unlockedBy(MRegistry.TRITANIUM_BLOCK.item) - .unlockedBy(color.tag) - .build(consumer) - } - - for ((item, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.itemsWithColor) { - val (base, stripe) = colors - - val original = MRegistry.TRITANIUM_BLOCK.items[base]!! - - MatteryRecipe(item, 8) - .row(original, original, original) - .row(original, stripe.tag, original) - .row(original, original, original) - .unlockedBy(original) - .build(consumer) - } - - MatteryRecipe(MRegistry.VENT.item, 24) - .rowB(MItemTags.PLATE_TRITANIUM) - .row(MItemTags.PLATE_TRITANIUM, Items.IRON_BARS, MItemTags.PLATE_TRITANIUM) - .rowB(MItemTags.PLATE_TRITANIUM) - .unlockedBy(MItemTags.PLATE_TRITANIUM) - .build(consumer) - - for ((color, item) in MRegistry.VENT.items) { - MatteryRecipe(item, 8) - .row(MRegistry.VENT.item, MRegistry.VENT.item, MRegistry.VENT.item) - .row(MRegistry.VENT.item, color.tag, MRegistry.VENT.item) - .row(MRegistry.VENT.item, MRegistry.VENT.item, MRegistry.VENT.item) - .unlockedBy(MItemTags.PLATE_TRITANIUM) - .unlockedBy(color.tag) - .build(consumer) - } - - for ((color, item) in MRegistry.VENT_ALTERNATIVE.allItems) { - val other = MRegistry.VENT.allItems[color]!! - ShapelessRecipeBuilder(item, 1).requires(other).unlockedBy(item).save(consumer) - ShapelessRecipeBuilder(other, 1).requires(item).unlockedBy(other).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "${other.registryName!!.path}_from_alt")) - } - - MatteryRecipe(MRegistry.DECORATIVE_CRATE.item, 24) - .rowB(MItemTags.PLATE_IRON) - .row(MItemTags.PLATE_IRON, COBBLESTONE, MItemTags.PLATE_IRON) - .rowB(MItemTags.PLATE_IRON) - .unlockedBy(MItemTags.PLATE_IRON) - .build(consumer) - - for ((color, crate) in MRegistry.DECORATIVE_CRATE.items) { - MatteryRecipe(crate, 8) - .row(MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item) - .row(MRegistry.DECORATIVE_CRATE.item, color.tag, MRegistry.DECORATIVE_CRATE.item) - .row(MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item) - .unlockedBy(MRegistry.DECORATIVE_CRATE.item) - .build(consumer) - } - // Машины MatteryRecipe(MItems.MATTER_RECYCLER) .row(MItems.MATTER_CAPACITOR_PARTS, Items.HOPPER, MItemTags.BASIC_CIRCUIT) @@ -260,25 +199,6 @@ fun addCraftingTableRecipes(consumer: Consumer) { .rowAC(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_DIAMOND) .build(consumer) - // Напольная плитка - for ((color, unrefinedItem) in MRegistry.UNREFINED_FLOOR_TILES.items) { - MatteryRecipe(unrefinedItem, 24) - .row(Items.CLAY, Items.SAND, Items.CLAY) - .row(Items.SAND, color.tag, Items.SAND) - .row(Items.CLAY, Items.SAND, Items.CLAY) - .unlockedBy(Items.CLAY) - .build(consumer) - } - - for ((color, refinedItem) in MRegistry.FLOOR_TILES.items) { - SimpleCookingRecipeBuilder.smelting( - Ingredient.of(MRegistry.UNREFINED_FLOOR_TILES.items[color]!!), - refinedItem, - 0.15f, - 200 - ).unlockedBy("has_unrefined_block", has(MRegistry.UNREFINED_FLOOR_TILES.items[color]!!)).save(consumer) - } - // станция андроида MatteryRecipe(MItems.ANDROID_STATION) .row(MItems.ELECTRIC_PARTS, MItemTags.ADVANCED_CIRCUIT, MItems.ELECTRIC_PARTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt new file mode 100644 index 000000000..7b16a0e66 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -0,0 +1,166 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.ShapedRecipeBuilder +import net.minecraft.data.recipes.ShapelessRecipeBuilder +import net.minecraft.data.recipes.SimpleCookingRecipeBuilder +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.Items +import net.minecraft.world.item.crafting.Ingredient +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MRegistry +import java.util.function.Consumer + +fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer) { + // Напольная плитка + for ((color, unrefinedItem) in MRegistry.UNREFINED_FLOOR_TILES.items) { + MatteryRecipe(unrefinedItem, 24) + .row(Items.CLAY, Items.SAND, Items.CLAY) + .row(Items.SAND, color.tag, Items.SAND) + .row(Items.CLAY, Items.SAND, Items.CLAY) + .unlockedBy(Items.CLAY) + .build(consumer) + } + + for ((color, refinedItem) in MRegistry.FLOOR_TILES.items) { + SimpleCookingRecipeBuilder.smelting( + Ingredient.of(MRegistry.UNREFINED_FLOOR_TILES.items[color]!!), + refinedItem, + 0.15f, + 200 + ).unlockedBy("has_unrefined_block", has(MRegistry.UNREFINED_FLOOR_TILES.items[color]!!)).save(consumer) + } + + for ((item, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.itemsWithColor) { + val (base, stripe) = colors + + val original = MRegistry.TRITANIUM_BLOCK.items[base]!! + + MatteryRecipe(item, 8) + .row(original, original, original) + .row(original, stripe.tag, original) + .row(original, original, original) + .unlockedBy(original) + .build(consumer) + } + + MatteryRecipe(MRegistry.VENT.item, 24) + .rowB(MItemTags.PLATE_TRITANIUM) + .row(MItemTags.PLATE_TRITANIUM, Items.IRON_BARS, MItemTags.PLATE_TRITANIUM) + .rowB(MItemTags.PLATE_TRITANIUM) + .unlockedBy(MItemTags.PLATE_TRITANIUM) + .build(consumer) + + for ((color, item) in MRegistry.VENT.items) { + MatteryRecipe(item, 8) + .row(MRegistry.VENT.item, MRegistry.VENT.item, MRegistry.VENT.item) + .row(MRegistry.VENT.item, color.tag, MRegistry.VENT.item) + .row(MRegistry.VENT.item, MRegistry.VENT.item, MRegistry.VENT.item) + .unlockedBy(MItemTags.PLATE_TRITANIUM) + .unlockedBy(color.tag) + .build(consumer) + } + + for ((color, item) in MRegistry.VENT_ALTERNATIVE.allItems) { + val other = MRegistry.VENT.allItems[color]!! + ShapelessRecipeBuilder(item, 1).requires(other).unlockedBy(item).save(consumer) + ShapelessRecipeBuilder(other, 1).requires(item).unlockedBy(other).save(consumer, ResourceLocation( + OverdriveThatMatters.MOD_ID, "${other.registryName!!.path}_from_alt")) + } + + MatteryRecipe(MRegistry.DECORATIVE_CRATE.item, 24) + .rowB(MItemTags.PLATE_IRON) + .row(MItemTags.PLATE_IRON, Tags.Items.COBBLESTONE, MItemTags.PLATE_IRON) + .rowB(MItemTags.PLATE_IRON) + .unlockedBy(MItemTags.PLATE_IRON) + .build(consumer) + + for ((color, crate) in MRegistry.DECORATIVE_CRATE.items) { + MatteryRecipe(crate, 8) + .row(MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item) + .row(MRegistry.DECORATIVE_CRATE.item, color.tag, MRegistry.DECORATIVE_CRATE.item) + .row(MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.item) + .unlockedBy(MRegistry.DECORATIVE_CRATE.item) + .build(consumer) + } + + for ((color, item) in MRegistry.TRITANIUM_BLOCK.items) { + MatteryRecipe(item, 8) + .row(MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item) + .row(MRegistry.TRITANIUM_BLOCK.item, color.tag, MRegistry.TRITANIUM_BLOCK.item) + .row(MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.item) + .unlockedBy(MRegistry.TRITANIUM_BLOCK.item) + .unlockedBy(color.tag) + .build(consumer) + } + + ShapelessRecipeBuilder(MRegistry.INDUSTRIAL_GLASS.item, 8) + .requires(Items.GLASS, 8) + .requires(MItemTags.PLATE_TRITANIUM) + .unlockedBy("has_plate", has(MItemTags.PLATE_TRITANIUM)) + .unlockedBy("has_glass", has(Items.GLASS)) + .save(consumer) + + ShapedRecipeBuilder(MRegistry.INDUSTRIAL_GLASS_PANE.item, 16) + .define('#', MRegistry.INDUSTRIAL_GLASS.item) + .pattern("###").pattern("###") + .unlockedBy("has_tritanium_glass", has(MRegistry.INDUSTRIAL_GLASS.item)) + .save(consumer) + + val mappingUpgradeVanilla = mapOf( + DyeColor.WHITE to Items.WHITE_STAINED_GLASS, + DyeColor.ORANGE to Items.ORANGE_STAINED_GLASS, + DyeColor.MAGENTA to Items.MAGENTA_STAINED_GLASS, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_STAINED_GLASS, + DyeColor.YELLOW to Items.YELLOW_STAINED_GLASS, + DyeColor.LIME to Items.LIME_STAINED_GLASS, + DyeColor.PINK to Items.PINK_STAINED_GLASS, + DyeColor.GRAY to Items.GRAY_STAINED_GLASS, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_STAINED_GLASS, + DyeColor.CYAN to Items.CYAN_STAINED_GLASS, + DyeColor.PURPLE to Items.PURPLE_STAINED_GLASS, + DyeColor.BLUE to Items.BLUE_STAINED_GLASS, + DyeColor.BROWN to Items.BROWN_STAINED_GLASS, + DyeColor.GREEN to Items.GREEN_STAINED_GLASS, + DyeColor.RED to Items.RED_STAINED_GLASS, + DyeColor.BLACK to Items.BLACK_STAINED_GLASS, + ) + + for (color in DyeColor.values()) { + val item = MRegistry.INDUSTRIAL_GLASS.items[color]!! + val paneItem = MRegistry.INDUSTRIAL_GLASS_PANE.items[color]!! + val mappedVanilla = mappingUpgradeVanilla[color]!! + + // обычная покраска + ShapelessRecipeBuilder(item, 8) + .requires(MRegistry.INDUSTRIAL_GLASS.item, 8) + .requires(color.tag) + .unlockedBy("has_tritanium_glass", has(MRegistry.INDUSTRIAL_GLASS.item)) + .save(consumer) + + // апгрейд ванильного крашенного стекла + ShapelessRecipeBuilder(item, 8) + .requires(mappedVanilla, 8) + .requires(MItemTags.PLATE_TRITANIUM) + .unlockedBy("has_plate", has(MItemTags.PLATE_TRITANIUM)) + .unlockedBy("has_colored_glass", has(mappedVanilla)) + .save(consumer, ResourceLocation(DataGen.MOD_ID, "${item.registryName!!.path}_upgrade")) + + ShapelessRecipeBuilder(paneItem, 8) + .requires(MRegistry.INDUSTRIAL_GLASS_PANE.item, 8) + .requires(color.tag) + .unlockedBy("has_tritanium_glass_pane", has(MRegistry.INDUSTRIAL_GLASS_PANE.item)) + .save(consumer) + + ShapedRecipeBuilder(paneItem, 16) + .define('#', item) + .pattern("###").pattern("###") + .unlockedBy("has_colored_tritanium_glass", has(paneItem)) + .save(consumer, ResourceLocation(DataGen.MOD_ID, "${paneItem.registryName!!.path}_alt")) + } +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 0889376e0..a115404d4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -14,11 +14,12 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe +import java.util.LinkedList import java.util.function.Consumer -private typealias RecipeLambda = (MatteryRecipeProvider, Consumer) -> Unit +private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: Consumer) -> Unit -private fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): InventoryChangeTrigger.TriggerInstance { +fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): InventoryChangeTrigger.TriggerInstance { return inventoryTrigger(ItemPredicate.Builder.item().of(p_176522_).withCount(p_176521_).build()) } @@ -41,19 +42,22 @@ fun inventoryTrigger(vararg p_126012_: ItemPredicate): InventoryChangeTrigger.Tr } class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn) { - private val lambdas = ArrayList() + private val callbacks = LinkedList() - fun lambda(lambda: RecipeLambda) = lambdas.add(lambda) + fun exec(callback: RecipeBuilderCallback): MatteryRecipeProvider { + callbacks.add(callback) + return this + } override fun buildCraftingRecipes(callback: Consumer) { - for (lambda in lambdas) { + for (lambda in callbacks) { lambda(this, callback) } } fun plate(id: String, count: Int = 1, workTicks: Int = 200) { - lambda { it, callback -> - callback.accept(PlatePressShallowFinishedRecipe( + exec { _, consumer -> + consumer.accept(PlatePressShallowFinishedRecipe( ResourceLocation(DataGen.MOD_ID, "plates/$id"), ResourceLocation("forge", "ingots/$id"), ResourceLocation("forge", "plates/$id"), @@ -64,7 +68,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat } fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200) { - lambda { it, callback -> + exec { it, callback -> callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(ResourceLocation(DataGen.MOD_ID, "plate_$id"), ingredient, result, count, workTicks))) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt new file mode 100644 index 000000000..a869b70b6 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +fun addPlatePressRecipes(provider: MatteryRecipeProvider) { + val baselineMetals = arrayOf("iron", "silver", "bronze", "lead", "constantan") + val softMetals = arrayOf("gold", "aluminum", "aluminium", "brass", "copper", "electrum") + val hardMetals = arrayOf("tritanium", "steel", "tungsten", "uranium") + + for (thing in baselineMetals) { + provider.plate(thing) + } + + for (thing in softMetals) { + provider.plate(thing, workTicks = 140) + } + + for (thing in hardMetals) { + provider.plate(thing, workTicks = 300) + } +}