Interface ICraftingNetwork

All Known Implementing Classes:
CraftingNetwork

public interface ICraftingNetwork
A network capability for crafting.
  • Method Details

    • getChannels

      int[] getChannels()
      Returns:
      The channels that have at least one active position.
    • getCraftingInterfaces

      Set<ICraftingInterface> getCraftingInterfaces(int channel)
      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

      IRecipeIndex getRecipeIndex(int channel)
      Get the recipe index on the given channel.
      Parameters:
      channel - The crafting channel.
      Returns:
      The index.
    • addCraftingInterface

      boolean addCraftingInterface(int channel, ICraftingInterface craftingInterface)
      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

      boolean removeCraftingInterface(int channel, ICraftingInterface craftingInterface)
      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, otherwise addCraftingInterface(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, otherwise removeCraftingInterface(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

      void onCraftingJobFinished(CraftingJob craftingJob)
      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

      Iterator<CraftingJob> getCraftingJobs(int channel)
      Parameters:
      channel - A channel id.
      Returns:
      Get all present crafting jobs.
    • getCraftingJob

      @Nullable CraftingJob getCraftingJob(int channel, int craftingJobId)
      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

      @Nullable ICraftingInterface getCraftingJobInterface(int channel, int craftingJobId)
      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

      long getRunningTicks(CraftingJob craftingJob)
      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.