java.lang.Object
com.blamejared.crafttweaker.impl.recipe.handler.type.crafttweaker.CTShapelessRecipeHandler
All Implemented Interfaces:
IRecipeHandler<CTShapelessRecipeBase>

@For(CTShapelessRecipeBase.class) public final class CTShapelessRecipeHandler extends Object implements IRecipeHandler<CTShapelessRecipeBase>
  • Constructor Details

    • CTShapelessRecipeHandler

      public CTShapelessRecipeHandler()
  • Method Details

    • dumpToCommandString

      public String dumpToCommandString(IRecipeManager manager, CTShapelessRecipeBase 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<CTShapelessRecipeBase>
      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,CTShapelessRecipeBase>> replaceIngredients(IRecipeManager manager, CTShapelessRecipeBase 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<CTShapelessRecipeBase>
      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())).
    • doesConflict

      public <U extends net.minecraft.world.item.crafting.Recipe<?>> boolean doesConflict(IRecipeManager manager, CTShapelessRecipeBase firstRecipe, U secondRecipe)
      Description copied from interface: IRecipeHandler
      Checks if the two recipes conflict with each other.

      In this case, a conflict is defined as the two recipes being made in the exact same way (e.g. with the same shape and the same ingredients if the two recipes are shaped crafting table ones).

      Conflicts are also considered symmetrical in this implementation, which means that if firstRecipe conflicts with secondRecipe, the opposite is also true.

      Specified by:
      doesConflict in interface IRecipeHandler<CTShapelessRecipeBase>
      Type Parameters:
      U - The type of secondRecipe.
      Parameters:
      manager - The recipe manager responsible for this kind of recipes.
      firstRecipe - The recipe which should be checked for conflict.
      secondRecipe - The other recipe which firstRecipe should be checked against. The recipe may or may not be of the same type of firstRecipe. See the API note section for more details.
      Returns:
      Whether the firstRecipe conflicts with secondRecipe or not.