<commit_before>package squeek.veganoption.content.registry;

import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import squeek.veganoption.helpers.MiscHelper;

public class CompostRegistry
{
	public static List<ItemStack> browns = new ArrayList<ItemStack>();
	public static List<ItemStack> greens = new ArrayList<ItemStack>();
	public static List<FoodSpecifier> uncompostableFoods = new ArrayList<FoodSpecifier>();

	public static void registerAllFoods()
	{
		// TODO: Check for/handle metadata-based sub items
		for (Object obj : Item.itemRegistry)
		{
			ItemStack itemStack = new ItemStack((Item) obj);
			if (isCompostableFood(itemStack))
			{
				addGreen(itemStack);
			}
		}
	}

	public abstract static class FoodSpecifier
	{
		public abstract boolean matches(ItemStack itemStack);
	}

	public static boolean isCompostable(ItemStack itemStack)
	{
		return isGreen(itemStack) || isBrown(itemStack);
	}

	public static boolean isBrown(ItemStack itemStack)
	{
		return MiscHelper.isItemStackInList(browns, itemStack);
	}

	public static boolean isGreen(ItemStack itemStack)
	{
		return MiscHelper.isItemStackInList(greens, itemStack);
	}

	public static boolean isCompostableFood(ItemStack itemStack)
	{
		// TODO: optionally use AppleCore's method?
		if (itemStack != null && itemStack.getItem() instanceof ItemFood)
		{<commit_msg>Add subitem support to CompostRegistry food discovery<commit_after>package squeek.veganoption.content.registry;

import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import squeek.veganoption.helpers.MiscHelper;

public class CompostRegistry
{
	public static List<ItemStack> browns = new ArrayList<ItemStack>();
	public static List<ItemStack> greens = new ArrayList<ItemStack>();
	public static List<FoodSpecifier> uncompostableFoods = new ArrayList<FoodSpecifier>();

	public static void registerAllFoods()
	{
		List<ItemStack> stackList = new ArrayList<ItemStack>();

		for (Object obj : Item.itemRegistry)
		{
			Item item = ((Item) obj);

			if (item == null)
				continue;

			for (CreativeTabs itemTab : item.getCreativeTabs())
			{
				if (itemTab == null)
					continue;

				stackList.clear();
				item.getSubItems(item, itemTab, stackList);
			}

			for (ItemStack itemStack : stackList)
			{
				if (isCompostableFood(itemStack))
				{
					addGreen(itemStack);
				}
			}
		}
	}

	public abstract static class FoodSpecifier
	{
		public abstract boolean matches(ItemStack itemStack);
	}

	public static boolean isCompostable(ItemStack itemStack)
	{
		return isGreen(itemStack) || isBrown(itemStack);
	}

	public static boolean isBrown(ItemStack itemStack)
	{
		return MiscHelper.isItemStackInList(browns, itemStack);
	}

	public static boolean isGreen(ItemStack itemStack)
	{
		return MiscHelper.isItemStackInList(greens, itemStack);
	}

	public static boolean isCompostableFood(ItemStack itemStack)
	{
		// TODO: optionally use AppleCore's method?
		if (itemStack != null && itemStack.getItem() instanceof ItemFood)
		{
{'fraction_non_alphanumeric': 0.09681227863046045, 'fraction_numerical': 0.0, 'mean_word_length': 5.019538188277087, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2274612', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1042, 'n_words': 247}