Class RecipeHelper

java.lang.Object
org.moddingx.libx.crafting.RecipeHelper

public class RecipeHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isItemValidInput(net.minecraft.world.item.crafting.RecipeManager rm, net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.item.ItemStack stack)
    Gets whether an ItemStack is a valid input for at least one recipe of a given recipe type.
    static boolean
    matches(net.minecraft.world.item.crafting.Recipe<?> recipe, List<net.minecraft.world.item.ItemStack> stacks, boolean exactMatch)
    Checks whether all the ingredients of a recipe are present in a list of ItemStacks.
    static JsonObject
    serializeItemStack(net.minecraft.world.item.ItemStack stack, boolean writeNBT)
    Serialises the given ItemStack to json, so it can be read back by CraftingHelper.getItemStack(JsonObject, boolean).
    static List<net.minecraft.world.item.ItemStack>
    stackUp(List<net.minecraft.world.item.ItemStack> stacks)
    Takes a list of ItemStacks and stacks them up so multiple ItemStacks that can be stacked are transformed into one.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RecipeHelper

      public RecipeHelper()
  • Method Details

    • isItemValidInput

      public static boolean isItemValidInput(net.minecraft.world.item.crafting.RecipeManager rm, net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.item.ItemStack stack)
      Gets whether an ItemStack is a valid input for at least one recipe of a given recipe type.
      Parameters:
      rm - The recipe manager to use. You can get one from a world.
    • matches

      public static boolean matches(net.minecraft.world.item.crafting.Recipe<?> recipe, List<net.minecraft.world.item.ItemStack> stacks, boolean exactMatch)
      Checks whether all the ingredients of a recipe are present in a list of ItemStacks. This does not check that all ingredients are on different slots.
      Parameters:
      exactMatch - When this is true this will return false if the stack list contains more items than the recipe requires.
    • stackUp

      public static List<net.minecraft.world.item.ItemStack> stackUp(List<net.minecraft.world.item.ItemStack> stacks)
      Takes a list of ItemStacks and stacks them up so multiple ItemStacks that can be stacked are transformed into one.
    • serializeItemStack

      public static JsonObject serializeItemStack(net.minecraft.world.item.ItemStack stack, boolean writeNBT)
      Serialises the given ItemStack to json, so it can be read back by CraftingHelper.getItemStack(JsonObject, boolean).