Package com.minecolonies.api.crafting
Class RecipeStorage
java.lang.Object
com.minecolonies.api.crafting.RecipeStorage
- All Implemented Interfaces:
IRecipeStorage
Class used to represent a recipe in minecolonies.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.world.level.storage.loot.parameters.LootContextParamSetThe loot parameter set definition -
Method Summary
Modifier and TypeMethodDescriptionstatic RecipeStorage.Builderbuilder()Start building a RecipeStorage.static RecipeStorage.Builderbuilder(@NotNull IRecipeStorage recipe) Start building a RecipeStorage.booleancanFullFillRecipe(int qty, Map<ItemStorage, Integer> existingRequirements, @NotNull List<net.minecraftforge.items.IItemHandler> citizen, @NotNull IBuilding building) Method to check if with the help of inventories this recipe can be fulfilled.booleancanFullFillRecipe(int qty, Map<ItemStorage, Integer> existingRequirements, @NotNull net.minecraftforge.items.IItemHandler... inventories) Method to check if with the help of inventories this recipe can be fulfilled.booleanList<net.minecraft.world.item.ItemStack>fullfillRecipeAndCopy(net.minecraft.world.level.storage.loot.LootParams context, List<net.minecraftforge.items.IItemHandler> handlers, boolean doInsert) Check for space, remove items, and insert crafted items, returning a copy of the crafted items.@NotNull List<net.minecraft.world.item.ItemStack>Get a list of alternates to getPrimaryOutputgetClassicForMultiOutput(Predicate<net.minecraft.world.item.ItemStack> stackPredicate) Get the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternategetClassicForMultiOutput(net.minecraft.world.item.ItemStack requiredOutput) Get the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternate@NotNull List<ItemStorage>Get the cleaned up list of the recipes.@NotNull List<net.minecraft.world.item.ItemStack>Get the tools (leave behind in grid)@NotNull List<net.minecraft.world.item.ItemStack>Get the tools and Secondary Output (leave behind in grid)intGet the grid size.getInput()Get the list of input items.net.minecraft.world.level.block.BlockGet the required intermediate for the recipe.net.minecraft.resources.ResourceLocationGet the location/id of the Loot table used for optional outputs@NotNull net.minecraft.world.item.ItemStackGetter for the primary output.net.minecraft.resources.ResourceLocationSource of the recipe, ie registry name.Get which type this recipe is This type comes from the RecipeTypes registry@NotNull EquipmentTypeEntryGet the additional tool needed beyond the recipe (if any)@NotNull List<net.minecraft.world.item.ItemStack>Get the secondary (leave behind in grid) outputsIToken<?>getToken()Get the unique token of the recipe.inthashCode()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.crafting.IRecipeStorage
fullfillRecipe, fullfillRecipe, fullFillRecipe, fullFillRecipe, fullfillRecipeAndCopy
-
Field Details
-
recipeLootParameters
public static final net.minecraft.world.level.storage.loot.parameters.LootContextParamSet recipeLootParametersThe loot parameter set definition
-
-
Method Details
-
builder
Start building a RecipeStorage.- Returns:
- the builder.
-
builder
Start building a RecipeStorage.- Parameters:
recipe- a recipe to use as a base.- Returns:
- the builder.
-
getInput
Description copied from interface:IRecipeStorageGet the list of input items. Suppressing Sonar Rule Squid:S2384 The rule thinks we should return a copy of the list and not the list itself. But in this case the rule does not apply because the list is an unmodifiable list already- Specified by:
getInputin interfaceIRecipeStorage- Returns:
- the list.
-
getCleanedInput
Description copied from interface:IRecipeStorageGet the cleaned up list of the recipes. Air gets removed and equal items get put together. This returns an list of immutable itemStorage elements that cannot be tempered with.- Specified by:
getCleanedInputin interfaceIRecipeStorage- Returns:
- the list.
-
getPrimaryOutput
@NotNull public @NotNull net.minecraft.world.item.ItemStack getPrimaryOutput()Description copied from interface:IRecipeStorageGetter for the primary output.- Specified by:
getPrimaryOutputin interfaceIRecipeStorage- Returns:
- the itemStack to be produced.
-
getGridSize
public int getGridSize()Description copied from interface:IRecipeStorageGet the grid size.- Specified by:
getGridSizein interfaceIRecipeStorage- Returns:
- the integer representing it. (2x2 = 4, 3x3 = 9, etc)
-
getIntermediate
public net.minecraft.world.level.block.Block getIntermediate()Description copied from interface:IRecipeStorageGet the required intermediate for the recipe.- Specified by:
getIntermediatein interfaceIRecipeStorage- Returns:
- the block.
-
canFullFillRecipe
public boolean canFullFillRecipe(int qty, Map<ItemStorage, Integer> existingRequirements, @NotNull @NotNull net.minecraftforge.items.IItemHandler... inventories) Description copied from interface:IRecipeStorageMethod to check if with the help of inventories this recipe can be fulfilled. Also check if the inventory has enough to fulfill the existing requirements.- Specified by:
canFullFillRecipein interfaceIRecipeStorage- Parameters:
qty- the quantity to craft.existingRequirements- map of existing requirements (pending requests).inventories- the inventories to check.- Returns:
- true if possible, else false.
-
canFullFillRecipe
public boolean canFullFillRecipe(int qty, Map<ItemStorage, Integer> existingRequirements, @NotNull @NotNull List<net.minecraftforge.items.IItemHandler> citizen, @NotNull @NotNull IBuilding building) Description copied from interface:IRecipeStorageMethod to check if with the help of inventories this recipe can be fulfilled. Also check if the inventory has enough to fulfill the existing requirements.- Specified by:
canFullFillRecipein interfaceIRecipeStorage- Parameters:
qty- the quantity to craft.existingRequirements- map of existing requirements (pending requests).citizen- the citizen inventory to check.building- the building inv to check.- Returns:
- true if possible, else false.
-
equals
-
hashCode
public int hashCode() -
fullfillRecipeAndCopy
public List<net.minecraft.world.item.ItemStack> fullfillRecipeAndCopy(net.minecraft.world.level.storage.loot.LootParams context, List<net.minecraftforge.items.IItemHandler> handlers, boolean doInsert) Check for space, remove items, and insert crafted items, returning a copy of the crafted items.- Specified by:
fullfillRecipeAndCopyin interfaceIRecipeStorage- Parameters:
context- loot contexthandlers- the handlers to use- Returns:
- copy of the crafted items if successful, null on failure
-
getToken
Description copied from interface:IRecipeStorageGet the unique token of the recipe.- Specified by:
getTokenin interfaceIRecipeStorage- Returns:
- the IToken.
-
getClassicForMultiOutput
Description copied from interface:IRecipeStorageGet the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternate- Specified by:
getClassicForMultiOutputin interfaceIRecipeStorage- Parameters:
requiredOutput- Which output wanted- Returns:
- the RecipeStorage that is "right" for that output
-
getClassicForMultiOutput
public RecipeStorage getClassicForMultiOutput(Predicate<net.minecraft.world.item.ItemStack> stackPredicate) Description copied from interface:IRecipeStorageGet the classic version of this recipe with GetPrimaryOutput targeted correctly from the chosen alternate- Specified by:
getClassicForMultiOutputin interfaceIRecipeStorage- Parameters:
stackPredicate- Predicate to select the right stack- Returns:
- the RecipeStorage that is "right" for that output
-
getRecipeType
Description copied from interface:IRecipeStorageGet which type this recipe is This type comes from the RecipeTypes registry- Specified by:
getRecipeTypein interfaceIRecipeStorage- Returns:
- The recipe type
-
getRecipeSource
public net.minecraft.resources.ResourceLocation getRecipeSource()Description copied from interface:IRecipeStorageSource of the recipe, ie registry name.- Specified by:
getRecipeSourcein interfaceIRecipeStorage- Returns:
-
getAlternateOutputs
Description copied from interface:IRecipeStorageGet a list of alternates to getPrimaryOutput- Specified by:
getAlternateOutputsin interfaceIRecipeStorage- Returns:
- a list if Itemstacks that this recipe can produce instead of getPrimaryOutput
-
getCraftingToolsAndSecondaryOutputs
@NotNull public @NotNull List<net.minecraft.world.item.ItemStack> getCraftingToolsAndSecondaryOutputs()Description copied from interface:IRecipeStorageGet the tools and Secondary Output (leave behind in grid)- Specified by:
getCraftingToolsAndSecondaryOutputsin interfaceIRecipeStorage- Returns:
- list of items that weren't consumed during crafting
-
getLootTable
public net.minecraft.resources.ResourceLocation getLootTable()Description copied from interface:IRecipeStorageGet the location/id of the Loot table used for optional outputs- Specified by:
getLootTablein interfaceIRecipeStorage- Returns:
- the resource location for the table
-
getRequiredTool
Description copied from interface:IRecipeStorageGet the additional tool needed beyond the recipe (if any)- Specified by:
getRequiredToolin interfaceIRecipeStorage- Returns:
- the required tool
-
getCraftingTools
Description copied from interface:IRecipeStorageGet the tools (leave behind in grid)- Specified by:
getCraftingToolsin interfaceIRecipeStorage- Returns:
- list of items that weren't consumed during crafting
-
getSecondaryOutputs
Description copied from interface:IRecipeStorageGet the secondary (leave behind in grid) outputs- Specified by:
getSecondaryOutputsin interfaceIRecipeStorage- Returns:
- list of items that weren't consumed during crafting
-