Package net.minecraft.recipe
Class ShapedRecipe
java.lang.Object
net.minecraft.recipe.ShapedRecipe
- All Implemented Interfaces:
CraftingRecipe,Recipe<CraftingInventory>
- Direct Known Subclasses:
MapExtendingRecipe
public class ShapedRecipe extends Object implements CraftingRecipe
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShapedRecipe.Serializer -
Field Summary
Fields Modifier and Type Field Description private Stringgroupprivate intheightprivate Identifieridprivate DefaultedList<Ingredient>inputprivate ItemStackoutputprivate intwidth -
Constructor Summary
Constructors Constructor Description ShapedRecipe(Identifier id, String group, int width, int height, DefaultedList<Ingredient> input, ItemStack output) -
Method Summary
Modifier and Type Method Description ItemStackcraft(CraftingInventory craftingInventory)Crafts this recipe.private static DefaultedList<Ingredient>createPatternMatrix(String[] pattern, Map<String,Ingredient> symbols, int width, int height)Compiles a pattern and series of symbols into a list of ingredients (the matrix) suitable for matching against a crafting grid.private static intfindFirstSymbol(String line)private static intfindLastSymbol(String pattern)booleanfits(int width, int height)Determines whether this recipe's pattern will fit into the available crafting area.StringgetGroup()Optional group this recipe belongs in.intgetHeight()IdentifiergetId()DefaultedList<Ingredient>getIngredients()The ingredients accepted as inputs for this recipe.static ItemStackgetItemStack(JsonObject json)ItemStackgetOutput()private static String[]getPattern(JsonArray json)RecipeSerializer<?>getSerializer()intgetWidth()booleanmatches(CraftingInventory craftingInventory, World world)Determines whether this recipe matches the contents currently placed inside the available crafting grid.private booleanmatchesPattern(CraftingInventory inv, int offsetX, int offsetY, boolean flipped)private static Map<String,Ingredient>readSymbols(JsonObject json)Reads the pattern symbols.(package private) static String[]removePadding(String[] pattern)Removes empty space from around the recipe pattern.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.recipe.CraftingRecipe
getTypeMethods inherited from interface net.minecraft.recipe.Recipe
createIcon, getRemainder, isIgnoredInRecipeBook
-
Field Details
-
width
private final int width -
height
private final int height -
input
-
output
-
id
-
group
-
-
Constructor Details
-
ShapedRecipe
public ShapedRecipe(Identifier id, String group, int width, int height, DefaultedList<Ingredient> input, ItemStack output)
-
-
Method Details
-
getId
- Specified by:
getIdin interfaceRecipe<CraftingInventory>
-
getSerializer
- Specified by:
getSerializerin interfaceRecipe<CraftingInventory>
-
getGroup
Optional group this recipe belongs in. Used to group recipes into different categories by the recipe book.- Specified by:
getGroupin interfaceRecipe<CraftingInventory>
-
getOutput
- Specified by:
getOutputin interfaceRecipe<CraftingInventory>
-
getIngredients
The ingredients accepted as inputs for this recipe. Used by the recipe book when displaying a ghost form of this recipe on the crafting grid as well as for previewing the possible inputs in the book itself.- Specified by:
getIngredientsin interfaceRecipe<CraftingInventory>
-
fits
@Environment(CLIENT) public boolean fits(int width, int height)Determines whether this recipe's pattern will fit into the available crafting area.- Specified by:
fitsin interfaceRecipe<CraftingInventory>
-
matches
Description copied from interface:RecipeDetermines whether this recipe matches the contents currently placed inside the available crafting grid.- Specified by:
matchesin interfaceRecipe<CraftingInventory>
-
matchesPattern
-
craft
Description copied from interface:RecipeCrafts this recipe.This method may perform side effects on the
inventoryargument.This method should return a new item stack on each call.
- Specified by:
craftin interfaceRecipe<CraftingInventory>- Returns:
- the resulting item stack
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
createPatternMatrix
private static DefaultedList<Ingredient> createPatternMatrix(String[] pattern, Map<String,Ingredient> symbols, int width, int height)Compiles a pattern and series of symbols into a list of ingredients (the matrix) suitable for matching against a crafting grid. -
removePadding
Removes empty space from around the recipe pattern.Turns patterns such as:
Into:" o" " a" " ""o" "a"- Returns:
- a new recipe pattern with all leading and trailing empty rows/columns removed
-
findFirstSymbol
-
findLastSymbol
-
getPattern
-
readSymbols
Reads the pattern symbols.- Returns:
- a mapping from a symbol to the ingredient it represents
-
getItemStack
-