Class StoneCutterRecipeHandler

java.lang.Object
com.blamejared.crafttweaker.impl.recipe.handler.type.vanilla.StoneCutterRecipeHandler
All Implemented Interfaces:
IRecipeHandler<net.minecraft.world.item.crafting.StonecutterRecipe>

@For(net.minecraft.world.item.crafting.StonecutterRecipe.class) public final class StoneCutterRecipeHandler extends Object implements IRecipeHandler<net.minecraft.world.item.crafting.StonecutterRecipe>
  • Constructor Details

    • StoneCutterRecipeHandler

      public StoneCutterRecipeHandler()
  • Method Details

    • dumpToCommandString

      public String dumpToCommandString(IRecipeManager manager, net.minecraft.world.item.crafting.StonecutterRecipe recipe)
      Description copied from interface: IRecipeHandler
      Creates a String representation of a valid addRecipe (or alternative) call for the given subclass of Recipe.

      Recipe dumps are triggered by the /ct recipes or /ct recipes hand commands.

      All newlines added to either the start or the end of the string will be automatically trimmed.

      Specified by:
      dumpToCommandString in interface IRecipeHandler<net.minecraft.world.item.crafting.StonecutterRecipe>
      Parameters:
      manager - The recipe manager responsible for this kind of recipes.
      recipe - The recipe that is currently being dumped.
      Returns:
      A String representing a addRecipe (or similar) call.
    • replaceIngredients

      public Optional<Function<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.StonecutterRecipe>> replaceIngredients(IRecipeManager manager, net.minecraft.world.item.crafting.StonecutterRecipe recipe, List<IReplacementRule> rules)
      Description copied from interface: IRecipeHandler
      Handles the replacement of ingredients according to the given set of IReplacementRules for the given subclass of Recipe.

      This method should try to apply all of the applicable rules to the recipe. If one of the rules fails to apply, an error message should be generated via CraftTweakerAPI.LOGGER. Incomplete application of the replacement rules may or may not apply depending on the specific implementation: no specific contracts are enforced by this method.

      If a particular recipe handler does not support replacement, a IRecipeHandler.ReplacementNotSupportedException should be raised, along with a helpful error message. A recipe handler must be consistent, meaning that given the same recipe class, the behavior should be consistent: either an exception gets thrown or the replacement gets carried out.

      Specified by:
      replaceIngredients in interface IRecipeHandler<net.minecraft.world.item.crafting.StonecutterRecipe>
      Parameters:
      manager - The recipe manager responsible for this kind of recipes.
      recipe - The recipe whose ingredients should be replaced.
      rules - A series of IReplacementRules in the order they should be applied. Implementations are nevertheless allowed to reorder these rules as they see fit. Refer to the implementation specifications for more details.
      Returns:
      An Optional containing a function that creates the replaced recipe, if any replacements have been carried out. If no replacement rule affected the current recipe, the return value should be Optional.empty(). The parameter of the function will be the new ID of the recipe that should be used, as determined by the method caller: the name may correspond to the old one or be a completely new one, implementations are not allowed to make any assumptions on the value of this parameter. It is customary, though not required, that the value returned by the wrapped function is a completely different object from recipe (i.e. recipe != result.get().apply(recipe.getId())).