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 72dc43e84..52701af48 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -55,6 +55,7 @@ import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.addTags import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock +import kotlin.properties.Delegates fun modLocation(string: String) = ResourceLocation(DataGen.MOD_ID, string) @@ -146,9 +147,9 @@ object DataGen { fun wall(block: WallBlock, sideTexture: String, topTexture: String) { val name = block.registryName?.path ?: throw IllegalStateException("Invalid state of wall block $block") - var post: ModelFile? = null - var side: ModelFile? = null - var sideTall: ModelFile? = null + var post by Delegates.notNull() + var side by Delegates.notNull() + var sideTall by Delegates.notNull() blockModelProvider.exec { post = blockModelProvider @@ -170,9 +171,9 @@ object DataGen { blockStateProvider.exec { blockStateProvider.wallBlock( block, - checkNotNull(post) { "post model is null" }, - checkNotNull(side) { "side model is null" }, - checkNotNull(sideTall) { "sideTall model is null" }, + post, + side, + sideTall, ) } } @@ -186,11 +187,11 @@ object DataGen { val noside = "${name}_noside_ne" val noside_alt = "${name}_noside_sw" - var mdl_post: ModelFile? = null - var mdl_side: ModelFile? = null - var mdl_side_alt: ModelFile? = null - var mdl_noside: ModelFile? = null - var mdl_noside_alt: ModelFile? = null + var mdl_post by Delegates.notNull() + var mdl_side by Delegates.notNull() + var mdl_side_alt by Delegates.notNull() + var mdl_noside by Delegates.notNull() + var mdl_noside_alt by Delegates.notNull() with(blockModelProvider) { exec { @@ -204,12 +205,6 @@ object DataGen { @Suppress("name_shadowing") blockStateProvider.exec { - val mdl_post = checkNotNull(mdl_post) { "mdl_post is null" } - val mdl_side = checkNotNull(mdl_side) { "mdl_side is null" } - val mdl_side_alt = checkNotNull(mdl_side_alt) { "mdl_side_alt is null" } - val mdl_noside = checkNotNull(mdl_noside) { "mdl_noside is null" } - val mdl_noside_alt = checkNotNull(mdl_noside_alt) { "mdl_noside_alt is null" } - with(blockStateProvider.getMultipartBuilder(block)) { part().modelFile(mdl_post).addModel() part().modelFile(mdl_side).addModel().condition(IronBarsBlock.NORTH, true) @@ -225,14 +220,14 @@ object DataGen { } fun door(block: Block, textureTop: ResourceLocation, textureBottom: ResourceLocation) { - var doorBottomLeft: ModelFile? = null - var doorBottomLeftOpen: ModelFile? = null - var doorBottomRight: ModelFile? = null - var doorBottomRightOpen: ModelFile? = null - var doorTopLeft: ModelFile? = null - var doorTopLeftOpen: ModelFile? = null - var doorTopRight: ModelFile? = null - var doorTopRightOpen: ModelFile? = null + var doorBottomLeft by Delegates.notNull() + var doorBottomLeftOpen by Delegates.notNull() + var doorBottomRight by Delegates.notNull() + var doorBottomRightOpen by Delegates.notNull() + var doorTopLeft by Delegates.notNull() + var doorTopLeftOpen by Delegates.notNull() + var doorTopRight by Delegates.notNull() + var doorTopRightOpen by Delegates.notNull() val doorBottomLeftName = "${block.registryName!!.path}_bl" val doorBottomLeftOpenName = "${block.registryName!!.path}_blo" @@ -256,15 +251,6 @@ object DataGen { @Suppress("name_shadowing") blockStateProvider.exec { - val doorBottomLeft = checkNotNull(doorBottomLeft) { "doorBottomLeft is null" } - val doorBottomLeftOpen = checkNotNull(doorBottomLeftOpen) { "doorBottomLeftOpen is null" } - val doorBottomRight = checkNotNull(doorBottomRight) { "doorBottomRight is null" } - val doorBottomRightOpen = checkNotNull(doorBottomRightOpen) { "doorBottomRightOpen is null" } - val doorTopLeft = checkNotNull(doorTopLeft) { "doorTopLeft is null" } - val doorTopLeftOpen = checkNotNull(doorTopLeftOpen) { "doorTopLeftOpen is null" } - val doorTopRight = checkNotNull(doorTopRight) { "doorTopRight is null" } - val doorTopRightOpen = checkNotNull(doorTopRightOpen) { "doorTopRightOpen is null" } - with(blockStateProvider.getMultipartBuilder(block)) { for (facing in DoorBlock.FACING.possibleValues) { for (hinge in DoorBlock.HINGE.possibleValues) { @@ -307,9 +293,9 @@ object DataGen { } fun trapdoor(block: Block, texture: ResourceLocation) { - var trapdoorBottom: ModelFile? = null - var trapdoorTop: ModelFile? = null - var trapdoorOpen: ModelFile? = null + var trapdoorBottom by Delegates.notNull() + var trapdoorTop by Delegates.notNull() + var trapdoorOpen by Delegates.notNull() val trapdoorBottomName = "${block.registryName!!.path}_bottom" val trapdoorTopName = "${block.registryName!!.path}_top" diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 4d4b057f4..70c2e0687 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -1,11 +1,13 @@ package ru.dbotthepony.mc.otm.datagen import net.minecraft.resources.ResourceLocation +import net.minecraft.world.level.block.PressurePlateBlock import net.minecraft.world.level.block.SlabBlock import net.minecraft.world.level.block.StairBlock import net.minecraft.world.level.block.WallBlock import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraftforge.client.model.generators.ConfiguredModel +import net.minecraftforge.client.model.generators.ModelFile import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get @@ -18,6 +20,7 @@ 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 +import kotlin.properties.Delegates fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelProvider: MatteryItemModelProvider, blockModelProvider: MatteryBlockModelProvider) { for ((color, block) in MRegistry.DECORATIVE_CRATE.allBlocks) { @@ -38,6 +41,28 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr DataGen.decorativeStairs(block as StairBlock, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path) } + for ((color, block) in MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks) { + val texture = modLocation(DataGen.DECORATIVE_BLOCK_LOCATION + "/" + MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path) + + var depressed by Delegates.notNull() + var pressed by Delegates.notNull() + + blockModelProvider.exec { + depressed = blockModelProvider.pressurePlate(block.registryName!!.path, texture) + pressed = blockModelProvider.pressurePlateDown(block.registryName!!.path + "_pressed", texture) + } + + blockStateProvider.exec { + blockStateProvider.getVariantBuilder(block) + .partialState().with(BlockStateProperties.POWERED, false).addModels(ConfiguredModel(depressed)) + .partialState().with(BlockStateProperties.POWERED, true).addModels(ConfiguredModel(pressed)) + } + } + + for (item in MRegistry.TRITANIUM_PRESSURE_PLATE.allItems.values) { + itemModelProvider.block(item) + } + for ((color, block) in MRegistry.TRITANIUM_SLAB.allBlocks) { blockStateProvider.exec { blockStateProvider.slabBlock( diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 2983c0901..dc7fcf5df 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -19,9 +19,19 @@ private fun decoratives(provider: MatteryLanguageProvider) { provider.englishColors.add(MRegistry.CARGO_CRATES, "%s Cargo Crate") provider.englishColors.add(MRegistry.DECORATIVE_CRATE, "%s Container Block") - for ((color, name) in provider.englishColors.dyeClassMapped) { - provider.english.add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate") - provider.english.add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate") + with (provider.english) { + for ((color, name) in provider.englishColors.dyeClassMapped) { + add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate") + add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Minecart with $name Cargo Crate") + + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Tritanium Pressure Plate") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description0", "Activates only if player steps on it") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description1", "High blast resistance") + } + + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Tritanium Pressure Plate") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description0", "Activates only if player steps on it") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", "High blast resistance") } provider.english.add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate") @@ -397,10 +407,6 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.TRITANIUM_TRAPDOOR, "Tritanium Trapdoor") add(MBlocks.TRITANIUM_TRAPDOOR, "description0", "High blast resistance door with redstone latch...") add(MBlocks.TRITANIUM_TRAPDOOR, "description1", "...feeling safe now?") - - add(MBlocks.TRITANIUM_PRESSURE_PLATE, "Tritanium Pressure Plate") - add(MBlocks.TRITANIUM_PRESSURE_PLATE, "description0", "Activates only if player steps on it") - add(MBlocks.TRITANIUM_PRESSURE_PLATE, "description1", "High blast resistance") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index fd7cf89e4..7049d59e8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -61,7 +61,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.METAL_BEAM) lootTables.dropsSelf(MBlocks.TRITANIUM_TRAPDOOR) - lootTables.dropsSelf(MBlocks.TRITANIUM_PRESSURE_PLATE) + lootTables.dropsSelf(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values) lootTables.blockSimple(MBlocks.PHANTOM_ATTRACTOR) { it.add(LootItem.lootTableItem(MBlocks.PHANTOM_ATTRACTOR) 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 30a48962a..be5dd1ef5 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 @@ -4,6 +4,7 @@ import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.ShapedRecipeBuilder import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.tags.ItemTags +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient @@ -67,11 +68,19 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MBlocks.TRITANIUM_PRESSURE_PLATE) + MatteryRecipe(MRegistry.TRITANIUM_PRESSURE_PLATE.item) .row(MItemTags.TRITANIUM_PLATES, MItemTags.BASIC_CIRCUIT, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) + for (dye in DyeColor.values()) { + ShapelessRecipeBuilder(MRegistry.TRITANIUM_PRESSURE_PLATE.getItem(dye), 1) + .requires(Ingredient.of(MRegistry.TRITANIUM_PRESSURE_PLATE.allItems.entries.stream().filter { it.key != dye }.map { ItemStack(it.value) })) + .requires(dye.tag) + .unlockedBy(MItemTags.TRITANIUM_PLATES) + .save(consumer) + } + MatteryRecipe(MBlocks.PLATE_PRESS) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 2f5ac4ee6..4056bba01 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -72,6 +72,8 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.appender(ItemTags.TRAPDOORS).add(MItems.TRITANIUM_TRAPDOOR) tagsProvider.blocks.appender(BlockTags.TRAPDOORS).add(MBlocks.TRITANIUM_TRAPDOOR) + tagsProvider.blocks.appender(BlockTags.PRESSURE_PLATES).add(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values) + tagsProvider.items.appender(MItemTags.MACHINES).add(MItems.MACHINES) tagsProvider.blocks.appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it as? BlockItem }.filter { it != null }.map { it!!.block }) @@ -124,7 +126,6 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.TRITANIUM_DOOR, MBlocks.TRITANIUM_TRAPDOOR, - MBlocks.TRITANIUM_PRESSURE_PLATE, MBlocks.TRITANIUM_INGOT_BLOCK, ), Tiers.IRON) @@ -145,6 +146,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_BLOCK.allBlocks.values, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_SLAB.allBlocks.values, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_WALL.allBlocks.values, Tiers.IRON) + tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STAIRS.allBlocks.values, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_BLOCK.flatBlocks, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.TRITANIUM_STRIPED_STAIRS.flatBlocks, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt index 9792bd6a6..abc9fd9ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt @@ -21,7 +21,7 @@ import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate : BasePressurePlateBlock(Properties.of(Material.METAL, DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index 07f1bcd44..f80597e91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -156,9 +156,9 @@ object MBlocks { } } } - val TRITANIUM_PRESSURE_PLATE: Block by registry.register(MNames.TRITANIUM_PRESSURE_PLATE) { TritaniumPressurePlate() } - init { + MRegistry.TRITANIUM_PRESSURE_PLATE.registerBlocks(registry) + MRegistry.CARGO_CRATES.registerBlocks(registry) MRegistry.TRITANIUM_BLOCK.registerBlocks(registry) MRegistry.TRITANIUM_STAIRS.registerBlocks(registry) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index 4e7278af8..76adc6f16 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -236,7 +236,10 @@ object MItems { val TRITANIUM_DOOR: Item by registry.register(MNames.TRITANIUM_DOOR) { DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR, DEFAULT_PROPERTIES_DECORATIVE) } val TRITANIUM_TRAPDOOR: Item by registry.register(MNames.TRITANIUM_TRAPDOOR) { BlockItem(MBlocks.TRITANIUM_TRAPDOOR, DEFAULT_PROPERTIES_DECORATIVE) } - val TRITANIUM_PRESSURE_PLATE: Item by registry.register(MNames.TRITANIUM_PRESSURE_PLATE) { BlockItem(MBlocks.TRITANIUM_PRESSURE_PLATE, DEFAULT_PROPERTIES_DECORATIVE) } + + init { + MRegistry.TRITANIUM_PRESSURE_PLATE.registerItems(registry) + } // components val MATTER_IO_PORT: Item by registry.register(MNames.MATTER_IO_PORT) { Item(DEFAULT_PROPERTIES) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index 903d07f2e..d9864f88c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature import ru.dbotthepony.mc.otm.block.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.ImpreciseFraction import ru.dbotthepony.mc.otm.item.EnergySwordItem @@ -150,6 +151,8 @@ object MRegistry { WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!)) }) + val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) + val VENT = DecorativeBlock.simple(MNames.VENT, { BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT)