Class RecipeCache<T extends BotanyPotRecipe>
java.lang.Object
net.darkhax.botanypots.common.api.data.recipes.RecipeCache<T>
- Type Parameters:
T- The type of recipe held by the cache.
An experimental cache that makes looking up botany pot recipes faster.
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.Multimap<net.minecraft.world.item.Item, net.minecraft.world.item.crafting.RecipeHolder<T>> Gets a map of all cached values.booleanisCached(net.minecraft.world.item.ItemStack stack) Checks if an item exists in the cache.@Nullable net.minecraft.world.item.crafting.RecipeHolder<T> lookup(net.minecraft.world.item.ItemStack stack, BotanyPotContext context, net.minecraft.world.level.Level level) Looks up an item in the cache.static <T extends BotanyPotRecipe>
net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<T>> Creates a new cache for a given recipe type.
-
Method Details
-
isCached
public boolean isCached(net.minecraft.world.item.ItemStack stack) Checks if an item exists in the cache.- Parameters:
stack- The item to test.- Returns:
- If the item has at least one match in the lookup cache.
-
getCachedValues
public com.google.common.collect.Multimap<net.minecraft.world.item.Item,net.minecraft.world.item.crafting.RecipeHolder<T>> getCachedValues()Gets a map of all cached values.- Returns:
- The lookup cache.
-
lookup
@Nullable public @Nullable net.minecraft.world.item.crafting.RecipeHolder<T> lookup(net.minecraft.world.item.ItemStack stack, BotanyPotContext context, net.minecraft.world.level.Level level) Looks up an item in the cache.- Parameters:
stack- The item to lookup.context- The context of the lookup.level- The current game level.- Returns:
- The recipe that best matches the provided information.
-
of
public static <T extends BotanyPotRecipe> net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<T>> of(Supplier<net.minecraft.world.item.crafting.RecipeType<T>> type) Creates a new cache for a given recipe type.- Type Parameters:
T- The type of the recipe.- Parameters:
type- The type of recipe to build a cache for.- Returns:
- The created recipe cache.
-