Class CustomRecipeManager

java.lang.Object
com.minecolonies.core.colony.crafting.CustomRecipeManager

public class CustomRecipeManager extends Object
Manager class for tracking Custom recipes during load and use This class is a singleton
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRecipe(@NotNull CustomRecipe recipe)
    Add recipe to manager.
    void
    addRecipeTemplate(@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.
    void
    buildLootData(@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.
    Get the singleton instance of this class
    getLootDrops(@Nullable net.minecraft.resources.ResourceLocation lootTableId)
    Gets the loot drops (if any) associated with a particular recipe.
    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 crafter
    void
    handleCustomRecipeManagerMessage(net.minecraft.network.FriendlyByteBuf buff)
    Ingests the custom recipes packet, and applies it to the recipe manager.
    void
    removeRecipe(@NotNull net.minecraft.resources.ResourceLocation toRemove)
    Remove recipe
    void
    Reset the entire recipe map.
    void
    Resolve the recipeTemplates into actual recipes.
    void
    sendCustomRecipeManagerPackets(net.minecraft.server.level.ServerPlayer player)
    Sends relevant Custom Recipes loaded from the Custom Recipe Manager to the client.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      public static CustomRecipeManager getInstance()
      Get the singleton instance of this class
      Returns:
    • addRecipe

      public void addRecipe(@NotNull @NotNull CustomRecipe recipe)
      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

      public Set<CustomRecipe> getRecipes(@NotNull @NotNull String crafter)
      Get all of the custom recipes that apply to a particular crafter
      Parameters:
      crafter -
      Returns:
    • getAllRecipes

      public Map<String,Map<net.minecraft.resources.ResourceLocation,CustomRecipe>> getAllRecipes()
      The complete list of custom recipes, by crafter.
    • getRecipeByOutput

      public List<CustomRecipe> getRecipeByOutput(net.minecraft.world.item.Item item)
      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

      public List<CustomRecipe> 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.
      Parameters:
      itemStack - An ItemStack to search for recipes.
      Returns:
      A list of custom recipes with that output.
    • getRecipeByOutput

      public List<CustomRecipe> 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.
      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 the recipeTemplates into 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.