diff --git a/src/main/groovy-tests/recipeSearchTests.groovy b/src/main/groovy-tests/recipeMapTests.groovy similarity index 84% rename from src/main/groovy-tests/recipeSearchTests.groovy rename to src/main/groovy-tests/recipeMapTests.groovy index cf4a8c50..468180f9 100644 --- a/src/main/groovy-tests/recipeSearchTests.groovy +++ b/src/main/groovy-tests/recipeMapTests.groovy @@ -1,4 +1,9 @@ // Import Recipe Search Helpers, used for Chanced Item and Fluid Ingredients + + +import gregtech.api.recipes.ingredients.nbtmatch.NBTCondition +import gregtech.api.recipes.ingredients.nbtmatch.NBTMatcher + import static com.nomiceu.nomilabs.groovy.GroovyHelpers.GTRecipeHelpers.* // Building Test Recipes @@ -28,4 +33,15 @@ mods.gregtech.arc_furnace.removeByInput([item('minecraft:yellow_flower')], null) // [GTRecipeCategory category, Outputs... (see above)] (Matches/Removes any recipe with that output, and that category) // [Outputs... (see above)] (Matches/Removes any recipe with that output) // [Predicate predicate, Outputs... (see above)] (Matches/Removes any recipe with that output, and matching that predicate) -mods.gregtech.arc_furnace.removeByOutput(50, [item('minecraft:apple') * 64, item('minecraft:apple') * 64, item('minecraft:apple') * 64], null, [chanced(item('minecraft:apple') * 64, 50, 1)], [chanced(fluid('fluorine') * 2000, 50, 1)]) \ No newline at end of file +mods.gregtech.arc_furnace.removeByOutput(50, [item('minecraft:apple') * 64, item('minecraft:apple') * 64, item('minecraft:apple') * 64], null, [chanced(item('minecraft:apple') * 64, 50, 1)], [chanced(fluid('fluorine') * 2000, 50, 1)]) + +// NBT Helpers for Recipe Builder +// inputNBT version for ItemStack +// wildInputNBT version for ItemStack + +mods.gregtech.assembler.recipeBuilder() + .inputNBT(metaitem('nomilabs:dustPureOsmiridium8020'), NBTMatcher.ANY, NBTCondition.ANY) + .inputWildNBT(metaitem('nomilabs:dustOsmiridium8020')) // Same as above (Except the ItemStack of course) + .outputs(item('minecraft:apple') * 64) + .EUt(30).duration(30) + .buildAndRegister() \ No newline at end of file diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/RecipeBuilderMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/RecipeBuilderMixin.java index 81c50269..9b243199 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/RecipeBuilderMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/gregtech/RecipeBuilderMixin.java @@ -4,6 +4,9 @@ import gregtech.api.recipes.RecipeBuilder; import gregtech.api.recipes.RecyclingHandler; import gregtech.api.recipes.ingredients.GTRecipeInput; +import gregtech.api.recipes.ingredients.GTRecipeItemInput; +import gregtech.api.recipes.ingredients.nbtmatch.NBTCondition; +import gregtech.api.recipes.ingredients.nbtmatch.NBTMatcher; import gregtech.api.util.EnumValidationResult; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Final; @@ -16,7 +19,7 @@ import static com.nomiceu.nomilabs.util.LabsGroovyHelper.throwOrGroovyLog; @Mixin(value = RecipeBuilder.class, remap = false) -public class RecipeBuilderMixin> { +public abstract class RecipeBuilderMixin> { @Shadow @Final protected List outputs; @@ -28,6 +31,9 @@ public class RecipeBuilderMixin> { @Shadow protected EnumValidationResult recipeStatus; + @Shadow + public abstract RecipeBuilder inputNBT(GTRecipeInput input, NBTMatcher matcher, NBTCondition condition); + @Unique @SuppressWarnings("unused") public RecipeBuilder changeRecycling() { @@ -41,4 +47,16 @@ public RecipeBuilder changeRecycling() { //noinspection unchecked return (RecipeBuilder) (Object) this; } + + @Unique + @SuppressWarnings("unused") + public RecipeBuilder inputWildNBT(ItemStack stack) { + return inputNBT(stack, NBTMatcher.ANY, NBTCondition.ANY); + } + + @Unique + @SuppressWarnings("unused") + public RecipeBuilder inputNBT(ItemStack stack, NBTMatcher matcher, NBTCondition condition) { + return inputNBT(new GTRecipeItemInput(stack), matcher, condition); + } }