Class CraftingNetwork
java.lang.Object
org.cyclops.integratedcrafting.core.network.CraftingNetwork
- All Implemented Interfaces:
ICraftingNetwork
A crafting handler network with multiple channels.
-
Constructor Summary
Constructors -
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.protected voidaddCraftingJob(int channel, CraftingJob craftingJob, ICraftingInterface craftingInterface) booleancancelCraftingJob(int channel, int craftingJobId) Cancel the given crafting job.protected voidcancelCraftingJob(CraftingJob craftingJob) protected voidcleanupChannelIfEmpty(int channel) 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.protected longcom.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.protected static com.google.common.collect.Multimap<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition,ICraftingInterface> 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.protected voidremoveCraftingJob(int channel, CraftingJob craftingJob) voidscheduleCraftingJob(CraftingJob craftingJob, boolean allowDistribution) Add the given crafting job to the list of crafting jobs.
-
Constructor Details
-
CraftingNetwork
public CraftingNetwork()
-
-
Method Details
-
newRecipeCraftingInterfacesMap
protected static com.google.common.collect.Multimap<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition,ICraftingInterface> newRecipeCraftingInterfacesMap() -
getChannels
public int[] getChannels()- Specified by:
getChannelsin interfaceICraftingNetwork- Returns:
- The channels that have at least one active position.
-
getCraftingInterfaces
Description copied from interface:ICraftingNetworkGet all crafting interfaces for the given channel.- Specified by:
getCraftingInterfacesin interfaceICraftingNetwork- Parameters:
channel- The crafting channel.- Returns:
- Crafting interfaces.
-
getRecipeCraftingInterfaces
public com.google.common.collect.Multimap<org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition,ICraftingInterface> getRecipeCraftingInterfaces(int channel) Description copied from interface:ICraftingNetworkGet the recipe to interface mapping for the given channel.- Specified by:
getRecipeCraftingInterfacesin interfaceICraftingNetwork- Parameters:
channel- The crafting channel.- Returns:
- The recipe to interface mapping.
-
getRecipeIndex
Description copied from interface:ICraftingNetworkGet the recipe index on the given channel.- Specified by:
getRecipeIndexin interfaceICraftingNetwork- Parameters:
channel- The crafting channel.- Returns:
- The index.
-
addCraftingInterface
Description copied from interface:ICraftingNetworkAdd a crafting interface to the network.- Specified by:
addCraftingInterfacein interfaceICraftingNetwork- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.- Returns:
- If the crafting interface did not exist before in the network.
-
removeCraftingInterface
Description copied from interface:ICraftingNetworkRemove a crafting interface from the network.- Specified by:
removeCraftingInterfacein interfaceICraftingNetwork- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.- Returns:
- If the crafting interface existed.
-
addCraftingInterfaceRecipe
public boolean addCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Description copied from interface:ICraftingNetworkAdd the given recipe that is owned by the given crafting interface. This should only be called for differential changes, otherwiseICraftingNetwork.addCraftingInterface(int, ICraftingInterface)should be called.- Specified by:
addCraftingInterfaceRecipein interfaceICraftingNetwork- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.recipe- The recipe to add.- Returns:
- If the recipe was added.
-
removeCraftingInterfaceRecipe
public boolean removeCraftingInterfaceRecipe(int channel, ICraftingInterface craftingInterface, org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition recipe) Description copied from interface:ICraftingNetworkRemove the given recipe that is owned by the given crafting interface. This should only be called for differential changes, otherwiseICraftingNetwork.removeCraftingInterface(int, ICraftingInterface)should be called.- Specified by:
removeCraftingInterfaceRecipein interfaceICraftingNetwork- Parameters:
channel- The channel of the interface.craftingInterface- A crafting interface.recipe- The recipe to remove.- Returns:
- If the recipe was removed.
-
scheduleCraftingJob
public void scheduleCraftingJob(CraftingJob craftingJob, boolean allowDistribution) throws UnavailableCraftingInterfacesException Description copied from interface:ICraftingNetworkAdd the given crafting job to the list of crafting jobs.- Specified by:
scheduleCraftingJobin interfaceICraftingNetwork- 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.
-
getCurrentTick
protected long getCurrentTick() -
onCraftingJobFinished
Description copied from interface:ICraftingNetworkCalled by crafting interfaces when the crafting job is finished and should be removed from all lists.- Specified by:
onCraftingJobFinishedin interfaceICraftingNetwork- Parameters:
craftingJob- The crafting job.
-
cancelCraftingJob
public boolean cancelCraftingJob(int channel, int craftingJobId) Description copied from interface:ICraftingNetworkCancel the given crafting job. This will also cancel all its dependencies.- Specified by:
cancelCraftingJobin interfaceICraftingNetwork- Parameters:
channel- A channel id.craftingJobId- The crafting job id.- Returns:
- If the crafting job existed.
-
cancelCraftingJob
-
getCraftingJobs
- Specified by:
getCraftingJobsin interfaceICraftingNetwork- Parameters:
channel- A channel id.- Returns:
- Get all present crafting jobs.
-
getCraftingJob
- Specified by:
getCraftingJobin interfaceICraftingNetwork- Parameters:
channel- A channel id.craftingJobId- A crafting job id.- Returns:
- The crafting job with the given id or null.
-
addCraftingJob
protected void addCraftingJob(int channel, CraftingJob craftingJob, ICraftingInterface craftingInterface) -
removeCraftingJob
-
getCraftingJobs
public <T,M> Iterator<CraftingJob> getCraftingJobs(int channel, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition) Description copied from interface:ICraftingNetworkGet present crafting jobs for the given (expected) output instance.- Specified by:
getCraftingJobsin interfaceICraftingNetwork- 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
- Specified by:
getCraftingJobDependencyGraphin interfaceICraftingNetwork- Returns:
- An overview of all crafting job dependencies in this network.
-
getCraftingJobInterface
Description copied from interface:ICraftingNetworkGet the interface in which the given crafting job is being crafted.- Specified by:
getCraftingJobInterfacein interfaceICraftingNetwork- Parameters:
channel- The channel.craftingJobId- A crafting job.- Returns:
- The owning crafting interface or null.
-
getRunningTicks
Description copied from interface:ICraftingNetworkCalculate the number of ticks the given job has been running.- Specified by:
getRunningTicksin interfaceICraftingNetwork- Parameters:
craftingJob- A crafting job.- Returns:
- The number of ticks this job has been running.
-
cleanupChannelIfEmpty
protected void cleanupChannelIfEmpty(int channel)
-