package info.u_team.u_team_core.integration.jei;

import java.util.List;
import java.util.stream.Collectors;

import info.u_team.u_team_core.UCoreMod;
import info.u_team.u_team_core.api.dye.IDyeableItem;
import info.u_team.u_team_core.inventory.*;
import mezz.jei.api.*;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.item.*;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.registries.ForgeRegistries;

@JeiPlugin
public class UTeamCoreJeiPlugin implements IModPlugin {
	
	private final ResourceLocation id = new ResourceLocation(UCoreMod.MODID, "jei");
	
	@Override
	public ResourceLocation getPluginUid() {
		return id;
	}
	
	@Override
	public void registerRecipes(IRecipeRegistration registration) {
		final Minecraft minecraft = Minecraft.getInstance();
		final World world = minecraft.world;
		
		final IItemHandlerModifiable handler = new UItemStackHandler(9);
		handler.setStackInSlot(1, new ItemStack(Items.WHITE_DYE));
		
		final List<ItemStack> items = ForgeRegistries.ITEMS.getValues().stream() //
				.filter(item -> item instanceof IDyeableItem || item instanceof IDyeableArmorItem) //
				.map(ItemStack::new) //
				.filter(stack -> {
					handler.setStackInSlot(0, stack.copy());
					return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, new CraftingRecipeWrapper(handler, 3, 3), world).isPresent();
				}).collect(Collectors.toList());
		
		registration.addIngredientInfo(items, VanillaTypes.ITEM, "jei.uteamcore.dyeable.info");
	}
	
}

@@ -518,24 +518,81 @@
 ceLocation;%0A
+import net.minecraft.util.text.TranslationTextComponent;%0A
 import net.m
@@ -1747,16 +1747,45 @@
 s.ITEM, 
+new TranslationTextComponent(
 %22jei.ute
@@ -1805,16 +1805,17 @@
 e.info%22)
+)
 ;%0A%09%7D%0A%09%0A%7D

Update jei integration