Package net.minecraft.recipe
Class RecipeManager
java.lang.Object
net.minecraft.resource.SinglePreparationResourceReloader<Map<Identifier,JsonElement>>
 
net.minecraft.resource.JsonDataLoader
net.minecraft.recipe.RecipeManager
- All Implemented Interfaces:
- ResourceReloader
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 - official - cjd- intermediary - net/minecraft/class_1863- named - net/minecraft/recipe/RecipeManager
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceNested classes/interfaces inherited from interface net.minecraft.resource.ResourceReloaderResourceReloader.Synchronizer
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate booleanThis isn't quite indicating an errored state; its value is only set tofalseand is nevertrue, and isn't used anywhere.private static final Gsonprivate static final Loggerprivate Map<RecipeType<?>,Map<Identifier, Recipe<?>>> private Map<Identifier,Recipe<?>> 
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidapply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler) Handles the prepared intermediate object.static <C extends Inventory,T extends Recipe<C>> 
 RecipeManager.MatchGetter<C,T> createCachedMatchGetter(RecipeType<T> type) Creates a cached match getter.static Recipe<?>deserialize(Identifier id, JsonObject json) Reads a recipe from a JSON object.get(Identifier id) Returns a recipe with the givenid, or empty if there is no such recipe.getAllMatches(RecipeType<T> type, C inventory, World world) Creates a list of all recipes of the giventypethat match the giveninventoryandworld.private <C extends Inventory,T extends Recipe<C>> 
 Map<Identifier,T> getAllOfType(RecipeType<T> type) getFirstMatch(RecipeType<T> type, C inventory, World world) Returns a recipe of the giventypethat match the giveninventoryandworld.<C extends Inventory,T extends Recipe<C>> 
 Optional<com.mojang.datafixers.util.Pair<Identifier,T>> getFirstMatch(RecipeType<T> type, C inventory, World world, @Nullable Identifier id) <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 giventypethat match the giveninventoryandworld, or a shallow copy of theinventory.booleanReturns theerroredfield.keys()Returns a stream of IDs of recipes in this manager.listAllOfType(RecipeType<T> type) Creates a list of all recipes of the giventype.voidsetRecipes(Iterable<Recipe<?>> recipes) Sets the recipes for this recipe manager.Collection<Recipe<?>>values()Returns all recipes in this manager.Methods inherited from class net.minecraft.resource.JsonDataLoaderload, prepareMethods inherited from class net.minecraft.resource.SinglePreparationResourceReloaderreloadMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.resource.ResourceReloadergetName
- 
Field Details- 
GSON- Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a:Lcom/google/gson/Gson;- intermediary - field_19359- Lnet/minecraft/class_1863;field_19359:Lcom/google/gson/Gson;- named - GSON- Lnet/minecraft/recipe/RecipeManager;GSON:Lcom/google/gson/Gson;
 
- 
LOGGER- Mappings:
- Namespace - Name - Mixin selector - official - b- Lcjd;b:Lorg/slf4j/Logger;- intermediary - field_9027- Lnet/minecraft/class_1863;field_9027:Lorg/slf4j/Logger;- named - LOGGER- Lnet/minecraft/recipe/RecipeManager;LOGGER:Lorg/slf4j/Logger;
 
- 
recipes- Mappings:
- Namespace - Name - Mixin selector - official - c- Lcjd;c:Ljava/util/Map;- intermediary - field_9023- Lnet/minecraft/class_1863;field_9023:Ljava/util/Map;- named - recipes- Lnet/minecraft/recipe/RecipeManager;recipes:Ljava/util/Map;
 
- 
recipesById- Mappings:
- Namespace - Name - Mixin selector - official - d- Lcjd;d:Ljava/util/Map;- intermediary - field_36308- Lnet/minecraft/class_1863;field_36308:Ljava/util/Map;- named - recipesById- Lnet/minecraft/recipe/RecipeManager;recipesById:Ljava/util/Map;
 
- 
erroredprivate boolean erroredThis isn't quite indicating an errored state; its value is only set tofalseand is nevertrue, and isn't used anywhere.- Mappings:
- Namespace - Name - Mixin selector - official - e- Lcjd;e:Z- intermediary - field_9024- Lnet/minecraft/class_1863;field_9024:Z- named - errored- Lnet/minecraft/recipe/RecipeManager;errored:Z
 
 
- 
- 
Constructor Details- 
RecipeManagerpublic RecipeManager()
 
- 
- 
Method Details- 
applyprotected void apply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler) Description copied from class:SinglePreparationResourceReloaderHandles the prepared intermediate object.This method is called in the apply executor, or the game engine, in a reload. - Specified by:
- applyin class- SinglePreparationResourceReloader<Map<Identifier,- JsonElement>> 
- Parameters:
- map- the prepared object
- resourceManager- the resource manager
- profiler- the apply profiler
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a(Ljava/util/Map;Lakx;Lban;)V- intermediary - method_20705- Lnet/minecraft/class_1863;method_20705(Ljava/util/Map;Lnet/minecraft/class_3300;Lnet/minecraft/class_3695;)V- named - apply- Lnet/minecraft/recipe/RecipeManager;apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V
 
- 
isErroredpublic boolean isErrored()Returns theerroredfield. This is unused in vanilla and will only returnfalsewithout mods.- Returns:
- the erroredfield
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a()Z- intermediary - method_35227- Lnet/minecraft/class_1863;method_35227()Z- named - isErrored- Lnet/minecraft/recipe/RecipeManager;isErrored()Z
 
