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 named net/minecraft/recipe/RecipeManagerintermediary net/minecraft/class_1863official czd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRecipeManager.MatchGetter<I extends RecipeInput,T extends Recipe<I>> Nested classes/interfaces inherited from interface net.minecraft.resource.ResourceReloader
ResourceReloader.Synchronizer -
Field Summary
FieldsModifier 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<Identifier, RecipeEntry<?>> private Multimap<RecipeType<?>, RecipeEntry<?>> private final RegistryWrapper.WrapperLookup -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler) Handles the prepared intermediate object.static <I extends RecipeInput,T extends Recipe<I>>
RecipeManager.MatchGetter<I, T> createCachedMatchGetter(RecipeType<T> type) Creates a cached match getter.protected static RecipeEntry<?> deserialize(Identifier id, JsonObject json, RegistryWrapper.WrapperLookup registryLookup) Reads a recipe from a JSON object.private <T extends Recipe<?>>
@Nullable RecipeEntry<T> get(RecipeType<T> type, Identifier id) Returns a recipe with the givenidandtype, or empty if there is no such recipe.Optional<RecipeEntry<?>> get(Identifier id) Returns a recipe with the givenid, or empty if there is no such recipe.<I extends RecipeInput,T extends Recipe<I>>
List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, I input, World world) Creates a list of all recipes of the giventypethat match the giveninventoryandworld.private <I extends RecipeInput,T extends Recipe<I>>
Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type) <I extends RecipeInput,T extends Recipe<I>>
Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world) Returns a recipe of the giventypethat match the giveninventoryandworld.<I extends RecipeInput,T extends Recipe<I>>
Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world, @Nullable RecipeEntry<T> recipe) <I extends RecipeInput,T extends Recipe<I>>
Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world, @Nullable Identifier id) <I extends RecipeInput,T extends Recipe<I>>
DefaultedList<ItemStack> getRemainingStacks(RecipeType<T> type, I input, 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.<I extends RecipeInput,T extends Recipe<I>>
List<RecipeEntry<T>> listAllOfType(RecipeType<T> type) Creates a list of all recipes of the giventype.voidsetRecipes(Iterable<RecipeEntry<?>> recipes) Sets the recipes for this recipe manager.values()Returns all recipes in this manager.Methods inherited from class net.minecraft.resource.JsonDataLoader
load, prepareMethods inherited from class net.minecraft.resource.SinglePreparationResourceReloader
reloadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.resource.ResourceReloader
getName
-
Field Details
-
GSON
- Mappings:
Namespace Name Mixin selector named GSONLnet/minecraft/recipe/RecipeManager;GSON:Lcom/google/gson/Gson;intermediary field_19359Lnet/minecraft/class_1863;field_19359:Lcom/google/gson/Gson;official aLczd;a:Lcom/google/gson/Gson;
-
LOGGER
- Mappings:
Namespace Name Mixin selector named LOGGERLnet/minecraft/recipe/RecipeManager;LOGGER:Lorg/slf4j/Logger;intermediary field_9027Lnet/minecraft/class_1863;field_9027:Lorg/slf4j/Logger;official bLczd;b:Lorg/slf4j/Logger;
-
registryLookup
- Mappings:
Namespace Name Mixin selector named registryLookupLnet/minecraft/recipe/RecipeManager;registryLookup:Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;intermediary field_48848Lnet/minecraft/class_1863;field_48848:Lnet/minecraft/class_7225$class_7874;official cLczd;c:Ljo$a;
-
recipesByType
- Mappings:
Namespace Name Mixin selector named recipesByTypeLnet/minecraft/recipe/RecipeManager;recipesByType:Lcom/google/common/collect/Multimap;intermediary field_51481Lnet/minecraft/class_1863;field_51481:Lcom/google/common/collect/Multimap;official dLczd;d:Lcom/google/common/collect/Multimap;
-
recipesById
- Mappings:
Namespace Name Mixin selector named recipesByIdLnet/minecraft/recipe/RecipeManager;recipesById:Ljava/util/Map;intermediary field_36308Lnet/minecraft/class_1863;field_36308:Ljava/util/Map;official eLczd;e:Ljava/util/Map;
-
errored
private 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 named erroredLnet/minecraft/recipe/RecipeManager;errored:Zintermediary field_9024Lnet/minecraft/class_1863;field_9024:Zofficial fLczd;f:Z
-
-
Constructor Details
-
RecipeManager
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/recipe/RecipeManager;<init>(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Vintermediary <init>Lnet/minecraft/class_1863;<init>(Lnet/minecraft/class_7225$class_7874;)Vofficial <init>Lczd;<init>(Ljo$a;)V
-
-
Method Details
-
apply
protected 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 classSinglePreparationResourceReloader<Map<Identifier,JsonElement>> - Parameters:
map- the prepared objectresourceManager- the resource managerprofiler- the apply profiler- Mappings:
Namespace Name Mixin selector named applyLnet/minecraft/recipe/RecipeManager;apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)Vintermediary method_20705Lnet/minecraft/class_1863;method_20705(Ljava/util/Map;Lnet/minecraft/class_3300;Lnet/minecraft/class_3695;)Vofficial aLczd;a(Ljava/util/Map;Laue;Lbnf;)V
-
isErrored
public boolean isErrored()Returns theerroredfield. This is unused in vanilla and will only returnfalsewithout mods.- Returns:
- the
erroredfield - Mappings:
Namespace Name Mixin selector named isErroredLnet/minecraft/recipe/RecipeManager;isErrored()Zintermediary method_35227Lnet/minecraft/class_1863;method_35227()Zofficial aLczd;a()Z
-
getFirstMatch
public <I extends RecipeInput,T extends Recipe<I>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, 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 typeworld- the input world- Returns:
- a recipe of the given
typethat match the giveninventoryandworld - Mappings:
Namespace Name Mixin selector named getFirstMatchLnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;)Ljava/util/Optional;intermediary method_8132Lnet/minecraft/class_1863;method_8132(Lnet/minecraft/class_3956;Lnet/minecraft/class_9695;Lnet/minecraft/class_1937;)Ljava/util/Optional;official aLczd;a(Lczf;Lczc;Ldcw;)Ljava/util/Optional;
-
getFirstMatch
public <I extends RecipeInput,T extends Recipe<I>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world, @Nullable @Nullable Identifier id) - Mappings:
Namespace Name Mixin selector named getFirstMatchLnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;Lnet/minecraft/util/Identifier;)Ljava/util/Optional;intermediary method_42299Lnet/minecraft/class_1863;method_42299(Lnet/minecraft/class_3956;Lnet/minecraft/class_9695;Lnet/minecraft/class_1937;Lnet/minecraft/class_2960;)Ljava/util/Optional;official aLczd;a(Lczf;Lczc;Ldcw;Lakr;)Ljava/util/Optional;
-
getFirstMatch
public <I extends RecipeInput,T extends Recipe<I>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world, @Nullable @Nullable RecipeEntry<T> recipe) - Mappings:
Namespace Name Mixin selector named getFirstMatchLnet/minecraft/recipe/RecipeManager;getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;Lnet/minecraft/recipe/RecipeEntry;)Ljava/util/Optional;intermediary method_59993Lnet/minecraft/class_1863;method_59993(Lnet/minecraft/class_3956;Lnet/minecraft/class_9695;Lnet/minecraft/class_1937;Lnet/minecraft/class_8786;)Ljava/util/Optional;official aLczd;a(Lczf;Lczc;Ldcw;Lczb;)Ljava/util/Optional;
-
listAllOfType
public <I extends RecipeInput,T extends Recipe<I>> List<RecipeEntry<T>> listAllOfType(RecipeType<T> type) Creates 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 named listAllOfTypeLnet/minecraft/recipe/RecipeManager;listAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/List;intermediary method_30027Lnet/minecraft/class_1863;method_30027(Lnet/minecraft/class_3956;)Ljava/util/List;official aLczd;a(Lczf;)Ljava/util/List;
-
getAllMatches
public <I extends RecipeInput,T extends Recipe<I>> List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, I input, 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 typeworld- the input world- Returns:
- the created list of matching recipes
- Mappings:
Namespace Name Mixin selector named getAllMatchesLnet/minecraft/recipe/RecipeManager;getAllMatches(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;)Ljava/util/List;intermediary method_17877Lnet/minecraft/class_1863;method_17877(Lnet/minecraft/class_3956;Lnet/minecraft/class_9695;Lnet/minecraft/class_1937;)Ljava/util/List;official bLczd;b(Lczf;Lczc;Ldcw;)Ljava/util/List;
-
getAllOfType
private <I extends RecipeInput,T extends Recipe<I>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type) - Mappings:
Namespace Name Mixin selector named getAllOfTypeLnet/minecraft/recipe/RecipeManager;getAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/Collection;intermediary method_17717Lnet/minecraft/class_1863;method_17717(Lnet/minecraft/class_3956;)Ljava/util/Collection;official cLczd;c(Lczf;)Ljava/util/Collection;
-
getRemainingStacks
public <I extends RecipeInput,T extends Recipe<I>> DefaultedList<ItemStack> getRemainingStacks(RecipeType<T> type, I input, 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 typeworld- 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 named getRemainingStacksLnet/minecraft/recipe/RecipeManager;getRemainingStacks(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;)Lnet/minecraft/util/collection/DefaultedList;intermediary method_8128Lnet/minecraft/class_1863;method_8128(Lnet/minecraft/class_3956;Lnet/minecraft/class_9695;Lnet/minecraft/class_1937;)Lnet/minecraft/class_2371;official cLczd;c(Lczf;Lczc;Ldcw;)Ljv;
-
get
Returns 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 named getLnet/minecraft/recipe/RecipeManager;get(Lnet/minecraft/util/Identifier;)Ljava/util/Optional;intermediary method_8130Lnet/minecraft/class_1863;method_8130(Lnet/minecraft/class_2960;)Ljava/util/Optional;official aLczd;a(Lakr;)Ljava/util/Optional;
-
get
@Nullable private <T extends Recipe<?>> @Nullable RecipeEntry<T> get(RecipeType<T> type, Identifier id) Returns a recipe with the givenidandtype, or empty if there is no such recipe.- Parameters:
type- the type of the desired recipeid- the ID of the desired recipe- Returns:
- a recipe with the given
idandtype, or empty if there is no such recipe - Mappings:
Namespace Name Mixin selector named getLnet/minecraft/recipe/RecipeManager;get(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/util/Identifier;)Lnet/minecraft/recipe/RecipeEntry;intermediary method_59821Lnet/minecraft/class_1863;method_59821(Lnet/minecraft/class_3956;Lnet/minecraft/class_2960;)Lnet/minecraft/class_8786;official aLczd;a(Lczf;Lakr;)Lczb;
-
sortedValues
- Mappings:
Namespace Name Mixin selector named sortedValuesLnet/minecraft/recipe/RecipeManager;sortedValues()Ljava/util/Collection;intermediary method_59822Lnet/minecraft/class_1863;method_59822()Ljava/util/Collection;official bLczd;b()Ljava/util/Collection;
-
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 valuesLnet/minecraft/recipe/RecipeManager;values()Ljava/util/Collection;intermediary method_8126Lnet/minecraft/class_1863;method_8126()Ljava/util/Collection;official dLczd;d()Ljava/util/Collection;
-
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 keysLnet/minecraft/recipe/RecipeManager;keys()Ljava/util/stream/Stream;intermediary method_8127Lnet/minecraft/class_1863;method_8127()Ljava/util/stream/Stream;official eLczd;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
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 named deserializeLnet/minecraft/recipe/RecipeManager;deserialize(Lnet/minecraft/util/Identifier;Lcom/google/gson/JsonObject;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/recipe/RecipeEntry;intermediary method_17720Lnet/minecraft/class_1863;method_17720(Lnet/minecraft/class_2960;Lcom/google/gson/JsonObject;Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_8786;official aLczd;a(Lakr;Lcom/google/gson/JsonObject;Ljo$a;)Lczb;
-
setRecipes
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 setRecipesLnet/minecraft/recipe/RecipeManager;setRecipes(Ljava/lang/Iterable;)Vintermediary method_20702Lnet/minecraft/class_1863;method_20702(Ljava/lang/Iterable;)Vofficial aLczd;a(Ljava/lang/Iterable;)V
-
createCachedMatchGetter
public static <I extends RecipeInput,T extends Recipe<I>> RecipeManager.MatchGetter<I,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 createCachedMatchGetterLnet/minecraft/recipe/RecipeManager;createCachedMatchGetter(Lnet/minecraft/recipe/RecipeType;)Lnet/minecraft/recipe/RecipeManager$MatchGetter;intermediary method_42302Lnet/minecraft/class_1863;method_42302(Lnet/minecraft/class_3956;)Lnet/minecraft/class_1863$class_7266;official bLczd;b(Lczf;)Lczd$a;
-