Package com.minecolonies.api.util
Class CraftingUtils
java.lang.Object
com.minecolonies.api.util.CraftingUtils
Utility class that handles crafting duties
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculateMaxCraftingCount(int count, @NotNull IRecipeStorage storage) Calculate the max time a recipe has to be executed.static intcalculateMaxCraftingCount(@NotNull net.minecraft.world.item.ItemStack outputStack, @NotNull IRecipeStorage storage) Calculate the max time a recipe has to be executed.static voidforEachCreativeTabItems(net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters displayParams, @NotNull BiConsumer<net.minecraft.world.item.CreativeModeTab, Collection<net.minecraft.world.item.ItemStack>> consumer) Find all items registered in creative tabs and do something with them.static OptionalPredicate<net.minecraft.world.item.ItemStack>getIngredientValidatorBasedOnTags(@NotNull String crafterJobName) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting ingredient by the specified job, based on the associated tags.static OptionalPredicate<net.minecraft.world.item.ItemStack>getIngredientValidatorBasedOnTags(@NotNull String crafterJobName, boolean includeDoRules) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting ingredient by the specified job, based on the associated tags.static OptionalPredicate<net.minecraft.world.item.ItemStack>getProductValidatorBasedOnTags(@NotNull String crafterJobName) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting product by the specified job, based on the associated tags.isRecipeCompatibleBasedOnTags(@NotNull IGenericRecipe recipe, @NotNull String crafterJobName) Checks the tags associated with the specified job to see whether the provided recipe includes products and/or ingredients that are marked as compatible or incompatible with this job.
-
Method Details
-
calculateMaxCraftingCount
public static int calculateMaxCraftingCount(@NotNull @NotNull net.minecraft.world.item.ItemStack outputStack, @NotNull @NotNull IRecipeStorage storage) Calculate the max time a recipe has to be executed.- Parameters:
outputStack- the output stack.storage- the storage.- Returns:
- the quantity.
-
calculateMaxCraftingCount
Calculate the max time a recipe has to be executed.- Parameters:
count- the count.storage- the storage.- Returns:
- the quantity.
-
getProductValidatorBasedOnTags
public static OptionalPredicate<net.minecraft.world.item.ItemStack> getProductValidatorBasedOnTags(@NotNull @NotNull String crafterJobName) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting product by the specified job, based on the associated tags.- Parameters:
crafterJobName- The name of the crafting job (defines which tags to check).- Returns:
- a validator that checks the crafting product tags.
-
getIngredientValidatorBasedOnTags
public static OptionalPredicate<net.minecraft.world.item.ItemStack> getIngredientValidatorBasedOnTags(@NotNull @NotNull String crafterJobName) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting ingredient by the specified job, based on the associated tags.- Parameters:
crafterJobName- The name of the crafting job (defines which tags to check).- Returns:
- a validator that checks the crafting ingredient tags.
-
getIngredientValidatorBasedOnTags
public static OptionalPredicate<net.minecraft.world.item.ItemStack> getIngredientValidatorBasedOnTags(@NotNull @NotNull String crafterJobName, boolean includeDoRules) Generates anOptionalPredicatethat reports whether a particular stack is allowed, banned, or undecided when used as a crafting ingredient by the specified job, based on the associated tags.- Parameters:
crafterJobName- The name of the crafting job (defines which tags to check).includeDoRules- True if applying DO overrides- Returns:
- a validator that checks the crafting ingredient tags.
-
isRecipeCompatibleBasedOnTags
public static Optional<Boolean> isRecipeCompatibleBasedOnTags(@NotNull @NotNull IGenericRecipe recipe, @NotNull @NotNull String crafterJobName) Checks the tags associated with the specified job to see whether the provided recipe includes products and/or ingredients that are marked as compatible or incompatible with this job.- Parameters:
recipe- The recipe to check.crafterJobName- The name of the crafting job (defines which tags to check).- Returns:
- True if the recipe is compatible, false if not compatible, or empty if no decision either way.
-
forEachCreativeTabItems
public static void forEachCreativeTabItems(@NotNull net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters displayParams, @NotNull @NotNull BiConsumer<net.minecraft.world.item.CreativeModeTab, Collection<net.minecraft.world.item.ItemStack>> consumer) Find all items registered in creative tabs and do something with them.- Parameters:
displayParams- the display parameters.consumer- the action to perform.
-