Interface IRecipeOutputExtension

All Known Subinterfaces:
RecipeOutput, ScopedRecipeOutput
All Known Implementing Classes:
ConditionalRecipeOutput, RecipeOutputWrapper

public interface IRecipeOutputExtension
Extra methods for RecipeOutput.
  • Method Details

    • self

      private RecipeOutput self()
    • accept

      void accept(ResourceKey<Recipe<?>> key, Recipe<?> recipe, @Nullable AdvancementHolder advancement, ICondition... conditions)
      Generates a recipe with the given conditions.
    • withConditions

      default RecipeOutput withConditions(ICondition... conditions)
      Builds a wrapper around this recipe output that adds conditions to all received recipes.
      Parameters:
      conditions - The conditions to apply to the recipe output.
      Returns:
      The wrapped recipe output.
    • withContext

      default ScopedRecipeOutput withContext(UnaryOperator<RecipeContextBuilder> builder)

      Scopes the RecipeOutput to use a specific context.

      This should be used via a try-with-resources block:

      // In some `RecipeProvider` subclass
      @Override
      protected void buildRecipes() {
          try (var _ = this.output.withContext(
                  builder -> builder.forMod("examplemod")
                      .withConditions(
                          NeoForgeConditions.modLoaded("examplemod")
                      )
          )) {
              // Sets the recipe id to "examplemod:diamond_to_apple".
              // Will only load if "examplemod" is present.
              this.shapeless(RecipeCategory.MISC, Items.APPLE)
                  .requires(Items.DIAMOND)
                  .unlockedBy(getHasName(Items.APPLE), this.has(Items.APPLE))
                  .save(this.output, "diamond_to_apple");
      
              // ...
          }
      }
      
      Parameters:
      builder - A unary operator used to construct the context.
      Returns:
      A scoped recipe output.