From b4b0afa9d558ded04e1f142a21b7335aa950afb1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Sep 2022 16:14:28 +0700 Subject: [PATCH] Housekeep remaining tags, correct recipes --- .../datagen/recipes/CraftingTableRecipes.kt | 7 +-- .../datagen/recipes/MatteryRecipeProvider.kt | 19 ++++++-- .../otm/datagen/recipes/ShapelessRecipes.kt | 6 ++- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 5 ++ .../ru/dbotthepony/mc/otm/registry/Tags.kt | 46 +++++++++++++++++++ .../tags/items/industrial_glass.json | 40 ---------------- .../tags/items/tritanium_crates.json | 22 --------- 7 files changed, 74 insertions(+), 71 deletions(-) delete mode 100644 src/main/resources/data/overdrive_that_matters/tags/items/industrial_glass.json delete mode 100644 src/main/resources/data/overdrive_that_matters/tags/items/tritanium_crates.json 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 015b1f65e..cc5fcb910 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.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.common.Tags @@ -28,9 +29,9 @@ fun addCraftingTableRecipes(consumer: Consumer) { .save(consumer) ShapelessRecipeBuilder(crate, 1) - .requires(Ingredient.of(MItemTags.CARGO_CRATES), 1) - .requires(Ingredient.of(dye.tag), 1) - .unlockedBy("has_tritanium_crate", has(MItemTags.CARGO_CRATES)) + .requires(Ingredient.of(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { ItemStack(it.value) })) + .requires(dye.tag) + .unlockedBy(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { it.value }) .save(consumer, "${crate.registryName}_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 fb57bb1ef..f985ee946 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 @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import java.util.LinkedList import java.util.function.Consumer +import java.util.stream.Stream private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: Consumer) -> Unit @@ -43,13 +44,23 @@ fun inventoryTrigger(vararg p_126012_: ItemPredicate): InventoryChangeTrigger.Tr ) } -fun RecipeBuilder.unlockedBy(item: ItemLike): RecipeBuilder { +fun T.unlockedBy(item: ItemLike): T { val location = item.asItem().registryName!! - return unlockedBy("has_${location.namespace}_${location.path}", has(item)) + unlockedBy("has_${location.namespace}_${location.path}", has(item)) + return this } -fun RecipeBuilder.unlockedBy(item: TagKey): RecipeBuilder { - return unlockedBy("has_${item.location.namespace}_${item.location.path}", has(item)) +fun T.unlockedBy(item: Stream): T { + for (value in item) { + unlockedBy(value) + } + + return this +} + +fun T.unlockedBy(item: TagKey): T { + unlockedBy("has_${item.location.namespace}_${item.location.path}", has(item)) + return this } class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt index fb9d37a4a..72fb7f8b0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt @@ -3,7 +3,9 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.ShapelessRecipeBuilder 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 import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags @@ -21,9 +23,9 @@ fun addShapelessRecipes(consumer: Consumer) { .save(consumer) ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[color]!!, 1) - .requires(MItemTags.MINECART_CARGO_CRATES) + .requires(Ingredient.of(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { ItemStack(it.value) })) .requires(color.tag) - .unlockedBy(MItemTags.MINECART_CARGO_CRATES) + .unlockedBy(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { it.value }) .save(consumer, modLocation(MItems.CARGO_CRATE_MINECARTS[color]!!.registryName!!.path + "_alt")) } 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 3dbe5469e..0c02975ec 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 @@ -4,6 +4,7 @@ import net.minecraft.world.effect.MobEffects import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Items import net.minecraft.world.item.Tiers +import ru.dbotthepony.mc.otm.registry.MBlockTags import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems @@ -57,6 +58,10 @@ fun addTags(tagsProvider: TagsProvider) { MRegistry.INDUSTRIAL_GLASS.forEachBlock { s, _, block -> tagsProvider.blocks.forge("hardened_glass/$s").add(block) } MRegistry.INDUSTRIAL_GLASS_PANE.forEachBlock { s, _, block -> tagsProvider.blocks.forge("hardened_glass_panes/$s").add(block) } + tagsProvider.items.appender(MItemTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allItems.values) + tagsProvider.blocks.appender(MBlockTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + tagsProvider.blocks.appender(MBlockTags.CARGO_CRATES).add(MRegistry.CARGO_CRATES.allBlocks.values) + tagsProvider.requiresPickaxe(listOf( MBlocks.ANDROID_STATION, MBlocks.BATTERY_BANK, 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 d7cc5bc49..b64eb2005 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -1,9 +1,11 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.BlockTags import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey import net.minecraft.world.item.Item +import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.OverdriveThatMatters @Suppress("unused") @@ -62,3 +64,47 @@ object MItemTags { val HARDENED_GLASS_WHITE: TagKey = ItemTags.create(ResourceLocation("forge", "hardened_glass/white")) val HARDENED_GLASS_YELLOW: TagKey = ItemTags.create(ResourceLocation("forge", "hardened_glass/yellow")) } + +@Suppress("unused") +object MBlockTags { + val CARGO_CRATES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) + val INDUSTRIAL_GLASS: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) + + val HARDENED_GLASS_PANES: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes")) + val HARDENED_GLASS_PANES_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black")) + val HARDENED_GLASS_PANES_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue")) + val HARDENED_GLASS_PANES_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/brown")) + val HARDENED_GLASS_PANES_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/colorless")) + val HARDENED_GLASS_PANES_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/cyan")) + val HARDENED_GLASS_PANES_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/gray")) + val HARDENED_GLASS_PANES_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/green")) + val HARDENED_GLASS_PANES_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_blue")) + val HARDENED_GLASS_PANES_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/light_gray")) + val HARDENED_GLASS_PANES_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/lime")) + val HARDENED_GLASS_PANES_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/magenta")) + val HARDENED_GLASS_PANES_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/orange")) + val HARDENED_GLASS_PANES_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/pink")) + val HARDENED_GLASS_PANES_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/purple")) + val HARDENED_GLASS_PANES_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/red")) + val HARDENED_GLASS_PANES_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/white")) + val HARDENED_GLASS_PANES_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/yellow")) + + val HARDENED_GLASS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass")) + val HARDENED_GLASS_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/black")) + val HARDENED_GLASS_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/blue")) + val HARDENED_GLASS_BROWN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/brown")) + val HARDENED_GLASS_COLORLESS: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/colorless")) + val HARDENED_GLASS_CYAN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/cyan")) + val HARDENED_GLASS_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/gray")) + val HARDENED_GLASS_GREEN: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/green")) + val HARDENED_GLASS_LIGHT_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_blue")) + val HARDENED_GLASS_LIGHT_GRAY: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/light_gray")) + val HARDENED_GLASS_LIME: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/lime")) + val HARDENED_GLASS_MAGENTA: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/magenta")) + val HARDENED_GLASS_ORANGE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/orange")) + val HARDENED_GLASS_PINK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/pink")) + val HARDENED_GLASS_PURPLE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/purple")) + val HARDENED_GLASS_RED: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/red")) + val HARDENED_GLASS_WHITE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/white")) + val HARDENED_GLASS_YELLOW: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass/yellow")) +} diff --git a/src/main/resources/data/overdrive_that_matters/tags/items/industrial_glass.json b/src/main/resources/data/overdrive_that_matters/tags/items/industrial_glass.json deleted file mode 100644 index 84db7d0a1..000000000 --- a/src/main/resources/data/overdrive_that_matters/tags/items/industrial_glass.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "replace": false, - "values": [ - "overdrive_that_matters:industrial_glass", - "overdrive_that_matters:industrial_glass_pane", - - "overdrive_that_matters:industrial_glass_white", - "overdrive_that_matters:industrial_glass_pane_white", - "overdrive_that_matters:industrial_glass_orange", - "overdrive_that_matters:industrial_glass_pane_orange", - "overdrive_that_matters:industrial_glass_magenta", - "overdrive_that_matters:industrial_glass_pane_magenta", - "overdrive_that_matters:industrial_glass_light_blue", - "overdrive_that_matters:industrial_glass_pane_light_blue", - "overdrive_that_matters:industrial_glass_yellow", - "overdrive_that_matters:industrial_glass_pane_yellow", - "overdrive_that_matters:industrial_glass_lime", - "overdrive_that_matters:industrial_glass_pane_lime", - "overdrive_that_matters:industrial_glass_pink", - "overdrive_that_matters:industrial_glass_pane_pink", - "overdrive_that_matters:industrial_glass_gray", - "overdrive_that_matters:industrial_glass_pane_gray", - "overdrive_that_matters:industrial_glass_light_gray", - "overdrive_that_matters:industrial_glass_pane_light_gray", - "overdrive_that_matters:industrial_glass_cyan", - "overdrive_that_matters:industrial_glass_pane_cyan", - "overdrive_that_matters:industrial_glass_purple", - "overdrive_that_matters:industrial_glass_pane_purple", - "overdrive_that_matters:industrial_glass_blue", - "overdrive_that_matters:industrial_glass_pane_blue", - "overdrive_that_matters:industrial_glass_brown", - "overdrive_that_matters:industrial_glass_pane_brown", - "overdrive_that_matters:industrial_glass_green", - "overdrive_that_matters:industrial_glass_pane_green", - "overdrive_that_matters:industrial_glass_red", - "overdrive_that_matters:industrial_glass_pane_red", - "overdrive_that_matters:industrial_glass_black", - "overdrive_that_matters:industrial_glass_pane_black" - ] -} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/tags/items/tritanium_crates.json b/src/main/resources/data/overdrive_that_matters/tags/items/tritanium_crates.json deleted file mode 100644 index 2839c849f..000000000 --- a/src/main/resources/data/overdrive_that_matters/tags/items/tritanium_crates.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "replace": false, - "values": [ - "overdrive_that_matters:cargo_crate", - "overdrive_that_matters:cargo_crate_white", - "overdrive_that_matters:cargo_crate_orange", - "overdrive_that_matters:cargo_crate_magenta", - "overdrive_that_matters:cargo_crate_light_blue", - "overdrive_that_matters:cargo_crate_yellow", - "overdrive_that_matters:cargo_crate_lime", - "overdrive_that_matters:cargo_crate_pink", - "overdrive_that_matters:cargo_crate_gray", - "overdrive_that_matters:cargo_crate_light_gray", - "overdrive_that_matters:cargo_crate_cyan", - "overdrive_that_matters:cargo_crate_purple", - "overdrive_that_matters:cargo_crate_blue", - "overdrive_that_matters:cargo_crate_brown", - "overdrive_that_matters:cargo_crate_green", - "overdrive_that_matters:cargo_crate_red", - "overdrive_that_matters:cargo_crate_black" - ] -} \ No newline at end of file