Class RecipeManager

All Implemented Interfaces:
ResourceReloader

public class RecipeManager extends JsonDataLoader
A recipe manager allows easier use of recipes, such as finding matches and remainders. It is also integrated with a recipe loader, which loads recipes from data packs' JSON files.
Mappings:
Namespace Name
named net/minecraft/recipe/RecipeManager
intermediary net/minecraft/class_1863
official cza
  • Field Details

    • GSON

      private static final Gson GSON
      Mappings:
      Namespace Name Mixin selector
      named GSON Lnet/minecraft/recipe/RecipeManager;GSON:Lcom/google/gson/Gson;
      intermediary field_19359 Lnet/minecraft/class_1863;field_19359:Lcom/google/gson/Gson;
      official a Lcza;a:Lcom/google/gson/Gson;
    • LOGGER

      private static final Logger LOGGER
      Mappings:
      Namespace Name Mixin selector
      named LOGGER Lnet/minecraft/recipe/RecipeManager;LOGGER:Lorg/slf4j/Logger;
      intermediary field_9027 Lnet/minecraft/class_1863;field_9027:Lorg/slf4j/Logger;
      official b Lcza;b:Lorg/slf4j/Logger;
    • registryLookup

      private final RegistryWrapper.WrapperLookup registryLookup
      Mappings:
      Namespace Name Mixin selector
      named registryLookup Lnet/minecraft/recipe/RecipeManager;registryLookup:Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;
      intermediary field_48848 Lnet/minecraft/class_1863;field_48848:Lnet/minecraft/class_7225$class_7874;
      official c Lcza;c:Ljk$a;
    • recipesByType

      private Multimap<RecipeType<?>,RecipeEntry<?>> recipesByType
      Mappings:
      Namespace Name Mixin selector
      named recipesByType Lnet/minecraft/recipe/RecipeManager;recipesByType:Lcom/google/common/collect/Multimap;
      intermediary field_51481 Lnet/minecraft/class_1863;field_51481:Lcom/google/common/collect/Multimap;
      official d Lcza;d:Lcom/google/common/collect/Multimap;
    • recipesById

      private Map<Identifier,RecipeEntry<?>> recipesById
      Mappings:
      Namespace Name Mixin selector
      named recipesById Lnet/minecraft/recipe/RecipeManager;recipesById:Ljava/util/Map;
      intermediary field_36308 Lnet/minecraft/class_1863;field_36308:Ljava/util/Map;
      official e Lcza;e:Ljava/util/Map;
    • errored

      private boolean errored
      This isn't quite indicating an errored state; its value is only set to false and is never true, and isn't used anywhere.
      Mappings:
      Namespace Name Mixin selector
      named errored Lnet/minecraft/recipe/RecipeManager;errored:Z
      intermediary field_9024 Lnet/minecraft/class_1863;field_9024:Z
      official f Lcza;f:Z
  • Constructor Details

    • RecipeManager

      public RecipeManager(RegistryWrapper.WrapperLookup registryLookup)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/recipe/RecipeManager;<init>(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)V
      intermediary <init> Lnet/minecraft/class_1863;<init>(Lnet/minecraft/class_7225$class_7874;)V
      official <init> Lcza;<init>(Ljk$a;)V
  • Method Details

    • apply

      protected void apply(Map<Identifier,JsonElement> map, ResourceManager resourceManager, Profiler profiler)
      Description copied from class: SinglePreparationResourceReloader
      Handles the prepared intermediate object.

      This method is called in the apply executor, or the game engine, in a reload.

      Specified by:
      apply in class SinglePreparationResourceReloader<Map<Identifier,JsonElement>>
      Parameters:
      map - the prepared object
      resourceManager - the resource manager
      profiler - the apply profiler
      Mappings:
      Namespace Name Mixin selector
      named apply Lnet/minecraft/recipe/RecipeManager;apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V
      intermediary method_20705 Lnet/minecraft/class_1863;method_20705(Ljava/util/Map;Lnet/minecraft/class_3300;Lnet/minecraft/class_3695;)V
      official a Lcza;a(Ljava/util/Map;Laup;Lbnk;)V
    • isErrored

      public boolean isErrored()
      Returns the errored field. This is unused in vanilla and will only return false without mods.
      Returns:
      the errored field
      Mappings:
      Namespace Name Mixin selector
      named isErrored Lnet/minecraft/recipe/RecipeManager;isErrored()Z
      intermediary method_35227 Lnet/minecraft/class_1863;method_35227()Z
      official a Lcza;a()Z
    • getFirstMatch

      public <C extends Inventory, T extends Recipe<C>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, C inventory, World world)
      Returns a recipe of the given type that match the given inventory and world.

      If there are multiple matching recipes, the result is arbitrary, but this method will return the same result unless the recipes in this manager are updated.

      Parameters:
      type - the desired recipe type
      inventory - the input inventory
      world - the input world
      Returns:
      a recipe of the given type that match the given inventory and world
      Mappings:
      Namespace Name Mixin selector
      named getFirstMatch Lnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Ljava/util/Optional;
      intermediary method_8132 Lnet/minecraft/class_1863;method_8132(Lnet/minecraft/class_3956;Lnet/minecraft/class_1263;Lnet/minecraft/class_1937;)Ljava/util/Optional;
      official a Lcza;a(Lczc;Lbqp;Ldca;)Ljava/util/Optional;
    • getFirstMatch

      public <C extends Inventory, T extends Recipe<C>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, C inventory, World world, @Nullable @Nullable Identifier id)
      Mappings:
      Namespace Name Mixin selector
      named getFirstMatch Lnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;Lnet/minecraft/util/Identifier;)Ljava/util/Optional;
      intermediary method_42299 Lnet/minecraft/class_1863;method_42299(Lnet/minecraft/class_3956;Lnet/minecraft/class_1263;Lnet/minecraft/class_1937;Lnet/minecraft/class_2960;)Ljava/util/Optional;
      official a Lcza;a(Lczc;Lbqp;Ldca;Lalf;)Ljava/util/Optional;
    • listAllOfType

      public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> listAllOfType(RecipeType<T> type)
      Creates a list of all recipes of the given type. The list has an arbitrary order.

      This list does not update with this manager. Modifications to the returned list do not affect this manager.

      Parameters:
      type - the desired recipe type
      Returns:
      the created list of recipes of the given type
      Mappings:
      Namespace Name Mixin selector
      named listAllOfType Lnet/minecraft/recipe/RecipeManager;listAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/List;
      intermediary method_30027 Lnet/minecraft/class_1863;method_30027(Lnet/minecraft/class_3956;)Ljava/util/List;
      official a Lcza;a(Lczc;)Ljava/util/List;
    • getAllMatches

      public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, C inventory, World world)
      Creates a list of all recipes of the given type that match the given inventory and world. The list is ordered by the translation key of the output item stack of each recipe.

      This list does not update with this manager. Modifications to the returned list do not affect this manager.

      Parameters:
      type - the desired recipe type
      inventory - the input inventory
      world - the input world
      Returns:
      the created list of matching recipes
      Mappings:
      Namespace Name Mixin selector
      named getAllMatches Lnet/minecraft/recipe/RecipeManager;getAllMatches(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Ljava/util/List;
      intermediary method_17877 Lnet/minecraft/class_1863;method_17877(Lnet/minecraft/class_3956;Lnet/minecraft/class_1263;Lnet/minecraft/class_1937;)Ljava/util/List;
      official b Lcza;b(Lczc;Lbqp;Ldca;)Ljava/util/List;
    • getAllOfType

      private <C extends Inventory, T extends Recipe<C>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type)
      Mappings:
      Namespace Name Mixin selector
      named getAllOfType Lnet/minecraft/recipe/RecipeManager;getAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/Collection;
      intermediary method_17717 Lnet/minecraft/class_1863;method_17717(Lnet/minecraft/class_3956;)Ljava/util/Collection;
      official c Lcza;c(Lczc;)Ljava/util/Collection;
    • getRemainingStacks

      public <C extends Inventory, T extends Recipe<C>> DefaultedList<ItemStack> getRemainingStacks(RecipeType<T> type, C inventory, World world)
      Returns the remainder of a recipe of the given type that match the given inventory and world, or a shallow copy of the inventory.

      This retrieves the remainders of getFirstMatch(type, inventory, world) if the match exists.

      Parameters:
      type - the desired recipe type
      inventory - the input inventory
      world - the input world
      Returns:
      the remainder of a recipe of the given type that match the given inventory and world, or a shallow copy of the inventory
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named getRemainingStacks Lnet/minecraft/recipe/RecipeManager;getRemainingStacks(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Lnet/minecraft/util/collection/DefaultedList;
      intermediary method_8128 Lnet/minecraft/class_1863;method_8128(Lnet/minecraft/class_3956;Lnet/minecraft/class_1263;Lnet/minecraft/class_1937;)Lnet/minecraft/class_2371;
      official c Lcza;c(Lczc;Lbqp;Ldca;)Ljr;
    • get

      public Optional<RecipeEntry<?>> get(Identifier id)
      Returns a recipe with the given id, or empty if there is no such recipe.
      Parameters:
      id - the ID of the desired recipe
      Returns:
      a recipe with the given id, or empty if there is no such recipe
      Mappings:
      Namespace Name Mixin selector
      named get Lnet/minecraft/recipe/RecipeManager;get(Lnet/minecraft/util/Identifier;)Ljava/util/Optional;
      intermediary method_8130 Lnet/minecraft/class_1863;method_8130(Lnet/minecraft/class_2960;)Ljava/util/Optional;
      official a Lcza;a(Lalf;)Ljava/util/Optional;
    • get

      @Nullable private <T extends Recipe<?>> @Nullable RecipeEntry<T> get(RecipeType<T> type, Identifier id)
      Returns a recipe with the given id and type, or empty if there is no such recipe.
      Parameters:
      type - the type of the desired recipe
      id - the ID of the desired recipe
      Returns:
      a recipe with the given id and type, or empty if there is no such recipe
      Mappings:
      Namespace Name Mixin selector
      named get Lnet/minecraft/recipe/RecipeManager;get(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/util/Identifier;)Lnet/minecraft/recipe/RecipeEntry;
      intermediary method_59821 Lnet/minecraft/class_1863;method_59821(Lnet/minecraft/class_3956;Lnet/minecraft/class_2960;)Lnet/minecraft/class_8786;
      official a Lcza;a(Lczc;Lalf;)Lcyz;
    • sortedValues

      public Collection<RecipeEntry<?>> sortedValues()
      Mappings:
      Namespace Name Mixin selector
      named sortedValues Lnet/minecraft/recipe/RecipeManager;sortedValues()Ljava/util/Collection;
      intermediary method_59822 Lnet/minecraft/class_1863;method_59822()Ljava/util/Collection;
      official b Lcza;b()Ljava/util/Collection;
    • values

      public Collection<RecipeEntry<?>> values()
      Returns all recipes in this manager.

      The returned set does not update with the manager. Modifications to the returned set does not affect this manager.

      Returns:
      all recipes in this manager
      Mappings:
      Namespace Name Mixin selector
      named values Lnet/minecraft/recipe/RecipeManager;values()Ljava/util/Collection;
      intermediary method_8126 Lnet/minecraft/class_1863;method_8126()Ljava/util/Collection;
      official d Lcza;d()Ljava/util/Collection;
    • keys

      public Stream<Identifier> keys()
      Returns a stream of IDs of recipes in this manager.

      The returned stream does not update after setRecipes(Iterable) call.

      Returns:
      a stream of IDs of recipes in this manager
      API Note:
      This is used by the command sources to suggest recipe IDs for command arguments.
      Mappings:
      Namespace Name Mixin selector
      named keys Lnet/minecraft/recipe/RecipeManager;keys()Ljava/util/stream/Stream;
      intermediary method_8127 Lnet/minecraft/class_1863;method_8127()Ljava/util/stream/Stream;
      official e Lcza;e()Ljava/util/stream/Stream;
    • deserialize

      protected static RecipeEntry<?> deserialize(Identifier id, JsonObject json, RegistryWrapper.WrapperLookup registryLookup)
      Reads a recipe from a JSON object.
      Parameters:
      id - the recipe's ID
      Returns:
      the read recipe
      Throws:
      JsonParseException - if the recipe JSON is invalid
      Implementation Note:
      Even though a recipe's serializer is stored in a type field in the JSON format and referred so in this method, its registry has key minecraft:root/minecraft:recipe_serializer and is thus named.
      Mappings:
      Namespace Name Mixin selector
      named deserialize Lnet/minecraft/recipe/RecipeManager;deserialize(Lnet/minecraft/util/Identifier;Lcom/google/gson/JsonObject;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/recipe/RecipeEntry;
      intermediary method_17720 Lnet/minecraft/class_1863;method_17720(Lnet/minecraft/class_2960;Lcom/google/gson/JsonObject;Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_8786;
      official a Lcza;a(Lalf;Lcom/google/gson/JsonObject;Ljk$a;)Lcyz;
    • setRecipes

      public void setRecipes(Iterable<RecipeEntry<?>> recipes)
      Sets the recipes for this recipe manager. Used by the client to set the server side recipes.
      Parameters:
      recipes - the recipes to set
      Mappings:
      Namespace Name Mixin selector
      named setRecipes Lnet/minecraft/recipe/RecipeManager;setRecipes(Ljava/lang/Iterable;)V
      intermediary method_20702 Lnet/minecraft/class_1863;method_20702(Ljava/lang/Iterable;)V
      official a Lcza;a(Ljava/lang/Iterable;)V
    • createCachedMatchGetter

      public static <C extends Inventory, T extends Recipe<C>> RecipeManager.MatchGetter<C,T> createCachedMatchGetter(RecipeType<T> type)
      Creates a cached match getter. This is optimized for getting matches of the same recipe repeatedly, such as furnaces.
      Mappings:
      Namespace Name Mixin selector
      named createCachedMatchGetter Lnet/minecraft/recipe/RecipeManager;createCachedMatchGetter(Lnet/minecraft/recipe/RecipeType;)Lnet/minecraft/recipe/RecipeManager$MatchGetter;
      intermediary method_42302 Lnet/minecraft/class_1863;method_42302(Lnet/minecraft/class_3956;)Lnet/minecraft/class_1863$class_7266;
      official b Lcza;b(Lczc;)Lcza$a;