- 
getFirstMatchpublic <C extends Inventory,T extends Recipe<C>> Optional<T> getFirstMatch(RecipeType<T> type, C inventory, World world) Returns a recipe of the giventypethat match the giveninventoryandworld.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 typethat match the giveninventoryandworld
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a(Lcjf;Lbdq;Lcmm;)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;- named - getFirstMatch- Lnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Ljava/util/Optional;
 
- 
getFirstMatchpublic <C extends Inventory,T extends Recipe<C>> Optional<com.mojang.datafixers.util.Pair<Identifier,T>> getFirstMatch(RecipeType<T> type, C inventory, World world, @Nullable @Nullable Identifier id) - Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a(Lcjf;Lbdq;Lcmm;Lacq;)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;- 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;
 
- 
listAllOfTypeCreates a list of all recipes of the giventype. 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 - official - a- Lcjd;a(Lcjf;)Ljava/util/List;- intermediary - method_30027- Lnet/minecraft/class_1863;method_30027(Lnet/minecraft/class_3956;)Ljava/util/List;- named - listAllOfType- Lnet/minecraft/recipe/RecipeManager;listAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/List;
 
- 
getAllMatchespublic <C extends Inventory,T extends Recipe<C>> List<T> getAllMatches(RecipeType<T> type, C inventory, World world) Creates a list of all recipes of the giventypethat match the giveninventoryandworld. 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 - official - b- Lcjd;b(Lcjf;Lbdq;Lcmm;)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;- named - getAllMatches- Lnet/minecraft/recipe/RecipeManager;getAllMatches(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Ljava/util/List;
 
- 
getAllOfTypeprivate <C extends Inventory,T extends Recipe<C>> Map<Identifier,T> getAllOfType(RecipeType<T> type) - Mappings:
- Namespace - Name - Mixin selector - official - c- Lcjd;c(Lcjf;)Ljava/util/Map;- intermediary - method_17717- Lnet/minecraft/class_1863;method_17717(Lnet/minecraft/class_3956;)Ljava/util/Map;- named - getAllOfType- Lnet/minecraft/recipe/RecipeManager;getAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/Map;
 
- 
getRemainingStackspublic <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 giventypethat match the giveninventoryandworld, or a shallow copy of theinventory.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 typethat match the giveninventoryandworld, or a shallow copy of theinventory
- See Also:
- Mappings:
- Namespace - Name - Mixin selector - official - c- Lcjd;c(Lcjf;Lbdq;Lcmm;)Lhn;- 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;- named - getRemainingStacks- Lnet/minecraft/recipe/RecipeManager;getRemainingStacks(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;)Lnet/minecraft/util/collection/DefaultedList;
 
- 
getReturns a recipe with the givenid, 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 - official - a- Lcjd;a(Lacq;)Ljava/util/Optional;- intermediary - method_8130- Lnet/minecraft/class_1863;method_8130(Lnet/minecraft/class_2960;)Ljava/util/Optional;- named - get- Lnet/minecraft/recipe/RecipeManager;get(Lnet/minecraft/util/Identifier;)Ljava/util/Optional;
 
- 
valuesReturns 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 - official - b- Lcjd;b()Ljava/util/Collection;- intermediary - method_8126- Lnet/minecraft/class_1863;method_8126()Ljava/util/Collection;- named - values- Lnet/minecraft/recipe/RecipeManager;values()Ljava/util/Collection;
 
- 
keysReturns 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 - official - d- Lcjd;d()Ljava/util/stream/Stream;- intermediary - method_8127- Lnet/minecraft/class_1863;method_8127()Ljava/util/stream/Stream;- named - keys- Lnet/minecraft/recipe/RecipeManager;keys()Ljava/util/stream/Stream;
 
- 
deserializeReads a recipe from a JSON object.- Parameters:
- id- the recipe's ID
- json- the recipe JSON
- Returns:
- the read recipe
- Throws:
- JsonParseException- if the recipe JSON is invalid
- See Also:
- Implementation Note:
- Even though a recipe's serializer
 is stored in a typefield in the JSON format and referred so in this method, its registry has keyminecraft:root/minecraft:recipe_serializerand is thus named.
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lcjd;a(Lacq;Lcom/google/gson/JsonObject;)Lcjc;- intermediary - method_17720- Lnet/minecraft/class_1863;method_17720(Lnet/minecraft/class_2960;Lcom/google/gson/JsonObject;)Lnet/minecraft/class_1860;- named - deserialize- Lnet/minecraft/recipe/RecipeManager;deserialize(Lnet/minecraft/util/Identifier;Lcom/google/gson/JsonObject;)Lnet/minecraft/recipe/Recipe;
 
- 
setRecipesSets 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 - official - a- Lcjd;a(Ljava/lang/Iterable;)V- intermediary - method_20702- Lnet/minecraft/class_1863;method_20702(Ljava/lang/Iterable;)V- named - setRecipes- Lnet/minecraft/recipe/RecipeManager;setRecipes(Ljava/lang/Iterable;)V
 
- 
createCachedMatchGetterpublic 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 - official - b- Lcjd;b(Lcjf;)Lcjd$a;- intermediary - method_42302- Lnet/minecraft/class_1863;method_42302(Lnet/minecraft/class_3956;)Lnet/minecraft/class_1863$class_7266;- named - createCachedMatchGetter- Lnet/minecraft/recipe/RecipeManager;createCachedMatchGetter(Lnet/minecraft/recipe/RecipeType;)Lnet/minecraft/recipe/RecipeManager$MatchGetter;
 
 
-