diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_0.json b/src/generated/resources/data/botania/recipes/laputa_shard_0.json index 91edd98fe..49328d4e4 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_0.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_0.json @@ -26,6 +26,7 @@ } }, "result": { - "item": "botania:laputa_shard" + "item": "botania:laputa_shard", + "nbt": "{level:0}" } } \ No newline at end of file diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_1.json b/src/generated/resources/data/botania/recipes/laputa_shard_1.json index b186bb206..1d3707b4e 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_1.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_1.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:0}" + "nbt": "{level:0}", + "accepts_empty_tag": true } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_10.json b/src/generated/resources/data/botania/recipes/laputa_shard_10.json index 87e418572..6cd4327c0 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_10.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_10.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:9}" + "nbt": "{level:9}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_11.json b/src/generated/resources/data/botania/recipes/laputa_shard_11.json index 2b4959b0a..d8dcd3bae 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_11.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_11.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:10}" + "nbt": "{level:10}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_12.json b/src/generated/resources/data/botania/recipes/laputa_shard_12.json index 9699d92a7..de5b26a7f 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_12.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_12.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:11}" + "nbt": "{level:11}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_13.json b/src/generated/resources/data/botania/recipes/laputa_shard_13.json index 43e5cbe8d..addff14c6 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_13.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_13.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:12}" + "nbt": "{level:12}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_14.json b/src/generated/resources/data/botania/recipes/laputa_shard_14.json index d5bf7ae08..2a4da8123 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_14.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_14.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:13}" + "nbt": "{level:13}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_15.json b/src/generated/resources/data/botania/recipes/laputa_shard_15.json index 8461ff848..a1f73168a 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_15.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_15.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:14}" + "nbt": "{level:14}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_16.json b/src/generated/resources/data/botania/recipes/laputa_shard_16.json index 5bbe6e9d0..b37471e99 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_16.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_16.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:15}" + "nbt": "{level:15}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_17.json b/src/generated/resources/data/botania/recipes/laputa_shard_17.json index 3e3f0ec33..c5d0b394e 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_17.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_17.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:16}" + "nbt": "{level:16}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_18.json b/src/generated/resources/data/botania/recipes/laputa_shard_18.json index f4ff02ebd..0d1aae577 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_18.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_18.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:17}" + "nbt": "{level:17}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_19.json b/src/generated/resources/data/botania/recipes/laputa_shard_19.json index dcd35ed6d..1403ef757 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_19.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_19.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:18}" + "nbt": "{level:18}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_2.json b/src/generated/resources/data/botania/recipes/laputa_shard_2.json index 6c128bcde..7e948800a 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_2.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_2.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:1}" + "nbt": "{level:1}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_3.json b/src/generated/resources/data/botania/recipes/laputa_shard_3.json index 80ee54a1f..d59d5a84d 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_3.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_3.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:2}" + "nbt": "{level:2}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_4.json b/src/generated/resources/data/botania/recipes/laputa_shard_4.json index a2ad3e28f..939092e5b 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_4.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_4.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:3}" + "nbt": "{level:3}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_5.json b/src/generated/resources/data/botania/recipes/laputa_shard_5.json index 18a74336f..faf05249c 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_5.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_5.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:4}" + "nbt": "{level:4}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_6.json b/src/generated/resources/data/botania/recipes/laputa_shard_6.json index 73633f70c..e23ebd004 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_6.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_6.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:5}" + "nbt": "{level:5}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_7.json b/src/generated/resources/data/botania/recipes/laputa_shard_7.json index e4da36fa0..e79d1edfa 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_7.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_7.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:6}" + "nbt": "{level:6}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_8.json b/src/generated/resources/data/botania/recipes/laputa_shard_8.json index 41e8fe8d5..dfc5f3366 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_8.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_8.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:7}" + "nbt": "{level:7}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/laputa_shard_9.json b/src/generated/resources/data/botania/recipes/laputa_shard_9.json index e9ae48212..7bd44e2ba 100644 --- a/src/generated/resources/data/botania/recipes/laputa_shard_9.json +++ b/src/generated/resources/data/botania/recipes/laputa_shard_9.json @@ -6,10 +6,11 @@ "item": "botania:life_essence" }, { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "botania:laputa_shard", "count": 1, - "nbt": "{level:8}" + "nbt": "{level:8}", + "accepts_empty_tag": false } ], "result": { diff --git a/src/generated/resources/data/botania/recipes/water_rod.json b/src/generated/resources/data/botania/recipes/water_rod.json index ebf831ead..8022aa857 100644 --- a/src/generated/resources/data/botania/recipes/water_rod.json +++ b/src/generated/resources/data/botania/recipes/water_rod.json @@ -7,10 +7,11 @@ ], "key": { "B": { - "type": "forge:nbt", + "type": "botania:fuzzy_nbt", "item": "minecraft:potion", "count": 1, - "nbt": "{Potion:\"minecraft:water\"}" + "nbt": "{Potion:\"minecraft:water\"}", + "accepts_empty_tag": false }, "R": { "tag": "botania:runes/water" diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 1a7711d43..201b6b7e2 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -15,7 +15,6 @@ import net.minecraft.world.storage.loot.conditions.LootConditionManager; import net.minecraft.world.storage.loot.functions.LootFunctionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModList; @@ -59,7 +58,6 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.IMCHandler; import vazkii.botania.common.core.handler.IMCSender; -import vazkii.botania.common.core.handler.InternalMethodHandler; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.core.helper.ColorHelper; import vazkii.botania.common.core.loot.BindUuid; @@ -68,7 +66,6 @@ import vazkii.botania.common.core.loot.LootHandler; import vazkii.botania.common.core.loot.TrueGuardianKiller; import vazkii.botania.common.core.proxy.IProxy; import vazkii.botania.common.core.proxy.ServerProxy; -import vazkii.botania.common.crafting.FluxfieldCondition; import vazkii.botania.common.impl.corporea.CorporeaItemStackMatcher; import vazkii.botania.common.impl.corporea.CorporeaStringMatcher; import vazkii.botania.common.lib.LibMisc; @@ -223,8 +220,6 @@ public class Botania { CriteriaTriggers.register(LokiPlaceTrigger.INSTANCE); CriteriaTriggers.register(AlfPortalBreadTrigger.INSTANCE); - CraftingHelper.register(FluxfieldCondition.SERIALIZER); - ModBlocks.addDispenserBehaviours(); ModFeatures.addWorldgen(); diff --git a/src/main/java/vazkii/botania/common/crafting/FuzzyNBTIngredient.java b/src/main/java/vazkii/botania/common/crafting/FuzzyNBTIngredient.java new file mode 100644 index 000000000..849a0da57 --- /dev/null +++ b/src/main/java/vazkii/botania/common/crafting/FuzzyNBTIngredient.java @@ -0,0 +1,131 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.common.crafting; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.JSONUtils; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.common.crafting.IIngredientSerializer; + +import vazkii.botania.common.core.helper.ItemNBTHelper; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import java.util.stream.Stream; + +/** + * NBT ingredient that accepts items containing the same NBT data as the provided template stack. + * In addition, an option to accept items without any NBT data is provided. + * + * @see ItemNBTHelper#matchTag(INBT, INBT) + */ +public class FuzzyNBTIngredient extends Ingredient { + public static final IIngredientSerializer SERIALIZER = new Serializer(); + private static final String ACCEPTS_EMPTY_TAG = "accepts_empty_tag"; + + private final ItemStack stack; + private final boolean acceptsEmptyTag; + + /** + * Constructs the ingredient. + * + * @param stack Template stack for this ingredient + * @param acceptsEmptyTag Whether lack of NBT data is accepted by this ingredient in addition to the + * stack's data. + * @throws IllegalArgumentException if the stack has no NBT data. + */ + public FuzzyNBTIngredient(ItemStack stack, boolean acceptsEmptyTag) { + super(Stream.of(new Ingredient.SingleItemList(stack))); + this.stack = stack; + this.acceptsEmptyTag = acceptsEmptyTag; + if (!stack.hasTag()) { + throw new IllegalArgumentException("This ingredient type requires a stack with NBT!"); + } + } + + /** + * Constructs the ingredient. + * + * @param stack Template stack for this ingredient + * @throws IllegalArgumentException if the stack has no NBT data. + */ + public FuzzyNBTIngredient(ItemStack stack) { + this(stack, false); + } + + @Override + public boolean test(@Nullable ItemStack input) { + if (input == null || stack.getItem() != input.getItem()) { + return false; + } + CompoundNBT tag = input.getTag(); + if (acceptsEmptyTag && (tag == null || tag.isEmpty())) { + return true; + } + return ItemNBTHelper.matchTag(stack.getTag(), tag); + } + + @Override + public boolean isSimple() { + return false; + } + + @Nonnull + @Override + public JsonElement serialize() { + JsonObject json = new JsonObject(); + json.addProperty("type", CraftingHelper.getID(SERIALIZER).toString()); + json.addProperty("item", stack.getItem().getRegistryName().toString()); + json.addProperty("count", stack.getCount()); + json.addProperty("nbt", stack.getTag().toString()); + json.addProperty(ACCEPTS_EMPTY_TAG, acceptsEmptyTag); + return json; + } + + @Nonnull + @Override + public ItemStack[] getMatchingStacks() { + return new ItemStack[] { stack }; + } + + @Nonnull + @Override + public IIngredientSerializer getSerializer() { + return SERIALIZER; + } + + private static class Serializer implements IIngredientSerializer { + @Nonnull + @Override + public FuzzyNBTIngredient parse(@Nonnull PacketBuffer buffer) { + return new FuzzyNBTIngredient(buffer.readItemStack(), buffer.readBoolean()); + } + + @Nonnull + @Override + public FuzzyNBTIngredient parse(@Nonnull JsonObject json) { + boolean acceptsEmptyTag = JSONUtils.getBoolean(json, ACCEPTS_EMPTY_TAG, false); + return new FuzzyNBTIngredient(CraftingHelper.getItemStack(json, true), acceptsEmptyTag); + } + + @Override + public void write(@Nonnull PacketBuffer buffer, @Nonnull FuzzyNBTIngredient ingredient) { + buffer.writeItemStack(ingredient.stack); + buffer.writeBoolean(ingredient.acceptsEmptyTag); + } + } +} diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index b0f647ca1..49a2f93e0 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -19,6 +19,7 @@ import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -38,6 +39,8 @@ import vazkii.botania.client.gui.box.GuiBaubleBox; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.core.handler.ModSounds; +import vazkii.botania.common.crafting.FluxfieldCondition; +import vazkii.botania.common.crafting.FuzzyNBTIngredient; import vazkii.botania.common.crafting.recipe.*; import vazkii.botania.common.item.brew.ItemBrewBase; import vazkii.botania.common.item.brew.ItemIncenseStick; @@ -110,6 +113,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Locale; import static vazkii.botania.common.block.ModBlocks.register; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @ObjectHolder(LibMisc.MOD_ID) @@ -725,6 +729,9 @@ public final class ModItems { register(r, SpellClothRecipe.SERIALIZER, "spell_cloth_apply"); register(r, TerraPickTippingRecipe.SERIALIZER, "terra_pick_tipping"); register(r, TwigWandRecipe.SERIALIZER, "twig_wand"); + + CraftingHelper.register(FluxfieldCondition.SERIALIZER); + CraftingHelper.register(prefix("fuzzy_nbt"), FuzzyNBTIngredient.SERIALIZER); } @SubscribeEvent diff --git a/src/main/java/vazkii/botania/data/recipes/RecipeProvider.java b/src/main/java/vazkii/botania/data/recipes/RecipeProvider.java index 15c75054f..6afa10c12 100644 --- a/src/main/java/vazkii/botania/data/recipes/RecipeProvider.java +++ b/src/main/java/vazkii/botania/data/recipes/RecipeProvider.java @@ -47,6 +47,7 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.crafting.FluxfieldCondition; +import vazkii.botania.common.crafting.FuzzyNBTIngredient; import vazkii.botania.common.crafting.recipe.*; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; @@ -1258,7 +1259,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .build(consumer); ShapedRecipeBuilder.shapedRecipe(ModItems.waterRod) - .key('B', nbtIngredient(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER))) + .key('B', new FuzzyNBTIngredient(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER))) .key('R', ModTags.Items.RUNES_WATER) .key('T', ModItems.livingwoodTwig) .patternLine(" B") @@ -1369,14 +1370,15 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .patternLine("PDP") .patternLine("ASE") .addCriterion("has_item", hasItem(ModItems.lifeEssence)) - .build(consumer, "botania:laputa_shard_0"); + .build(WrapperResult.transformJson(consumer, json -> json.getAsJsonObject("result").addProperty("nbt", "{level:0}")), + "botania:laputa_shard_0"); for (int i = 1; i < 20; i++) { final int outputLevel = i; ItemStack stack = new ItemStack(ModItems.laputaShard); stack.getOrCreateTag().putInt("level", i - 1); ShapelessRecipeBuilder.shapelessRecipe(ModItems.laputaShard) .addIngredient(ModItems.lifeEssence) - .addIngredient(nbtIngredient(stack)) + .addIngredient(new FuzzyNBTIngredient(stack, i == 1)) .setGroup("botania:laputa_shard_upgrade") .addCriterion("has_item", hasItem(ModItems.laputaShard)) .build(WrapperResult.transformJson(consumer, json -> json.getAsJsonObject("result").addProperty("nbt", "{level:" + outputLevel + "}") @@ -2658,12 +2660,6 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { CustomRecipeBuilder.func_218656_a(serializer).build(consumer, prefix("dynamic/" + serializer.getRegistryName().getPath()).toString()); } - // Blame Forge for making the constructor protected. - // TODO maybe use a bit fuzzier ingredient, it will break if any mod throws random NBT data at the item - private static NBTIngredient nbtIngredient(ItemStack stack) { - return new NBTIngredient(stack) {}; - } - @Override public String getName() { return "Botania crafting recipes";