Interface CacheableRecipe
- All Known Implementing Classes:
BasicCrop,BasicFertilizer,BasicPotInteraction,BasicSoil,BlockDerivedCrop,BlockDerivedSoil
public interface CacheableRecipe
Cacheable recipes are used to improve lookup times for simple recipes that only consider the input Item. Cacheable
recipes should NOT care about additional context, like the world, player, pot, or components on the ItemStack.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if recipe can be cached based on the deserialized contents of the recipe.booleanisCacheKey(net.minecraft.world.item.ItemStack stack) Determines if a given item would be a valid cache key for this recipe.
-
Method Details
-
canBeCached
boolean canBeCached()Determines if recipe can be cached based on the deserialized contents of the recipe. For example, imagine a recipe with an optional list of non-cacheable conditions. If this list is not present or empty, the recipe could be cached when it otherwise could not.- Returns:
- If the recipe can be cached.
-
isCacheKey
boolean isCacheKey(net.minecraft.world.item.ItemStack stack) Determines if a given item would be a valid cache key for this recipe. Recipes can have more than one valid key.Implementations should only check intrinsic properties of the stack like the item id, tags, and the type of the item. Properties like data components should not be checked as these are not intrinsic to the item. An ItemStack is only provided in this context because it is needed to test Ingredient.
- Parameters:
stack- The item to test.- Returns:
- If the item is a valid cache key for this recipe.
-