Class CustomRecipe
java.lang.Object
com.minecolonies.core.colony.crafting.CustomRecipe
This class represents a recipe loaded from custom data that is available to a crafter
but not to a player
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe property name for the alternate output arraystatic final StringThe property name for the maximum level the building can bestatic final StringThe property name for the minimum level the building must bestatic final StringThe property name that indicates crafter type for the recipestatic final StringThe property name for the research id that invalidates this recipestatic final StringThe property name for a recipe template filter.static final StringThe property name that indicates the recipe to removestatic final StringThe property name for the inputs arraystatic final StringThe property name for the intermediate block IDstatic final StringThe property namefor the result loottablestatic final StringThe property name for if a recipe of the inputs must exist for the recipe to be validstatic final StringThe property name for the required research idstatic final StringThe property name for the result itemstatic final StringThe property name for the inputs arraystatic final StringThe property name to enable tooltip display (and transmission to the client).static final StringThe property name for a recipe template tag.static final StringThe property name for the required toolstatic final StringThe property name that indicates type for the recipestatic final StringThe recipe typestatic final StringThe multiple input recipe typestatic final StringThe multiple output recipe typestatic final StringThe remove typestatic final StringThe recipe template type -
Constructor Summary
ConstructorsConstructorDescriptionCustomRecipe(String crafter, int minBldgLevel, int maxBldgLevel, boolean mustExist, boolean showTooltip, net.minecraft.resources.ResourceLocation recipeId, Set<net.minecraft.resources.ResourceLocation> researchReqs, Set<net.minecraft.resources.ResourceLocation> researchExcludes, @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTable, EquipmentTypeEntry requiredTool, List<ItemStorage> inputs, net.minecraft.world.item.ItemStack primaryOutput, List<net.minecraft.world.item.ItemStack> secondaryOutput, List<net.minecraft.world.item.ItemStack> altOutputs, net.minecraft.world.level.block.Block intermediate) Creates a custom recipe from its components. -
Method Summary
Modifier and TypeMethodDescriptionstatic CustomRecipedeserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer) Deserialize from network.booleanList<net.minecraft.world.item.ItemStack> Get the alternative outputs for the recipe.Get the name of the crafter this recipe applies toSet<net.minecraft.resources.ResourceLocation> Get the IDs of research after which this recipe is no longer valid.Gets the input items for this recipenet.minecraft.world.level.block.BlockWhat is the intermediate block for this recipe?net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> Get the Loot Table, if one is present.intGet the maximum (inclusive) building level required to still consider this recipe valid.intGet the minimum (inclusive) building level required before this recipe is valid.booleanDoes this require it to already be there?net.minecraft.world.item.ItemStackGet the primary output for the recipenet.minecraft.resources.ResourceLocationGet the ID for this recipeGet the recipe storage represented by this recipeSet<net.minecraft.resources.ResourceLocation> Get the IDs of research required before this recipe is valid.@NotNull EquipmentTypeEntryGet the required tool, if any.List<net.minecraft.world.item.ItemStack> Get the secondary outputs for the recipe.booleanShould tooltip information be displayed on the client in inventory and JEI?inthashCode()booleanisValidForBuilding(IBuilding building) Check to see if the recipe is currently valid for the building This does research checks, to verify that the appropriate researches are in the correct statesstatic CustomRecipeparse(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.resources.ResourceLocation recipeId, @NotNull com.google.gson.JsonObject recipeJson) Parse a Json object into a Custom recipestatic @NotNull List<CustomRecipe> parseTemplate(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.resources.ResourceLocation baseId, @NotNull com.google.gson.JsonObject templateJson) Parse a recipe template into a list of recipes.voidserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf packetBuffer) Serialize to network.
-
Field Details
-
RECIPE_TYPE_PROP
The property name that indicates type for the recipe- See Also:
-
RECIPE_TYPE_RECIPE
The recipe type- See Also:
-
RECIPE_TYPE_RECIPE_MULT_OUT
The multiple output recipe type- See Also:
-
RECIPE_TYPE_RECIPE_MULT_IN
The multiple input recipe type- See Also:
-
RECIPE_TYPE_TEMPLATE
The recipe template type- See Also:
-
RECIPE_TYPE_REMOVE
The remove type- See Also:
-
RECIPE_ID_TO_REMOVE_PROP
The property name that indicates the recipe to remove- See Also:
-
RECIPE_CRAFTER_PROP
The property name that indicates crafter type for the recipe- See Also:
-
RECIPE_INPUTS_PROP
The property name for the inputs array- See Also:
-
RECIPE_SECONDARY_PROP
The property name for the inputs array- See Also:
-
RECIPE_ALTERNATE_PROP
The property name for the alternate output array- See Also:
-
RECIPE_RESULT_PROP
The property name for the result item- See Also:
-
RECIPE_LOOTTABLE_PROP
The property namefor the result loottable- See Also:
-
RECIPE_TOOL_PROP
The property name for the required tool- See Also:
-
RECIPE_INTERMEDIATE_PROP
The property name for the intermediate block ID- See Also:
-
RECIPE_RESEARCHID_PROP
The property name for the required research id- See Also:
-
RECIPE_EXCLUDED_RESEARCHID_PROP
The property name for the research id that invalidates this recipe- See Also:
-
RECIPE_BUILDING_MIN_LEVEL_PROP
The property name for the minimum level the building must be- See Also:
-
RECIPE_BUILDING_MAX_LEVEL_PROP
The property name for the maximum level the building can be- See Also:
-
RECIPE_MUST_EXIST
The property name for if a recipe of the inputs must exist for the recipe to be valid- See Also:
-
RECIPE_SHOW_TOOLTIP
The property name to enable tooltip display (and transmission to the client).- See Also:
-
RECIPE_TAG
The property name for a recipe template tag.- See Also:
-
RECIPE_FILTER
The property name for a recipe template filter.- See Also:
-
-
Constructor Details
-
CustomRecipe
public CustomRecipe(String crafter, int minBldgLevel, int maxBldgLevel, boolean mustExist, boolean showTooltip, net.minecraft.resources.ResourceLocation recipeId, Set<net.minecraft.resources.ResourceLocation> researchReqs, Set<net.minecraft.resources.ResourceLocation> researchExcludes, @Nullable @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTable, EquipmentTypeEntry requiredTool, List<ItemStorage> inputs, net.minecraft.world.item.ItemStack primaryOutput, List<net.minecraft.world.item.ItemStack> secondaryOutput, List<net.minecraft.world.item.ItemStack> altOutputs, net.minecraft.world.level.block.Block intermediate) Creates a custom recipe from its components.- Parameters:
crafter- The crafter for the recipe.minBldgLevel- Minimum level before the recipe can be learned.maxBldgLevel- Maximum level before buildings in the colony will remove the recipe, if learned.mustExist- If true, the custom recipe will only be learned if another recipe with the same output is taught to the building.showTooltip- If a tooltip describing the recipe should be attached to the item. Only one recipe per output should have showTooltip set to true.recipeId- The identifier for the recipe, as a resource location.researchReqs- Research IDs that the colony must have to begin the research.researchExcludes- Research IDs that will cause buildings in the colony to remove the recipe, if learned.lootTable- The loot table's resource location, if one is present.requiredTool- The tool required for this craft, if any. (In addition to any tools inferred from the recipe itself.)inputs- The consumed items, as ItemStorages.primaryOutput- The primary output of the recipe.secondaryOutput- The secondary outputs of the recipe. Most often items like buckets or tools.altOutputs- Alternative outputs of the recipe. Used to allow one taught recipe to result in multiple effective choices for the request system.
-
-
Method Details
-
parse
public static CustomRecipe parse(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.resources.ResourceLocation recipeId, @NotNull @NotNull com.google.gson.JsonObject recipeJson) Parse a Json object into a Custom recipe- Parameters:
recipeId- the recipe idrecipeJson- the json representing the recipe- Returns:
- new instance of CustomRecipe
-
parseTemplate
@NotNull public static @NotNull List<CustomRecipe> parseTemplate(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.resources.ResourceLocation baseId, @NotNull @NotNull com.google.gson.JsonObject templateJson) Parse a recipe template into a list of recipes. SeeItemStackUtils.parseIdTemplate(java.lang.String, net.minecraft.resources.ResourceLocation)for details on the template replacement format.- Parameters:
baseId- the base recipe pathtemplateJson- the recipe template- Returns:
- a list of recipes for items discovered from the template
-
getCrafter
Get the name of the crafter this recipe applies to- Returns:
- crafter name
-
getRecipeId
public net.minecraft.resources.ResourceLocation getRecipeId()Get the ID for this recipe- Returns:
- Recipe Resource Location
-
getInputs
Gets the input items for this recipe- Returns:
- input ItemStorages
-
getPrimaryOutput
public net.minecraft.world.item.ItemStack getPrimaryOutput()Get the primary output for the recipe- Returns:
- primary output ItemStack
-
getSecondaryOutput
Get the secondary outputs for the recipe.- Returns:
- secondary output ItemStacks
-
getAltOutputs
Get the alternative outputs for the recipe.- Returns:
- alternative output ItemStacks
-
getLootTable
public net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable> getLootTable()Get the Loot Table, if one is present.- Returns:
- Loot Table resource location
-
getRequiredTool
Get the required tool, if any.- Returns:
- the tool required to perform this craft
-
getRequiredResearchIds
Get the IDs of research required before this recipe is valid. All researches must be done before this recipe is valid.- Returns:
- The research IDs or empty if there is no such requirement.
-
getExcludedResearchIds
Get the IDs of research after which this recipe is no longer valid. All researches must be done before this recipe is no longer valid.- Returns:
- The research IDs or empty if there is no such requirement.
-
getMinBuildingLevel
public int getMinBuildingLevel()Get the minimum (inclusive) building level required before this recipe is valid.- Returns:
- The minimum building level (0 means no such requirement).
-
getMaxBuildingLevel
public int getMaxBuildingLevel()Get the maximum (inclusive) building level required to still consider this recipe valid.- Returns:
- The maximum building level (the recipe is no longer valid at higher levels).
-
isValidForBuilding
Check to see if the recipe is currently valid for the building This does research checks, to verify that the appropriate researches are in the correct states- Parameters:
building- Building to check recipe against.
-
getRecipeStorage
Get the recipe storage represented by this recipe- Returns:
- Recipe Storage
-
hashCode
public int hashCode() -
equals
-
getMustExist
public boolean getMustExist()Does this require it to already be there? -
getIntermediate
public net.minecraft.world.level.block.Block getIntermediate()What is the intermediate block for this recipe? -
getShowTooltip
public boolean getShowTooltip()Should tooltip information be displayed on the client in inventory and JEI? -
serialize
public void serialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf packetBuffer) Serialize to network.- Parameters:
packetBuffer- buffer to serialize into.
-
deserialize
public static CustomRecipe deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buffer) Deserialize from network.- Parameters:
buffer- network buffer.- Returns:
- deserialized recipe.
-