Class CraftingHelpers
java.lang.Object
org.cyclops.integratedcrafting.core.CraftingHelpers
Helpers related to handling crafting jobs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceGenerates semi-unique IDs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T1,M1, T2, M2>
voidaddRemainderAsSurplusForComponent(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T1, M1> ingredientComponent, List<T1> instances, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<T1, M1> simulatedExtractionMemory, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T2, M2> blackListComponent, T2 blacklistInstance, M2 blacklistCondition, long blacklistQuantity) static voidbeforeCalculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel) If the network is guaranteed to have uncommitted changes (such as the one in #48), forcefully run observers synchronously, so that we can calculate the job in a consistent network state.static CraftingJobcalculateAndScheduleCraftingJob(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, boolean allowDistribution, CraftingHelpers.IIdentifierGenerator identifierGenerator, UUID initiator) Schedule a crafting job for the given recipe in the given network.static <T,M> CraftingJob calculateAndScheduleCraftingJob(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, boolean allowDistribution, CraftingHelpers.IIdentifierGenerator identifierGenerator, UUID initiator) Schedule a crafting job for the given instance in the given network.protected static <T,M> PartialCraftingJobCalculationDependency calculateCraftingJobDependencyComponent(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> dependencyComponent, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> dependenciesOutputSurplus, MissingIngredients<T, M> missingIngredients, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, Map<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition, CraftingJob> dependencies, IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) protected static PartialCraftingJobCalculationcalculateCraftingJobs(IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, boolean collectMissingRecipes) Calculate a crafting job for the given recipe.protected static <T,M> CraftingJob calculateCraftingJobs(IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, boolean collectMissingRecipes) Calculate a crafting job for the given instance.static CraftingJobcalculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) Calculate the required crafting jobs and their dependencies for the given instance in the given network.static <T,M> CraftingJob calculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) Calculate the required crafting jobs and their dependencies for the given instance in the given network.static <T,M> MissingIngredients<T, M> compressMissingIngredients(MissingIngredients<T, M> missingIngredients) Compress the given missing ingredients so that equal instances just have an incremented quantity.protected static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredientscompressMixedIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients mixedIngredients) Stack all ingredients in the given mixed ingredients object.static <T,M> List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M>> getCompressedIngredients(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients mixedIngredients) Create a list of prototyped ingredients from the instances of the given ingredient component type in the given mixed ingredients.static net.minecraftforge.common.util.LazyOptional<ICraftingNetwork>getCraftingNetwork(org.cyclops.integrateddynamics.api.network.INetwork network) Get the crafting network in the given network.static ICraftingNetworkgetCraftingNetworkChecked(org.cyclops.integrateddynamics.api.network.INetwork network) Get the crafting network in the given network.static <T,M> List<T> getIngredientRecipeInputs(org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storage, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, long recipeOutputQuantity) Get all required recipe input ingredients from the network for the given ingredient component.static <T,M> org.apache.commons.lang3.tuple.Pair<List<T>, MissingIngredients<T, M>> getIngredientRecipeInputs(org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storage, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<T, M> simulatedExtractionMemory, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<T, M> extractionMemoryReusable, boolean collectMissingIngredients, long recipeOutputQuantity) Get all required recipe input ingredients from the network for the given ingredient component, and optionally, explicitly calculate the missing ingredients.static <T,M> net.minecraftforge.common.util.LazyOptional<org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients<T, M>> getIngredientsNetwork(org.cyclops.integrateddynamics.api.network.INetwork network, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the storage network of the given type in the given network.static <T,M> org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients<T, M> getIngredientsNetworkChecked(org.cyclops.integrateddynamics.api.network.INetwork network, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the storage network of the given type in the given network.static org.cyclops.integrateddynamics.api.network.INetworkgetNetworkChecked(org.cyclops.integrateddynamics.api.part.PartPos pos) Get the network at the given position, or throw a PartStateException if it is null.static <T,M> org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> getNetworkStorage(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, boolean scheduleObservation) Get the storage of the given ingredient component type from the network.static Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> getNetworkStorageGetter(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean scheduleObservation) Create a callback function for getting a storage for an ingredient component from the given network channel.static <T,M> long getOutputQuantityForRecipe(org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Calculate the effective quantity for the given instance in the output of the given recipe.static org.apache.commons.lang3.tuple.Pair<Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, List<?>>, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, MissingIngredients<?, ?>>> getRecipeInputs(Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemories, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoriesReusable, boolean collectMissingIngredients, long recipeOutputQuantity) Get all required recipe input ingredients based on a given storage callback.static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredientsgetRecipeInputs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, long recipeOutputQuantity) Get all required recipe input ingredients from the network.static Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> getRecipeOutputs(org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Create a collection of prototypes from the given recipe's outputs.static <T,M> long getStorageInstanceQuantity(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check the quantity of the given instance in the network.static <T,M> boolean hasStorageInstance(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check if the given network contains the given instance in any of its storages.static booleaninsertCrafting(Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.integrateddynamics.api.part.PartPos> targetGetter, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean simulate) Insert the ingredients of all applicable ingredient component types into the target to make it start crafting.static <T,M> boolean insertIngredientCrafting(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, net.minecraftforge.common.capabilities.ICapabilityProvider capabilityProvider, net.minecraft.core.Direction side, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storageFallback, boolean simulate) Insert the ingredients of the given ingredient component type into the target to make it start crafting.static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredientsinsertIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, boolean simulate) Insert the given ingredients into the given storage networks.static booleanisCrafting(ICraftingNetwork craftingNetwork, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Check if there is a scheduled crafting job for the given recipe.static <T,M> boolean isCrafting(ICraftingNetwork craftingNetwork, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check if there is a scheduled crafting job for the given instance.static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredientsmergeMixedIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients a, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients b) Merge two mixed ingredients in a new mixed ingredients object.static <T,M> org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M> multiplyPrototypedIngredient(org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M> prototypedIngredient, long amount) Multiply the quantity of a given prototyped ingredient with the given amount.static <T,M> List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M>> multiplyPrototypedIngredients(Collection<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M>> prototypedIngredients, long amount) Multiply the quantity of a given prototyped ingredient list with the given amount.static Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> multiplyRecipeOutputs(Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> recipeOutputs, int amount) Creates a new recipe outputs object with all ingredient quantities multiplied by the given amount.static CraftingJobscheduleCraftingJob(ICraftingNetwork craftingNetwork, CraftingJob craftingJob, boolean allowDistribution, UUID initiator) Schedule the given crafting job in the given network.static voidscheduleCraftingJobs(ICraftingNetwork craftingNetwork, CraftingJobDependencyGraph craftingJobDependencyGraph, boolean allowDistribution, UUID initiator) Schedule all crafting jobs in the given dependency graph in the given network.static List<CraftingJob>splitCraftingJobs(CraftingJob craftingJob, int splitFactor, CraftingJobDependencyGraph dependencyGraph, CraftingHelpers.IIdentifierGenerator identifierGenerator) Split the given crafting job amount into new jobs with a given split factor.
-
Constructor Details
-
CraftingHelpers
public CraftingHelpers()
-
-
Method Details
-
getNetworkChecked
public static org.cyclops.integrateddynamics.api.network.INetwork getNetworkChecked(org.cyclops.integrateddynamics.api.part.PartPos pos) throws org.cyclops.integrateddynamics.api.PartStateException Get the network at the given position, or throw a PartStateException if it is null.- Parameters:
pos- A position.- Returns:
- A network.
- Throws:
org.cyclops.integrateddynamics.api.PartStateException- If the network could not be found.
-
getCraftingNetwork
public static net.minecraftforge.common.util.LazyOptional<ICraftingNetwork> getCraftingNetwork(@Nullable org.cyclops.integrateddynamics.api.network.INetwork network) Get the crafting network in the given network.- Parameters:
network- A network.- Returns:
- The crafting network.
-
getCraftingNetworkChecked
public static ICraftingNetwork getCraftingNetworkChecked(@Nullable org.cyclops.integrateddynamics.api.network.INetwork network) Get the crafting network in the given network.- Parameters:
network- A network.- Returns:
- The crafting network.
-
getIngredientsNetwork
public static <T,M> net.minecraftforge.common.util.LazyOptional<org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients<T,M>> getIngredientsNetwork(org.cyclops.integrateddynamics.api.network.INetwork network, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the storage network of the given type in the given network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- A network.ingredientComponent- The ingredient component type of the network.- Returns:
- The storage network.
-
getIngredientsNetworkChecked
public static <T,M> org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients<T,M> getIngredientsNetworkChecked(org.cyclops.integrateddynamics.api.network.INetwork network, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the storage network of the given type in the given network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- A network.ingredientComponent- The ingredient component type of the network.- Returns:
- The storage network.
-
getNetworkStorage
public static <T,M> org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T,M> getNetworkStorage(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, boolean scheduleObservation) Get the storage of the given ingredient component type from the network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- The network.channel- A network channel.ingredientComponent- The ingredient component type of the network.scheduleObservation- If an observation inside the ingredients network should be scheduled.- Returns:
- The storage.
-
beforeCalculateCraftingJobs
public static void beforeCalculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel) If the network is guaranteed to have uncommitted changes (such as the one in #48), forcefully run observers synchronously, so that we can calculate the job in a consistent network state.- Parameters:
network- The network.channel- A network channel.
-
calculateCraftingJobs
public static <T,M> CraftingJob calculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) throws UnknownCraftingRecipeException, RecursiveCraftingRecipeExceptionCalculate the required crafting jobs and their dependencies for the given instance in the given network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- The target network.channel- The target channel.ingredientComponent- The ingredient component type of the instance.instance- The instance to craft.matchCondition- The match condition of the instance.craftMissing- If the missing required ingredients should also be crafted.identifierGenerator- identifierGenerator An ID generator for crafting jobs.craftingJobsGraph- The target graph where all dependencies will be stored.collectMissingRecipes- If the missing recipes should be collected insideUnknownCraftingRecipeException. This may slow down calculation for deeply nested recipe graphs.- Returns:
- The crafting job for the given instance.
- Throws:
UnknownCraftingRecipeException- If the recipe for a (sub)ingredient is unavailable.RecursiveCraftingRecipeException- If an infinite recursive recipe was detected.
-
calculateCraftingJobs
public static CraftingJob calculateCraftingJobs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) throws FailedCraftingRecipeException, RecursiveCraftingRecipeException Calculate the required crafting jobs and their dependencies for the given instance in the given network.- Parameters:
network- The target network.channel- The target channel.recipe- The recipe to calculate a job for.amount- The amount of times the recipe should be crafted.craftMissing- If the missing required ingredients should also be crafted.identifierGenerator- identifierGenerator An ID generator for crafting jobs.craftingJobsGraph- The target graph where all dependencies will be stored.collectMissingRecipes- If the missing recipes should be collected insideFailedCraftingRecipeException. This may slow down calculation for deeply nested recipe graphs.- Returns:
- The crafting job for the given instance.
- Throws:
FailedCraftingRecipeException- If the recipe could not be crafted due to missing sub-dependencies.RecursiveCraftingRecipeException- If an infinite recursive recipe was detected.
-
getGlobalCraftingJobIdentifier
- Returns:
- An identifier generator for crafting jobs.
-
getOutputQuantityForRecipe
public static <T,M> long getOutputQuantityForRecipe(org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Calculate the effective quantity for the given instance in the output of the given recipe.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
recipe- A recipe.ingredientComponent- The ingredient component.instance- An instance.matchCondition- A match condition.- Returns:
- The effective quantity.
-
calculateCraftingJobs
protected static <T,M> CraftingJob calculateCraftingJobs(IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, throws UnknownCraftingRecipeException, RecursiveCraftingRecipeExceptionorg.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, boolean collectMissingRecipes) Calculate a crafting job for the given instance. This method is merely an easily-stubbable implementation for the method above, to simplify unit testing.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
recipeIndex- The recipe index.channel- The target channel that will be stored in created crafting jobs.storageGetter- A callback function to get a storage for the given ingredient component.ingredientComponent- The ingredient component type of the instance.instance- The instance to craft.matchCondition- The match condition of the instance.craftMissing- If the missing required ingredients should also be crafted.simulatedExtractionMemory- This map remembers all extracted instances in simulation mode. This is to make sure that instances can not be extracted multiple times when simulating.extractionMemoryReusable- Like simulatedExtractionMemory, but it stores the reusable ingredients.identifierGenerator- An ID generator for crafting jobs.craftingJobsGraph- The target graph where all dependencies will be stored.parentDependencies- A set of parent recipe dependencies that are pending. This is used to check for infinite recursion in recipes.collectMissingRecipes- If the missing recipes should be collected insideUnknownCraftingRecipeException. This may slow down calculation for deeply nested recipe graphs.- Returns:
- The crafting job for the given instance.
- Throws:
UnknownCraftingRecipeException- If the recipe for a (sub)ingredient is unavailable.RecursiveCraftingRecipeException- If an infinite recursive recipe was detected.
-
calculateCraftingJobs
protected static PartialCraftingJobCalculation calculateCraftingJobs(IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, throws RecursiveCraftingRecipeExceptionorg.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, boolean collectMissingRecipes) Calculate a crafting job for the given recipe. This method is merely an easily-stubbable implementation for the method above, to simplify unit testing.- Parameters:
recipeIndex- The recipe index.channel- The target channel that will be stored in created crafting jobs.storageGetter- A callback function to get a storage for the given ingredient component.recipe- The recipe to calculate a job for.amount- The amount of times the recipe should be crafted.craftMissing- If the missing required ingredients should also be crafted.simulatedExtractionMemory- This map remembers all extracted instances in simulation mode. This is to make sure that instances can not be extracted multiple times when simulating.extractionMemoryReusable- Like simulatedExtractionMemory, but it stores the reusable ingredients.identifierGenerator- An ID generator for crafting jobs.craftingJobsGraph- The target graph where all dependencies will be stored.parentDependencies- A set of parent recipe dependencies that are pending. This is used to check for infinite recursion in recipes.collectMissingRecipes- If the missing recipes should be collected insideUnknownCraftingRecipeException. This may slow down calculation for deeply nested recipe graphs.- Returns:
- The crafting job for the given instance.
- Throws:
RecursiveCraftingRecipeException- If an infinite recursive recipe was detected.
-
calculateCraftingJobDependencyComponent
protected static <T,M> PartialCraftingJobCalculationDependency calculateCraftingJobDependencyComponent(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> dependencyComponent, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, throws RecursiveCraftingRecipeException?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> dependenciesOutputSurplus, MissingIngredients<T, M> missingIngredients, Set<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient> parentDependencies, Map<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition, CraftingJob> dependencies, IRecipeIndex recipeIndex, int channel, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemory, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoryReusable, CraftingHelpers.IIdentifierGenerator identifierGenerator, CraftingJobDependencyGraph craftingJobsGraph, boolean collectMissingRecipes) - Throws:
RecursiveCraftingRecipeException
-
addRemainderAsSurplusForComponent
protected static <T1,M1, void addRemainderAsSurplusForComponentT2, M2> (org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T1, M1> ingredientComponent, List<T1> instances, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<T1, M1> simulatedExtractionMemory, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T2, M2> blackListComponent, T2 blacklistInstance, M2 blacklistCondition, long blacklistQuantity) -
scheduleCraftingJobs
public static void scheduleCraftingJobs(ICraftingNetwork craftingNetwork, CraftingJobDependencyGraph craftingJobDependencyGraph, boolean allowDistribution, @Nullable UUID initiator) throws UnavailableCraftingInterfacesException Schedule all crafting jobs in the given dependency graph in the given network.- Parameters:
craftingNetwork- The target crafting network.craftingJobDependencyGraph- The crafting job dependency graph.allowDistribution- If the crafting jobs are allowed to be split over multiple crafting interfaces.initiator- Optional UUID of the initiator.- Throws:
UnavailableCraftingInterfacesException- If no crafting interfaces were available.
-
scheduleCraftingJob
public static CraftingJob scheduleCraftingJob(ICraftingNetwork craftingNetwork, CraftingJob craftingJob, boolean allowDistribution, @Nullable UUID initiator) throws UnavailableCraftingInterfacesException Schedule the given crafting job in the given network.- Parameters:
craftingNetwork- The target crafting network.craftingJob- The crafting job to schedule.allowDistribution- If the crafting job is allowed to be split over multiple crafting interfaces.initiator- Optional UUID of the initiator.- Returns:
- The scheduled crafting job.
- Throws:
UnavailableCraftingInterfacesException- If no crafting interfaces were available.
-
calculateAndScheduleCraftingJob
@Nullable public static <T,M> CraftingJob calculateAndScheduleCraftingJob(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean craftMissing, boolean allowDistribution, CraftingHelpers.IIdentifierGenerator identifierGenerator, @Nullable UUID initiator) Schedule a crafting job for the given instance in the given network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- The target network.channel- The target channel.ingredientComponent- The ingredient component type of the instance.instance- The instance to craft.matchCondition- The match condition of the instance.craftMissing- If the missing required ingredients should also be crafted.allowDistribution- If the crafting job is allowed to be split over multiple crafting interfaces.identifierGenerator- An ID generator for crafting jobs.initiator- Optional UUID of the initiator.- Returns:
- The scheduled crafting job, or null if no recipe was found.
-
calculateAndScheduleCraftingJob
@Nullable public static CraftingJob calculateAndScheduleCraftingJob(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, int amount, boolean craftMissing, boolean allowDistribution, CraftingHelpers.IIdentifierGenerator identifierGenerator, @Nullable UUID initiator) Schedule a crafting job for the given recipe in the given network.- Parameters:
network- The target network.channel- The target channel.recipe- The recipe to craft.amount- The amount to craft.craftMissing- If the missing required ingredients should also be crafted.allowDistribution- If the crafting job is allowed to be split over multiple crafting interfaces.identifierGenerator- An ID generator for crafting jobs.initiator- Optional UUID of the initiator.- Returns:
- The scheduled crafting job, or null if no recipe was found.
-
hasStorageInstance
public static <T,M> boolean hasStorageInstance(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check if the given network contains the given instance in any of its storages.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- The target network.channel- The target channel.ingredientComponent- The ingredient component type of the instance.instance- The instance to check.matchCondition- The match condition of the instance.- Returns:
- If the instance is present in the network.
-
getStorageInstanceQuantity
public static <T,M> long getStorageInstanceQuantity(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check the quantity of the given instance in the network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
network- The target network.channel- The target channel.ingredientComponent- The ingredient component type of the instance.instance- The instance to check.matchCondition- The match condition of the instance.- Returns:
- The quantity in the network.
-
isCrafting
public static <T,M> boolean isCrafting(ICraftingNetwork craftingNetwork, int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Check if there is a scheduled crafting job for the given instance.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
craftingNetwork- The target crafting network.channel- The target channel.ingredientComponent- The ingredient component type of the instance.instance- The instance to check.matchCondition- The match condition of the instance.- Returns:
- If the instance has a crafting job.
-
isCrafting
public static boolean isCrafting(ICraftingNetwork craftingNetwork, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Check if there is a scheduled crafting job for the given recipe.- Parameters:
craftingNetwork- The target crafting network.channel- The target channel.recipe- The recipe to check.- Returns:
- If the instance has a crafting job.
-
getIngredientRecipeInputs
@Nullable public static <T,M> List<T> getIngredientRecipeInputs(org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storage, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, long recipeOutputQuantity) Get all required recipe input ingredients from the network for the given ingredient component. If multiple alternative inputs are possible, then only the first possible match will be taken. Note: Make sure that you first call in simulation-mode to see if the ingredients are available. If you immediately call this non-simulated, then there might be a chance that ingredients are lost from the network.- Type Parameters:
T- The instance type.M- The matching condition parameter, may be Void.- Parameters:
storage- The target storage.ingredientComponent- The ingredient component to get the ingredients for.recipe- The recipe to get the inputs from.simulate- If true, then the ingredients will effectively be removed from the network, not when false.recipeOutputQuantity- The number of times the given recipe should be applied.- Returns:
- A list of slot-based ingredients, or null if no valid inputs could be found.
-
getIngredientRecipeInputs
public static <T,M> org.apache.commons.lang3.tuple.Pair<List<T>,MissingIngredients<T, getIngredientRecipeInputsM>> (org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storage, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<T, M> simulatedExtractionMemory, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<T, M> extractionMemoryReusable, boolean collectMissingIngredients, long recipeOutputQuantity) Get all required recipe input ingredients from the network for the given ingredient component, and optionally, explicitly calculate the missing ingredients. If multiple alternative inputs are possible, then only the first possible match will be taken. Note: Make sure that you first call in simulation-mode to see if the ingredients are available. If you immediately call this non-simulated, then there might be a chance that ingredients are lost from the network.- Type Parameters:
T- The instance type.M- The matching condition parameter, may be Void.- Parameters:
storage- The target storage.ingredientComponent- The ingredient component to get the ingredients for.recipe- The recipe to get the inputs from.simulate- If true, then the ingredients will effectively be removed from the network, not when false.simulatedExtractionMemory- This map remembers all extracted instances in simulation mode. This is to make sure that instances can not be extracted multiple times when simulating. The quantities can also go negatives, which means that a surplus of the given instance is present, which will be used up first before a call to the storage.extractionMemoryReusable- Like simulatedExtractionMemory, but it stores the reusable ingredients.collectMissingIngredients- If missing ingredients should be collected. If false, then the first returned list may be null if no valid matches can be found, and the second returned list is always null,recipeOutputQuantity- The number of times the given recipe should be applied.- Returns:
- A pair with two lists: 1. A list of available slot-based ingredients. 2. A missing ingredients object.
-
getRecipeInputs
@Nullable public static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients getRecipeInputs(org.cyclops.integrateddynamics.api.network.INetwork network, int channel, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, long recipeOutputQuantity) Get all required recipe input ingredients from the network. If multiple alternative inputs are possible, then only the first possible match will be taken. Note: Make sure that you first call in simulation-mode to see if the ingredients are available. If you immediately call this non-simulated, then there might be a chance that ingredients are lost from the network.- Parameters:
network- The target network.channel- The target channel.recipe- The recipe to get the inputs from.simulate- If true, then the ingredients will effectively be removed from the network, not when false.recipeOutputQuantity- The number of times the given recipe should be applied.- Returns:
- The found ingredients or null.
-
getNetworkStorageGetter
public static Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, getNetworkStorageGetterorg.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> (org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean scheduleObservation) Create a callback function for getting a storage for an ingredient component from the given network channel.- Parameters:
network- The target network.channel- The target channel.scheduleObservation- If an observation inside the ingredients network should be scheduled.- Returns:
- A callback function for getting a storage for an ingredient component.
-
getRecipeInputs
public static org.apache.commons.lang3.tuple.Pair<Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, getRecipeInputsList<?>>, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, MissingIngredients<?, ?>>> (Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe, boolean simulate, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionPrototypeMap<?, ?>> simulatedExtractionMemories, Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable<?, ?>> extractionMemoriesReusable, boolean collectMissingIngredients, long recipeOutputQuantity) Get all required recipe input ingredients based on a given storage callback. If multiple alternative inputs are possible, then only the first possible match will be taken. Note: Make sure that you first call in simulation-mode to see if the ingredients are available. If you immediately call this non-simulated, then there might be a chance that ingredients are lost from the network.- Parameters:
storageGetter- A callback function to get a storage for the given ingredient component.recipe- The recipe to get the inputs from.simulate- If true, then the ingredients will effectively be removed from the network, not when false.simulatedExtractionMemories- This map remembers all extracted instances in simulation mode. This is to make sure that instances can not be extracted multiple times when simulating.extractionMemoriesReusable- Like simulatedExtractionMemories, but it stores the reusable ingredients.collectMissingIngredients- If missing ingredients should be collected. If false, then the first returned mixed ingredients may be null if no valid matches can be found, and the second returned list is always null,recipeOutputQuantity- The number of times the given recipe should be applied.- Returns:
- A pair with two objects: 1. The found ingredients or null. 2. A mapping from ingredient component to missing ingredients (non-slot-based).
-
getCompressedIngredients
public static <T,M> List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T,M>> getCompressedIngredients(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients mixedIngredients) Create a list of prototyped ingredients from the instances of the given ingredient component type in the given mixed ingredients. Equal prototypes will be stacked.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
ingredientComponent- The ingredient component type.mixedIngredients- The mixed ingredients.- Returns:
- A list of prototypes.
-
compressMissingIngredients
public static <T,M> MissingIngredients<T,M> compressMissingIngredients(MissingIngredients<T, M> missingIngredients) Compress the given missing ingredients so that equal instances just have an incremented quantity.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
missingIngredients- The missing ingredients.- Returns:
- A new missing ingredients object.
-
getRecipeOutputs
public static Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, getRecipeOutputsList<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> (org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Create a collection of prototypes from the given recipe's outputs. Equal prototypes will be stacked.- Parameters:
recipe- A recipe.- Returns:
- A map from ingredient component types to their list of prototypes.
-
multiplyRecipeOutputs
public static Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?,?>, multiplyRecipeOutputsList<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> (Map<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<?, ?>>> recipeOutputs, int amount) Creates a new recipe outputs object with all ingredient quantities multiplied by the given amount.- Parameters:
recipeOutputs- A recipe objects holder.amount- An amount to multiply all instances by.- Returns:
- A new recipe objects holder.
-
multiplyPrototypedIngredients
public static <T,M> List<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T,M>> multiplyPrototypedIngredients(Collection<org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M>> prototypedIngredients, long amount) Multiply the quantity of a given prototyped ingredient list with the given amount.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
prototypedIngredients- A prototyped ingredient list.amount- An amount to multiply by.- Returns:
- A multiplied prototyped ingredient list.
-
multiplyPrototypedIngredient
public static <T,M> org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T,M> multiplyPrototypedIngredient(org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient<T, M> prototypedIngredient, long amount) Multiply the quantity of a given prototyped ingredient with the given amount.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
prototypedIngredient- A prototyped ingredient.amount- An amount to multiply by.- Returns:
- A multiplied prototyped ingredient.
-
mergeMixedIngredients
public static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients mergeMixedIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients a, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients b) Merge two mixed ingredients in a new mixed ingredients object. Instances will be stacked.- Parameters:
a- A first mixed ingredients object.b- A second mixed ingredients object.- Returns:
- A merged mixed ingredients object.
-
compressMixedIngredients
protected static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients compressMixedIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients mixedIngredients) Stack all ingredients in the given mixed ingredients object.- Parameters:
mixedIngredients- A mixed ingredients object.- Returns:
- A new mixed ingredients object.
-
insertIngredientCrafting
public static <T,M> boolean insertIngredientCrafting(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, net.minecraftforge.common.capabilities.ICapabilityProvider capabilityProvider, @Nullable net.minecraft.core.Direction side, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T, M> storageFallback, boolean simulate) Insert the ingredients of the given ingredient component type into the target to make it start crafting. If insertion in non-simulation mode fails, ingredients will be re-inserted into the network.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
ingredientComponent- The ingredient component type.capabilityProvider- The target capability provider.side- The target side.ingredients- The ingredients to insert.storageFallback- The storage to insert any failed ingredients back into. Can be null in simulation mode.simulate- If insertion should be simulated.- Returns:
- If all instances could be inserted.
-
insertCrafting
public static boolean insertCrafting(Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.integrateddynamics.api.part.PartPos> targetGetter, org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, org.cyclops.integrateddynamics.api.network.INetwork network, int channel, boolean simulate) Insert the ingredients of all applicable ingredient component types into the target to make it start crafting. If insertion in non-simulation mode fails, ingredients will be re-inserted into the network.- Parameters:
targetGetter- A function to get the target position.ingredients- The ingredients to insert.network- The network.channel- The channel.simulate- If insertion should be simulated.- Returns:
- If all instances could be inserted.
-
splitCraftingJobs
public static List<CraftingJob> splitCraftingJobs(CraftingJob craftingJob, int splitFactor, CraftingJobDependencyGraph dependencyGraph, CraftingHelpers.IIdentifierGenerator identifierGenerator) Split the given crafting job amount into new jobs with a given split factor.- Parameters:
craftingJob- A crafting job to split.splitFactor- The number of jobs to split the job over.dependencyGraph- The dependency graph that will be updated if there are dependencies in the original job.identifierGenerator- An identifier generator for the crafting jobs ids.- Returns:
- The newly created crafting jobs.
-
insertIngredients
public static org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients insertIngredients(org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients ingredients, Function<org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<?, ?>, org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage> storageGetter, boolean simulate) Insert the given ingredients into the given storage networks.- Parameters:
ingredients- A collection of ingredients.storageGetter- A storage network getter.simulate- If insertion should be simulated.- Returns:
- The remaining ingredients that were not inserted.
-