Class ShapedRecipe

java.lang.Object
org.cloudburstmc.server.crafting.ShapedRecipe
All Implemented Interfaces:
org.cloudburstmc.api.inventory.Recipe, CraftingRecipe

public class ShapedRecipe extends Object implements CraftingRecipe
author: MagicDroidX Nukkit Project
  • Constructor Details

    • ShapedRecipe

      public ShapedRecipe(org.cloudburstmc.api.util.Identifier recipeId, int priority, org.cloudburstmc.api.item.ItemStack primaryResult, String[] shape, io.netty.util.collection.CharObjectMap<org.cloudburstmc.api.item.ItemStack> ingredients, List<org.cloudburstmc.api.item.ItemStack> extraResults, org.cloudburstmc.api.util.Identifier block)
      Constructs a ShapedRecipe instance.
      Parameters:
      primaryResult - Primary result of the recipe
      shape -
      Array of 1, 2, or 3 strings representing the rows of the recipe. This accepts an array of 1, 2 or 3 strings. Each string should be of the same length and must be at most 3 characters long. Each character represents a unique type of ingredient. Spaces are interpreted as air.
      ingredients -
      Char => Item map of items to be set into the shape. This accepts an array of Items, indexed by character. Every unique character (except space) in the shape array MUST have a corresponding item in this list. Space character is automatically treated as air.
      extraResults -
      List of additional result items to leave in the crafting grid afterwards. Used for things like cake recipe empty buckets.

      Note: Recipes **do not** need to be square. Do NOT add padding for empty rows/columns.

  • Method Details

    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getResult

      public org.cloudburstmc.api.item.ItemStack getResult()
      Specified by:
      getResult in interface org.cloudburstmc.api.inventory.Recipe
    • getId

      public org.cloudburstmc.api.util.Identifier getId()
      Specified by:
      getId in interface org.cloudburstmc.api.inventory.Recipe
    • setIngredient

      public ShapedRecipe setIngredient(String key, org.cloudburstmc.api.item.ItemStack item)
    • setIngredient

      public ShapedRecipe setIngredient(char key, org.cloudburstmc.api.item.ItemStack item)
    • getIngredientList

      public List<org.cloudburstmc.api.item.ItemStack> getIngredientList()
    • getIngredientMap

      public Map<Integer,​Map<Integer,​org.cloudburstmc.api.item.ItemStack>> getIngredientMap()
    • getIngredient

      public org.cloudburstmc.api.item.ItemStack getIngredient(int x, int y)
    • getShape

      public String[] getShape()
    • getType

      public org.cloudburstmc.api.inventory.RecipeType getType()
      Specified by:
      getType in interface org.cloudburstmc.api.inventory.Recipe
    • getExtraResults

      public List<org.cloudburstmc.api.item.ItemStack> getExtraResults()
      Specified by:
      getExtraResults in interface CraftingRecipe
    • getAllResults

      public List<org.cloudburstmc.api.item.ItemStack> getAllResults()
      Specified by:
      getAllResults in interface CraftingRecipe
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface CraftingRecipe
    • matchItems

      public boolean matchItems(org.cloudburstmc.api.item.ItemStack[][] input, org.cloudburstmc.api.item.ItemStack[][] output)
      Description copied from interface: CraftingRecipe
      Returns whether the specified list of crafting grid inputs and outputs matches this recipe. Outputs DO NOT include the primary result item.
      Specified by:
      matchItems in interface CraftingRecipe
      Parameters:
      input - 2D array of items taken from the crafting grid
      output - 2D array of items put back into the crafting grid (secondary results)
      Returns:
      bool
    • getBlock

      public org.cloudburstmc.api.util.Identifier getBlock()
      Specified by:
      getBlock in interface org.cloudburstmc.api.inventory.Recipe
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • requiresCraftingTable

      public boolean requiresCraftingTable()
      Specified by:
      requiresCraftingTable in interface CraftingRecipe