package mcjty.rftools.jei;

import mcjty.lib.varia.ItemStackList;
import mcjty.rftools.network.RFToolsMessages;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;

@JEIPlugin
public class RFToolsJeiPlugin extends BlankModPlugin {

    public static void transferRecipe(Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients, BlockPos pos) {
        ItemStackList items = ItemStackList.create(10);
        for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> entry : guiIngredients.entrySet()) {
            int recipeSlot = entry.getKey();
            List<ItemStack> allIngredients = entry.getValue().getAllIngredients();
            if (!allIngredients.isEmpty()) {
                items.set(recipeSlot, allIngredients.get(0));
            }
        }

        RFToolsMessages.INSTANCE.sendToServer(new PacketSendRecipe(items, pos));
    }

    @Override
    public void register(@Nonnull IModRegistry registry) {
        IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
        ModularStorageRecipeTransferHandler.register(transferRegistry, new CrafterRecipeTransferHandler());
        ModularStorageRecipeTransferHandler.register(transferRegistry, new ModularStorageRecipeTransferHandler());
        ModularStorageRecipeTransferHandler.register(transferRegistry, new ModularStorageItemRecipeTransferHandler());
        ModularStorageRecipeTransferHandler.register(transferRegistry, new RemoteStorageItemRecipeTransferHandler());
        ModularStorageRecipeTransferHandler.register(transferRegistry, new StorageScannerRecipeTransferHandler());
    }
}

@@ -1328,38 +1328,31 @@
 ();%0A        
-ModularStorage
+Crafter
 RecipeTransf
@@ -1554,32 +1554,36 @@
   ModularStorage
+Item
 RecipeTransferHa
@@ -1667,38 +1667,41 @@
 ));%0A        
-Modular
+Remote
 Storage
+Item
 RecipeTransf
@@ -1788,38 +1788,38 @@
 ));%0A        
-Modular
 Storage
+Scanner
 RecipeTransf

Call the right register methods