package net.geforcemods.securitycraft.compat.jei;

import java.util.stream.Collectors;

import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.geforcemods.securitycraft.SCContent;
import net.geforcemods.securitycraft.SecurityCraft;
import net.geforcemods.securitycraft.api.SecurityCraftAPI;
import net.geforcemods.securitycraft.blocks.reinforced.IReinforcedBlock;
import net.geforcemods.securitycraft.screen.CustomizeBlockScreen;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

@JeiPlugin
public class SCJEIPlugin implements IModPlugin
{
	public static final ResourceLocation VTS_ID = new ResourceLocation(SecurityCraft.MODID, "vanilla_to_securitycraft");
	public static final ResourceLocation STV_ID = new ResourceLocation(SecurityCraft.MODID, "securitycraft_to_vanilla");

	@Override
	public void registerRecipes(IRecipeRegistration registration)
	{
		registration.addIngredientInfo(new ItemStack(SCContent.ADMIN_TOOL.get()), VanillaTypes.ITEM, "gui.securitycraft:scManual.recipe.admin_tool");
		SecurityCraftAPI.getRegisteredPasswordConvertibles().forEach(pc -> {
			Block original = pc.getOriginalBlock();

			//3rd party mods should handle this themselves
			if(original.getRegistryName().getNamespace().equals(SecurityCraft.MODID))
				registration.addIngredientInfo(new ItemStack(original), VanillaTypes.ITEM, "gui.securitycraft:scManual.recipe." + original.getRegistryName().getPath());
		});
		registration.addRecipes(IReinforcedBlock.VANILLA_TO_SECURITYCRAFT.entrySet().stream().map(entry -> new ReinforcerRecipe(entry.getKey(), entry.getValue())).collect(Collectors.toList()), VTS_ID);
		registration.addRecipes(IReinforcedBlock.SECURITYCRAFT_TO_VANILLA.entrySet().stream().map(entry -> new ReinforcerRecipe(entry.getValue(), entry.getKey())).collect(Collectors.toList()), STV_ID);
	}

	@Override
	public void registerCategories(IRecipeCategoryRegistration registration)
	{
		registration.addRecipeCategories(new VanillaToSecurityCraftCategory(registration.getJeiHelpers().getGuiHelper()));
		registration.addRecipeCategories(new SecurityCraftToVanillaCategory(registration.getJeiHelpers().getGuiHelper()));
	}

	@Override
	public void registerRecipeCatalysts(IRecipeCatalystRegistration registration)
	{
		registration.addRecipeCatalyst(new ItemStack(SCContent.UNIVERSAL_BLOCK_REINFORCER_LVL_1.get()), VTS_ID);
		registration.addRecipeCatalyst(new ItemStack(SCContent.UNIVERSAL_BLOCK_REINFORCER_LVL_2.get()), VTS_ID, STV_ID);
		registration.addRecipeCatalyst(new ItemStack(SCContent.UNIVERSAL_BLOCK_REINFORCER_LVL_3.get()), VTS_ID, STV_ID);
	}

	@Override
	public void registerGuiHandlers(IGuiHandlerRegistration registration)
	{
		registration.addGuiContainerHandler(CustomizeBlockScreen.class, new SlotMover());
	}

	@Override
	public ResourceLocation getPluginUid()
	{
		return new ResourceLocation(SecurityCraft.MODID, SecurityCraft.MODID);
	}
}

@@ -528,67 +528,8 @@
 ft;%0A
-import net.geforcemods.securitycraft.api.SecurityCraftAPI;%0A
 impo
@@ -593,24 +593,24 @@
 orcedBlock;%0A
+
 import net.g
@@ -667,42 +667,8 @@
 en;%0A
-import net.minecraft.block.Block;%0A
 impo
@@ -1269,250 +1269,384 @@
 ;%0A%09%09
-SecurityCraftAPI.getRegisteredPasswordConvertibles().forEach(pc -%3E %7B%0A%09%09%09Block original = pc.getOriginalBlock();%0A%0A%09%09%09//3rd party mods should handle this themselves%0A%09%09%09if(original.getRegistryName().getNamespace().equals(SecurityCraft.MODID))%0A%09%09
+registration.addIngredientInfo(new ItemStack(SCContent.KEYPAD.get()), VanillaTypes.ITEM, %22gui.securitycraft:scManual.recipe.%22 + SCContent.KEYPAD.get().getRegistryName().getPath());%0A%09%09registration.addIngredientInfo(new ItemStack(SCContent.KEYPAD_CHEST.get()), VanillaTypes.ITEM, %22gui.securitycraft:scManual.recipe.%22 + SCContent.KEYPAD_CHEST.get().getRegistryName().getPath());%0A
 %09%09re
@@ -1688,24 +1688,46 @@
 emStack(
-original
+SCContent.KEYPAD_FURNACE.get()
 ), Vanil
@@ -1783,16 +1783,38 @@
 %22 + 
-original
+SCContent.KEYPAD_FURNACE.get()
 .get
@@ -1844,14 +1844,8 @@
 ));%0A
-%09%09%7D);%0A
 %09%09re

fix jei descriptions of password convertibles