Fix datagen failure

This commit is contained in:
DBotThePony 2022-08-28 12:38:01 +07:00
parent d7a444327c
commit 9db36447a9
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 12 additions and 2 deletions

View File

@ -64,8 +64,8 @@ fun addCraftingTableRecipes(consumer: Consumer<FinishedRecipe>) {
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(

View File

@ -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<Item>): ShapelessRecipeBuilder {
return unlockedBy("has_${item.location.namespace}_${item.location.path}", has(item))
}
/**
* [ShapedRecipeBuilder] that doesn't suck
*/