Interface ICraftingNetwork
- All Known Implementing Classes:
CraftingNetwork
public interface ICraftingNetwork
A network capability for crafting.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddCraftingInterface(int channel, ICraftingInterface craftingInterface) Add a crafting interface to the network.booleanaddCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Add the given recipe that is owned by the given crafting interface.booleancancelCraftingJob(int channel, int craftingJobId) Cancel the given crafting job.int[]getCraftingInterfaces(int channel) Get all crafting interfaces for the given channel.getCraftingJob(int channel, int craftingJobId) getCraftingJobInterface(int channel, int craftingJobId) Get the interface in which the given crafting job is being crafted.getCraftingJobs(int channel) <T,M> Iterator<CraftingJob> getCraftingJobs(int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Get present crafting jobs for the given (expected) output instance.com.google.common.collect.Multimap<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition,ICraftingInterface> getRecipeCraftingInterfaces(int channel) Get the recipe to interface mapping for the given channel.getRecipeIndex(int channel) Get the recipe index on the given channel.longgetRunningTicks(CraftingJob craftingJob) Calculate the number of ticks the given job has been running.voidonCraftingJobFinished(CraftingJob craftingJob) Called by crafting interfaces when the crafting job is finished and should be removed from all lists.booleanremoveCraftingInterface(int channel, ICraftingInterface craftingInterface) Remove a crafting interface from the network.booleanremoveCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Remove the given recipe that is owned by the given crafting interface.voidscheduleCraftingJob(CraftingJob craftingJob, boolean allowDistribution) Add the given crafting job to the list of crafting jobs.
-
Method Details
-
getChannels
int[] getChannels()- Returns:
- The channels that have at least one active position.
-
getCraftingInterfaces
Get all crafting interfaces for the given channel.- Parameters:
channel- The crafting channel.- Returns:
- Crafting interfaces.
-
getRecipeCraftingInterfaces
com.google.common.collect.Multimap<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition,ICraftingInterface> getRecipeCraftingInterfaces(int channel) Get the recipe to interface mapping for the given channel.- Parameters:
channel- The crafting channel.- Returns:
- The recipe to interface mapping.
-
getRecipeIndex
Get the recipe index on the given channel.- Parameters:
channel- The crafting channel.- Returns:
- The index.
-
addCraftingInterface
Add a crafting interface to the network.- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.- Returns:
- If the crafting interface did not exist before in the network.
-
removeCraftingInterface
Remove a crafting interface from the network.- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.- Returns:
- If the crafting interface existed.
-
addCraftingInterfaceRecipe
boolean addCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Add the given recipe that is owned by the given crafting interface. This should only be called for differential changes, otherwiseaddCraftingInterface(int, ICraftingInterface)should be called.- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.recipe- The recipe to add.- Returns:
- If the recipe was added.
-
removeCraftingInterfaceRecipe
boolean removeCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Remove the given recipe that is owned by the given crafting interface. This should only be called for differential changes, otherwiseremoveCraftingInterface(int, ICraftingInterface)should be called.- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.recipe- The recipe to remove.- Returns:
- If the recipe was removed.
-
scheduleCraftingJob
void scheduleCraftingJob(CraftingJob craftingJob, boolean allowDistribution) throws UnavailableCraftingInterfacesException Add the given crafting job to the list of crafting jobs.- Parameters:
craftingJob- The crafting job.allowDistribution- If the crafting job is allowed to be split over multiple crafting interfaces.- Throws:
UnavailableCraftingInterfacesException- If no crafting interfaces were available.
-
onCraftingJobFinished
Called by crafting interfaces when the crafting job is finished and should be removed from all lists.- Parameters:
craftingJob- The crafting job.
-
cancelCraftingJob
boolean cancelCraftingJob(int channel, int craftingJobId) Cancel the given crafting job. This will also cancel all its dependencies.- Parameters:
channel- A channel id.craftingJobId- The crafting job id.- Returns:
- If the crafting job existed.
-
getCraftingJobs
- Parameters:
channel- A channel id.- Returns:
- Get all present crafting jobs.
-
getCraftingJob
- Parameters:
channel- A channel id.craftingJobId- A crafting job id.- Returns:
- The crafting job with the given id or null.
-
getCraftingJobs
<T,M> Iterator<CraftingJob> getCraftingJobs(int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Get present crafting jobs for the given (expected) output instance.- Type Parameters:
T- The instance type.M- The matching condition parameter.- Parameters:
channel- The channel.ingredientComponent- The ingredient component of the given output type.instance- The expected output instance.matchCondition- The matching condition under which the instance should be matched.- Returns:
- The applicable crafting jobs, can be empty.
-
getCraftingJobDependencyGraph
CraftingJobDependencyGraph getCraftingJobDependencyGraph()- Returns:
- An overview of all crafting job dependencies in this network.
-
getCraftingJobInterface
Get the interface in which the given crafting job is being crafted.- Parameters:
channel- The channel.craftingJobId- A crafting job.- Returns:
- The owning crafting interface or null.
-
getRunningTicks
Calculate the number of ticks the given job has been running.- Parameters:
craftingJob- A crafting job.- Returns:
- The number of ticks this job has been running.
-