From 9db36447a91c6244ea5a3b12ed82082914d0ea7b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 28 Aug 2022 12:38:01 +0700 Subject: [PATCH] Fix datagen failure --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 4 ++-- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 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 0eecce2cf..5588fbb66 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 @@ -64,8 +64,8 @@ fun addCraftingTableRecipes(consumer: 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") + ShapelessRecipeBuilder(item, 1).requires(other).unlockedBy(item).save(consumer) + ShapelessRecipeBuilder(other, 1).requires(item).unlockedBy(other).save(consumer, "${other.registryName!!.path}_from_alt") } for ((crate, color) in listOf( 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 31db8b8f1..e9a356658 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,6 +4,7 @@ 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.data.recipes.ShapelessRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item @@ -46,6 +47,15 @@ private data class RecipeRow( val c: RecipeCell?, ) +fun ShapelessRecipeBuilder.unlockedBy(item: ItemLike): ShapelessRecipeBuilder { + val location = item.asItem().registryName!! + return unlockedBy("has_${location.namespace}_${location.path}", has(item)) +} + +fun ShapelessRecipeBuilder.unlockedBy(item: TagKey): ShapelessRecipeBuilder { + return unlockedBy("has_${item.location.namespace}_${item.location.path}", has(item)) +} + /** * [ShapedRecipeBuilder] that doesn't suck */