package org.cyclops.integrateddynamics.api.network;

import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
import org.cyclops.cyclopscore.init.IRegistry;

import java.util.Collection;

/**
 * Registry for {@link INetworkCraftingHandler}.
 * @author rubensworks
 */
public interface INetworkCraftingHandlerRegistry extends IRegistry {

    /**
     * Register a new crafting handler.
     * @param craftingHandler The crafting handler.
     * @param <C> The crafting handler type.
     * @return The registered crafting handler.
     */
    public <C extends INetworkCraftingHandler> C register(C craftingHandler);

    /**
     * @return All registered crafting handlers.
     */
    public Collection<INetworkCraftingHandler> getCraftingHandlers();

    /**
     * Check if at least one crafting handler is applicable for the given channel.
     * @param network The network to craft in.
     * @param ingredientsNetwork The ingredients network to craft in.
     * @param channel A channel.
     * @return If we can craft in the given channel.
     */
    public default <T, M> boolean canCraft(INetwork network, IPositionedAddonsNetworkIngredients<T, M> ingredientsNetwork, int channel) {
        for (INetworkCraftingHandler craftingHandler : getCraftingHandlers()) {
            if (craftingHandler.canCraft(network, ingredientsNetwork, channel)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Start a crafting job for the given instance in the given channel.
     * @param network The network to craft in.
     * @param ingredientsNetwork The ingredients network to craft in.
     * @param channel A channel.
     * @param ingredientComponent The ingredient component.
     * @param instance The instance to craft.
     * @param matchCondition The condition under which the instance should be crafted.
     * @param ignoreExistingJobs If running jobs for the given instance should be ignored,
     *                           and a new job should be started anyways.
     * @return If a crafting job could be started.
     */
    public default <T, M> boolean craft(INetwork network, IPositionedAddonsNetworkIngredients<T, M> ingredientsNetwork, int channel,
                                        IngredientComponent<T, M> ingredientComponent, T instance, M matchCondition, boolean ignoreExistingJobs) {
        for (INetworkCraftingHandler craftingHandler : getCraftingHandlers()) {
            if (craftingHandler.craft(network, ingredientsNetwork, channel, ingredientComponent, instance, matchCondition, ignoreExistingJobs)) {
                return true;
            }
        }
        return false;
    }

}

@@ -997,32 +997,134 @@
 nnel A channel.%0A
+     * @param %3CT%3E The instance type.%0A     * @param %3CM%3E The matching condition parameter, may be Void.%0A
      * @return I
@@ -2139,16 +2139,118 @@
 nyways.%0A
+     * @param %3CT%3E The instance type.%0A     * @param %3CM%3E The matching condition parameter, may be Void.%0A
      * @

Add missing javadoc params in INetworkCraftingHandlerRegistry