Class CustomRecipeManager
java.lang.Object
com.minecolonies.core.colony.crafting.CustomRecipeManager
Manager class for tracking Custom recipes during load and use
This class is a singleton
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecipe(@NotNull CustomRecipe recipe) Add recipe to manager.voidaddRecipeTemplate(@NotNull net.minecraft.resources.ResourceLocation id, @NotNull com.google.gson.JsonObject templateJson) Temporarily stores a recipe template while waiting for the tags to finish loading.voidbuildLootData(@NotNull net.minecraft.world.level.storage.loot.LootDataManager lootTableManager, @NotNull net.minecraft.world.level.Level level) Analyses and builds an approximate list of possible loot drops from registered recipes.Map<String,Map<net.minecraft.resources.ResourceLocation, CustomRecipe>> The complete list of custom recipes, by crafter.static CustomRecipeManagerGet the singleton instance of this class@NotNull List<LootTableAnalyzer.LootDrop>getLootDrops(@Nullable net.minecraft.resources.ResourceLocation lootTableId) Gets the loot drops (if any) associated with a particular recipe.getRecipeByOutput(ItemStorage itemStorage) Gets the custom recipes for an ItemStorage, optionally including comparing count, damage, and NBT, or an empty list if no matching recipe exists.getRecipeByOutput(net.minecraft.world.item.Item item) Get the custom recipes for an item, or an empty list if no matching recipe exists.getRecipeByOutput(net.minecraft.world.item.ItemStack itemStack) Gets the custom recipes for an ItemStack, including comparing count and tags, or an empty list if no matching recipe exists.getRecipes(@NotNull String crafter) Get all of the custom recipes that apply to a particular craftervoidhandleCustomRecipeManagerMessage(net.minecraft.network.FriendlyByteBuf buff) Ingests the custom recipes packet, and applies it to the recipe manager.voidremoveRecipe(@NotNull net.minecraft.resources.ResourceLocation toRemove) Remove recipevoidreset()Reset the entire recipe map.voidResolve therecipeTemplatesinto actual recipes.voidsendCustomRecipeManagerPackets(net.minecraft.server.level.ServerPlayer player) Sends relevant Custom Recipes loaded from the Custom Recipe Manager to the client.
-
Method Details
-
getInstance
Get the singleton instance of this class- Returns:
-
addRecipe
Add recipe to manager.- Parameters:
recipe- the recipe to add
-
removeRecipe
public void removeRecipe(@NotNull @NotNull net.minecraft.resources.ResourceLocation toRemove) Remove recipe- Parameters:
toRemove-
-
addRecipeTemplate
public void addRecipeTemplate(@NotNull @NotNull net.minecraft.resources.ResourceLocation id, @NotNull @NotNull com.google.gson.JsonObject templateJson) Temporarily stores a recipe template while waiting for the tags to finish loading.- Parameters:
id- the resource id of the template.templateJson- the template content.
-
reset
public void reset()Reset the entire recipe map. Should be run on Data Pack Reloads, to avoid transferring settings from another world. -
getRecipes
Get all of the custom recipes that apply to a particular crafter- Parameters:
crafter-- Returns:
-
getAllRecipes
The complete list of custom recipes, by crafter. -
getRecipeByOutput
Get the custom recipes for an item, or an empty list if no matching recipe exists.- Parameters:
item- An individual item to search for recipes.- Returns:
- A list of custom recipes with that output.
-
getRecipeByOutput
Gets the custom recipes for an ItemStack, including comparing count and tags, or an empty list if no matching recipe exists.- Parameters:
itemStack- An ItemStack to search for recipes.- Returns:
- A list of custom recipes with that output.
-
getRecipeByOutput
Gets the custom recipes for an ItemStorage, optionally including comparing count, damage, and NBT, or an empty list if no matching recipe exists.- Parameters:
itemStorage- An ItemStorage to search for recipes.- Returns:
- A list of custom recipes with that output.
-
getLootDrops
@NotNull public @NotNull List<LootTableAnalyzer.LootDrop> getLootDrops(@Nullable @Nullable net.minecraft.resources.ResourceLocation lootTableId) Gets the loot drops (if any) associated with a particular recipe. These are just informational and shouldn't be used to actually generate loot.- Parameters:
lootTableId- The loot table id of the recipe.- Returns:
- The loot drops.
-
resolveTemplates
public void resolveTemplates()Resolve therecipeTemplatesinto actual recipes. Must be called server-side-only after tags have been loaded and before we sync to client. -
buildLootData
public void buildLootData(@NotNull @NotNull net.minecraft.world.level.storage.loot.LootDataManager lootTableManager, @NotNull @NotNull net.minecraft.world.level.Level level) Analyses and builds an approximate list of possible loot drops from registered recipes.- Parameters:
lootTableManager- the loot table manager
-
sendCustomRecipeManagerPackets
public void sendCustomRecipeManagerPackets(net.minecraft.server.level.ServerPlayer player) Sends relevant Custom Recipes loaded from the Custom Recipe Manager to the client.- Parameters:
player- the player to send the new data to.
-
handleCustomRecipeManagerMessage
public void handleCustomRecipeManagerMessage(net.minecraft.network.FriendlyByteBuf buff) Ingests the custom recipes packet, and applies it to the recipe manager.- Parameters:
buff- packet buffer containing the received data.
-