From d7a444327cdd5df52791512f90d898d33d932e73 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 28 Aug 2022 12:36:00 +0700 Subject: [PATCH] Tritanium blocks, crate, vents recipes --- .../datagen/recipes/CraftingTableRecipes.kt | 77 +++++++++++++++++-- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 76 +++++++++--------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 44 +++++++++++ .../ru/dbotthepony/mc/otm/registry/Tags.kt | 1 + 4 files changed, 155 insertions(+), 43 deletions(-) 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 52d70f1cd..0eecce2cf 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 @@ -3,10 +3,14 @@ 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.tags.TagKey +import net.minecraft.world.item.Item +import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.common.Tags import net.minecraftforge.common.Tags.Items.COBBLESTONE 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.registryName import java.util.function.Consumer @@ -38,10 +42,71 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy("has_chest", has(Tags.Items.CHESTS)) .save(consumer) - MatteryRecipe(MRegistry.TRITANIUM_BLOCK.item, 24) - .rowB(MItemTags.PLATE_TRITANIUM) - .row(MItemTags.PLATE_TRITANIUM, COBBLESTONE, MItemTags.PLATE_TRITANIUM) - .rowB(MItemTags.PLATE_TRITANIUM) - .unlockedBy(MItemTags.PLATE_TRITANIUM) - .build(consumer) + for ((color, item) in MRegistry.TRITANIUM_BLOCK.mappedColoredItemsAll) { + MatteryRecipe(item, 24) + .rowAB(color?.tag, MItemTags.PLATE_TRITANIUM) + .row(MItemTags.PLATE_TRITANIUM, COBBLESTONE, MItemTags.PLATE_TRITANIUM) + .rowB(MItemTags.PLATE_TRITANIUM) + .unlockedBy(MItemTags.PLATE_TRITANIUM) + .also { if (color != null) it.unlockedBy(color.tag) } + .build(consumer) + } + + for ((color, item) in MRegistry.VENT.mappedColoredItemsAll) { + MatteryRecipe(item, 24) + .rowAB(color?.tag, MItemTags.PLATE_TRITANIUM) + .row(MItemTags.PLATE_TRITANIUM, Items.IRON_BARS, MItemTags.PLATE_TRITANIUM) + .rowB(MItemTags.PLATE_TRITANIUM) + .unlockedBy(MItemTags.PLATE_TRITANIUM) + .also { if (color != null) it.unlockedBy(color.tag) } + .build(consumer) + } + + for ((color, item) in MRegistry.VENT_ALTERNATIVE.mappedColoredItemsAll) { + val other = MRegistry.VENT.mappedColoredItemsAll[color]!! + ShapelessRecipeBuilder(item, 1).requires(other).save(consumer) + ShapelessRecipeBuilder(other, 1).requires(item).save(consumer, "${other.registryName!!.path}_from_alt") + } + + for ((crate, color) in listOf( + MItems.CRATE_RED to Tags.Items.DYES_RED, + MItems.CRATE_BLUE to Tags.Items.DYES_BLUE, + MItems.CRATE_YELLOW to Tags.Items.DYES_YELLOW, + MItems.CRATE_GREEN to Tags.Items.DYES_GREEN, + MItems.CRATE_BLACK to Tags.Items.DYES_BLACK, + MItems.CRATE_PINK to Tags.Items.DYES_PINK, + MItems.CRATE_PURPLE to Tags.Items.DYES_PURPLE, + )) { + MatteryRecipe(crate, 24) + .rowAB(color, MItemTags.PLATE_IRON) + .row(MItemTags.PLATE_IRON, COBBLESTONE, MItemTags.PLATE_IRON) + .rowB(MItemTags.PLATE_IRON) + .unlockedBy(MItemTags.PLATE_IRON) + .unlockedBy(color) + .build(consumer, crate.registryName!!.path + "_1") + + MatteryRecipe(crate, 24) + .rowBC(MItemTags.PLATE_IRON, color) + .row(MItemTags.PLATE_IRON, COBBLESTONE, MItemTags.PLATE_IRON) + .rowB(MItemTags.PLATE_IRON) + .unlockedBy(MItemTags.PLATE_IRON) + .unlockedBy(color) + .build(consumer, crate.registryName!!.path + "_2") + + MatteryRecipe(crate, 24) + .rowB(MItemTags.PLATE_IRON) + .row(MItemTags.PLATE_IRON, COBBLESTONE, MItemTags.PLATE_IRON) + .rowAB(color, MItemTags.PLATE_IRON) + .unlockedBy(MItemTags.PLATE_IRON) + .unlockedBy(color) + .build(consumer, crate.registryName!!.path + "_3") + + MatteryRecipe(crate, 24) + .rowB(MItemTags.PLATE_IRON) + .row(MItemTags.PLATE_IRON, COBBLESTONE, MItemTags.PLATE_IRON) + .rowBC(MItemTags.PLATE_IRON, color) + .unlockedBy(MItemTags.PLATE_IRON) + .unlockedBy(color) + .build(consumer, crate.registryName!!.path + "_4") + } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index 114f882d9..31db8b8f1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -4,10 +4,12 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.ShapedRecipeBuilder +import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike +import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.registryName import java.util.function.Consumer @@ -129,7 +131,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1) { } if (name != null) { - builder.save(consumer, name) + builder.save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, name)) } else { builder.save(consumer) } @@ -415,147 +417,147 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1) { return this } - fun rowA(a: Ingredient): MatteryRecipe { + fun rowA(a: Ingredient?): MatteryRecipe { return this.row(a, null as Ingredient?, null as Ingredient?) } - fun rowA(a: ItemLike): MatteryRecipe { + fun rowA(a: ItemLike?): MatteryRecipe { return this.row(a, null as ItemLike?, null as ItemLike?) } - fun rowA(a: TagKey): MatteryRecipe { + fun rowA(a: TagKey?): MatteryRecipe { return this.row(a, null as TagKey?, null as TagKey?) } - fun rowB(b: Ingredient): MatteryRecipe { + fun rowB(b: Ingredient?): MatteryRecipe { return this.row(null as Ingredient?, b, null as Ingredient?) } - fun rowB(b: ItemLike): MatteryRecipe { + fun rowB(b: ItemLike?): MatteryRecipe { return this.row(null as ItemLike?, b, null as ItemLike?) } - fun rowB(b: TagKey): MatteryRecipe { + fun rowB(b: TagKey?): MatteryRecipe { return this.row(null as TagKey?, b, null as TagKey?) } - fun rowC(c: Ingredient): MatteryRecipe { + fun rowC(c: Ingredient?): MatteryRecipe { return this.row(null as Ingredient?, null as Ingredient?, c) } - fun rowC(c: ItemLike): MatteryRecipe { + fun rowC(c: ItemLike?): MatteryRecipe { return this.row(null as ItemLike?, null as ItemLike?, c) } - fun rowC(c: TagKey): MatteryRecipe { + fun rowC(c: TagKey?): MatteryRecipe { return this.row(null as TagKey?, null as TagKey?, c) } - fun rowAB(a: Ingredient, b: Ingredient): MatteryRecipe { + fun rowAB(a: Ingredient?, b: Ingredient?): MatteryRecipe { return this.row(a, b, null as Ingredient?) } - fun rowAB(a: Ingredient, b: ItemLike): MatteryRecipe { + fun rowAB(a: Ingredient?, b: ItemLike?): MatteryRecipe { return this.row(a, b, null as Ingredient?) } - fun rowAB(a: Ingredient, b: TagKey): MatteryRecipe { + fun rowAB(a: Ingredient?, b: TagKey?): MatteryRecipe { return this.row(a, b, null as Ingredient?) } - fun rowAB(a: ItemLike, b: Ingredient): MatteryRecipe { + fun rowAB(a: ItemLike?, b: Ingredient?): MatteryRecipe { return this.row(a, b, null as ItemLike?) } - fun rowAB(a: ItemLike, b: ItemLike): MatteryRecipe { + fun rowAB(a: ItemLike?, b: ItemLike?): MatteryRecipe { return this.row(a, b, null as ItemLike?) } - fun rowAB(a: ItemLike, b: TagKey): MatteryRecipe { + fun rowAB(a: ItemLike?, b: TagKey?): MatteryRecipe { return this.row(a, b, null as ItemLike?) } - fun rowAB(a: TagKey, b: Ingredient): MatteryRecipe { + fun rowAB(a: TagKey?, b: Ingredient?): MatteryRecipe { return this.row(a, b, null as TagKey?) } - fun rowAB(a: TagKey, b: ItemLike): MatteryRecipe { + fun rowAB(a: TagKey?, b: ItemLike?): MatteryRecipe { return this.row(a, b, null as TagKey?) } - fun rowAB(a: TagKey, b: TagKey): MatteryRecipe { + fun rowAB(a: TagKey?, b: TagKey?): MatteryRecipe { return this.row(a, b, null as TagKey?) } - fun rowAC(a: Ingredient, c: Ingredient): MatteryRecipe { + fun rowAC(a: Ingredient?, c: Ingredient?): MatteryRecipe { return this.row(a, null as Ingredient?, c) } - fun rowAC(a: Ingredient, c: ItemLike): MatteryRecipe { + fun rowAC(a: Ingredient?, c: ItemLike?): MatteryRecipe { return this.row(a, null as Ingredient?, c) } - fun rowAC(a: Ingredient, c: TagKey): MatteryRecipe { + fun rowAC(a: Ingredient?, c: TagKey?): MatteryRecipe { return this.row(a, null as Ingredient?, c) } - fun rowAC(a: ItemLike, c: Ingredient): MatteryRecipe { + fun rowAC(a: ItemLike?, c: Ingredient?): MatteryRecipe { return this.row(a, null as ItemLike?, c) } - fun rowAC(a: ItemLike, c: ItemLike): MatteryRecipe { + fun rowAC(a: ItemLike?, c: ItemLike?): MatteryRecipe { return this.row(a, null as ItemLike?, c) } - fun rowAC(a: ItemLike, c: TagKey): MatteryRecipe { + fun rowAC(a: ItemLike?, c: TagKey?): MatteryRecipe { return this.row(a, null as ItemLike?, c) } - fun rowAC(a: TagKey, c: Ingredient): MatteryRecipe { + fun rowAC(a: TagKey?, c: Ingredient?): MatteryRecipe { return this.row(a, null as TagKey?, c) } - fun rowAC(a: TagKey, c: ItemLike): MatteryRecipe { + fun rowAC(a: TagKey?, c: ItemLike?): MatteryRecipe { return this.row(a, null as TagKey?, c) } - fun rowAC(a: TagKey, c: TagKey): MatteryRecipe { + fun rowAC(a: TagKey?, c: TagKey?): MatteryRecipe { return this.row(a, null as TagKey?, c) } - fun rowBC(b: Ingredient, c: Ingredient): MatteryRecipe { + fun rowBC(b: Ingredient?, c: Ingredient?): MatteryRecipe { return this.row(null as Ingredient?, b, c) } - fun rowBC(b: Ingredient, c: ItemLike): MatteryRecipe { + fun rowBC(b: Ingredient?, c: ItemLike?): MatteryRecipe { return this.row(null as Ingredient?, b, c) } - fun rowBC(b: Ingredient, c: TagKey): MatteryRecipe { + fun rowBC(b: Ingredient?, c: TagKey?): MatteryRecipe { return this.row(null as Ingredient?, b, c) } - fun rowBC(b: ItemLike, c: Ingredient): MatteryRecipe { + fun rowBC(b: ItemLike?, c: Ingredient?): MatteryRecipe { return this.row(null as ItemLike?, b, c) } - fun rowBC(b: ItemLike, c: ItemLike): MatteryRecipe { + fun rowBC(b: ItemLike?, c: ItemLike?): MatteryRecipe { return this.row(null as ItemLike?, b, c) } - fun rowBC(b: ItemLike, c: TagKey): MatteryRecipe { + fun rowBC(b: ItemLike?, c: TagKey?): MatteryRecipe { return this.row(null as ItemLike?, b, c) } - fun rowBC(b: TagKey, c: Ingredient): MatteryRecipe { + fun rowBC(b: TagKey?, c: Ingredient?): MatteryRecipe { return this.row(null as TagKey?, b, c) } - fun rowBC(b: TagKey, c: ItemLike): MatteryRecipe { + fun rowBC(b: TagKey?, c: ItemLike?): MatteryRecipe { return this.row(null as TagKey?, b, c) } - fun rowBC(b: TagKey, c: TagKey): MatteryRecipe { + fun rowBC(b: TagKey?, c: TagKey?): MatteryRecipe { return this.row(null as TagKey?, b, c) } } 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 d0bea9b82..81fedc8b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -348,6 +348,50 @@ class DecorativeBlock( val block: Block get() = _block.get() val item: Item get() = _item.get() + val mappedColoredBlocksAll: Map by lazy { + LazyMap( + null to _block::get, + DyeColor.WHITE to _whiteBlock::get, + DyeColor.ORANGE to _orangeBlock::get, + DyeColor.MAGENTA to _magentaBlock::get, + DyeColor.LIGHT_BLUE to _lightBlueBlock::get, + DyeColor.YELLOW to _yellowBlock::get, + DyeColor.LIME to _limeBlock::get, + DyeColor.PINK to _pinkBlock::get, + DyeColor.GRAY to _grayBlock::get, + DyeColor.LIGHT_GRAY to _lightGrayBlock::get, + DyeColor.CYAN to _cyanBlock::get, + DyeColor.PURPLE to _purpleBlock::get, + DyeColor.BLUE to _blueBlock::get, + DyeColor.BROWN to _brownBlock::get, + DyeColor.GREEN to _greenBlock::get, + DyeColor.RED to _redBlock::get, + DyeColor.BLACK to _blackBlock::get, + ) + } + + val mappedColoredItemsAll: Map by lazy { + LazyMap( + null to _item::get, + DyeColor.WHITE to _whiteItem::get, + DyeColor.ORANGE to _orangeItem::get, + DyeColor.MAGENTA to _magentaItem::get, + DyeColor.LIGHT_BLUE to _lightBlueItem::get, + DyeColor.YELLOW to _yellowItem::get, + DyeColor.LIME to _limeItem::get, + DyeColor.PINK to _pinkItem::get, + DyeColor.GRAY to _grayItem::get, + DyeColor.LIGHT_GRAY to _lightGrayItem::get, + DyeColor.CYAN to _cyanItem::get, + DyeColor.PURPLE to _purpleItem::get, + DyeColor.BLUE to _blueItem::get, + DyeColor.BROWN to _brownItem::get, + DyeColor.GREEN to _greenItem::get, + DyeColor.RED to _redItem::get, + DyeColor.BLACK to _blackItem::get, + ) + } + val blocks: List by lazy { LazyList( _block::get, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index a3cc9115d..d4511b099 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object MItemTags { val INGOT_TRITANIUM: TagKey = ItemTags.create(ResourceLocation("forge", "ingots/tritanium")) val PLATE_TRITANIUM: TagKey = ItemTags.create(ResourceLocation("forge", "plates/tritanium")) + val PLATE_IRON: TagKey = ItemTags.create(ResourceLocation("forge", "plates/iron")) val TRITANIUM_CRATES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium_crates")) val INDUSTRIAL_GLASS: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) }