Skip to content

Commit

Permalink
More Recipe Builder Helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Mar 18, 2024
1 parent c9ef0dd commit cc2f23b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<Recipe> 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)])
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()
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +19,7 @@
import static com.nomiceu.nomilabs.util.LabsGroovyHelper.throwOrGroovyLog;

@Mixin(value = RecipeBuilder.class, remap = false)
public class RecipeBuilderMixin<R extends RecipeBuilder<R>> {
public abstract class RecipeBuilderMixin<R extends RecipeBuilder<R>> {
@Shadow
@Final
protected List<ItemStack> outputs;
Expand All @@ -28,6 +31,9 @@ public class RecipeBuilderMixin<R extends RecipeBuilder<R>> {
@Shadow
protected EnumValidationResult recipeStatus;

@Shadow
public abstract RecipeBuilder<R> inputNBT(GTRecipeInput input, NBTMatcher matcher, NBTCondition condition);

@Unique
@SuppressWarnings("unused")
public RecipeBuilder<R> changeRecycling() {
Expand All @@ -41,4 +47,16 @@ public RecipeBuilder<R> changeRecycling() {
//noinspection unchecked
return (RecipeBuilder<R>) (Object) this;
}

@Unique
@SuppressWarnings("unused")
public RecipeBuilder<R> inputWildNBT(ItemStack stack) {
return inputNBT(stack, NBTMatcher.ANY, NBTCondition.ANY);
}

@Unique
@SuppressWarnings("unused")
public RecipeBuilder<R> inputNBT(ItemStack stack, NBTMatcher matcher, NBTCondition condition) {
return inputNBT(new GTRecipeItemInput(stack), matcher, condition);
}
}

0 comments on commit cc2f23b

Please sign in to comment.