private bool PassRecipeFilters(Recipe recipe, List <int> groups)
        {
            if (RecipeBrowserUI.modIndex != RecipeBrowserUI.instance.mods.Length - 1)
            {
                if (recipe.createItem.modItem == null)
                {
                    return(false);
                }
                if (recipe.createItem.modItem.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex])
                {
                    return(false);
                }
            }

            if (NearbyIngredientsRadioBitton.Selected)
            {
                if (!PassNearbyChestFilter(recipe))
                {
                    return(false);
                }
            }

            // Item Checklist integration
            if (ItemChecklistRadioButton.Selected)
            {
                if (RecipeBrowserUI.instance.foundItems != null)
                {
                    for (int i = 0; i < Recipe.maxRequirements; i++)
                    {
                        if (recipe.requiredItem[i].type > 0)
                        {
                            if (!RecipeBrowserUI.instance.foundItems[recipe.requiredItem[i].type])
                            {
                                return(false);
                            }
                        }
                    }
                    // filter out recipes that make things I've already obtained
                    if (RecipeBrowserUI.instance.foundItems[recipe.createItem.type])
                    {
                        return(false);
                    }
                }
                else
                {
                    Main.NewText("How is this happening??");
                }
            }

            // Filter out recipes that don't use selected Tile
            if (Tile > -1)
            {
                List <int> adjTiles = new List <int>();
                adjTiles.Add(Tile);
                if (uniqueCheckbox.CurrentState == 0)
                {
                    Terraria.ModLoader.ModTile modTile = Terraria.ModLoader.TileLoader.GetTile(Tile);
                    if (modTile != null)
                    {
                        adjTiles.AddRange(modTile.adjTiles);
                    }
                    if (Tile == 302)
                    {
                        adjTiles.Add(17);
                    }
                    if (Tile == 77)
                    {
                        adjTiles.Add(17);
                    }
                    if (Tile == 133)
                    {
                        adjTiles.Add(17);
                        adjTiles.Add(77);
                    }
                    if (Tile == 134)
                    {
                        adjTiles.Add(16);
                    }
                    if (Tile == 354)
                    {
                        adjTiles.Add(14);
                    }
                    if (Tile == 469)
                    {
                        adjTiles.Add(14);
                    }
                    if (Tile == 355)
                    {
                        adjTiles.Add(13);
                        adjTiles.Add(14);
                    }
                    // TODO: GlobalTile.AdjTiles support (no player object, reflection needed since private)
                }
                if (!recipe.requiredTile.Any(t => adjTiles.Contains(t)))
                {
                    return(false);
                }
            }

            if (!queryItem.item.IsAir)
            {
                int  type    = queryItem.item.type;
                bool inGroup = recipe.acceptedGroups.Intersect(groups).Any();

                inGroup |= recipe.useWood(type, type) || recipe.useSand(type, type) || recipe.useFragment(type, type) || recipe.useIronBar(type, type) || recipe.usePressurePlate(type, type);
                if (!inGroup)
                {
                    if (!(recipe.createItem.type == type || recipe.requiredItem.Any(ing => ing.type == type)))
                    {
                        return(false);
                    }
                }
            }

            if (recipe.createItem.Name.ToLower().IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1)
            {
                return(false);
            }

            if (itemDescriptionFilter.currentString.Length > 0)
            {
                if ((recipe.createItem.ToolTip != null && GetTooltipsAsString(recipe.createItem.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
        private bool PassRecipeFilters(UIRecipeSlot recipeSlot, Recipe recipe, List <int> groups)
        {
            // TODO: Option to filter by source of Recipe rather than by createItem maybe?
            if (RecipeBrowserUI.modIndex != 0)
            {
                if (recipe.createItem.modItem == null)
                {
                    return(false);
                }
                if (recipe.createItem.modItem.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex])
                {
                    return(false);
                }
            }

            if (NearbyIngredientsRadioBitton.Selected)
            {
                if (!PassNearbyChestFilter(recipe))
                {
                    return(false);
                }
            }

            // Item Checklist integration
            if (ItemChecklistRadioButton.Selected)
            {
                if (RecipeBrowserUI.instance.foundItems != null)
                {
                    for (int i = 0; i < Recipe.maxRequirements; i++)
                    {
                        if (recipe.requiredItem[i].type > 0)
                        {
                            if (!RecipeBrowserUI.instance.foundItems[recipe.requiredItem[i].type])
                            {
                                return(false);
                            }
                        }
                    }
                    // filter out recipes that make things I've already obtained
                    if (RecipeBrowserUI.instance.foundItems[recipe.createItem.type])
                    {
                        return(false);
                    }
                }
                else
                {
                    Main.NewText("How is this happening??");
                }
            }

            // Filter out recipes that don't use selected Tile
            if (Tile > -1)
            {
                List <int> adjTiles = new List <int>();
                adjTiles.Add(Tile);
                if (uniqueCheckbox.CurrentState == 0)
                {
                    Terraria.ModLoader.ModTile modTile = Terraria.ModLoader.TileLoader.GetTile(Tile);
                    if (modTile != null)
                    {
                        adjTiles.AddRange(modTile.adjTiles);
                    }
                    if (Tile == 302)
                    {
                        adjTiles.Add(17);
                    }
                    if (Tile == 77)
                    {
                        adjTiles.Add(17);
                    }
                    if (Tile == 133)
                    {
                        adjTiles.Add(17);
                        adjTiles.Add(77);
                    }
                    if (Tile == 134)
                    {
                        adjTiles.Add(16);
                    }
                    if (Tile == 354)
                    {
                        adjTiles.Add(14);
                    }
                    if (Tile == 469)
                    {
                        adjTiles.Add(14);
                    }
                    if (Tile == 355)
                    {
                        adjTiles.Add(13);
                        adjTiles.Add(14);
                    }
                    // TODO: GlobalTile.AdjTiles support (no player object, reflection needed since private)
                }
                if (!recipe.requiredTile.Any(t => adjTiles.Contains(t)))
                {
                    return(false);
                }
            }

            if (!queryItem.item.IsAir)
            {
                int  type    = queryItem.item.type;
                bool inGroup = recipe.acceptedGroups.Intersect(groups).Any();

                inGroup |= recipe.useWood(type, type) || recipe.useSand(type, type) || recipe.useFragment(type, type) || recipe.useIronBar(type, type) || recipe.usePressurePlate(type, type);
                if (!inGroup)
                {
                    if (!(recipe.createItem.type == type || recipe.requiredItem.Any(ing => ing.type == type)))
                    {
                        return(false);
                    }
                }
            }

            var SelectedCategory = SharedUI.instance.SelectedCategory;

            if (SelectedCategory != null)
            {
                if (!SelectedCategory.belongs(recipe.createItem) && !SelectedCategory.subCategories.Any(x => x.belongs(recipe.createItem)))
                {
                    return(false);
                }
            }
            var availableFilters = SharedUI.instance.availableFilters;

            if (availableFilters != null)
            {
                foreach (var filter in SharedUI.instance.availableFilters)
                {
                    if (filter.button.selected)
                    {
                        // Extended craft problem.
                        if (!filter.belongs(recipe.createItem))
                        {
                            return(false);
                        }
                        if (filter == SharedUI.instance.ObtainableFilter)
                        {
                            recipeSlot.CraftPathNeeded();
                            if (!((recipeSlot.craftPathCalculated || recipeSlot.craftPathsCalculated) && recipeSlot.craftPaths.Count > 0))
                            {
                                return(false);
                            }
                        }
                        if (filter == SharedUI.instance.CraftableFilter)
                        {
                            int  index       = recipeSlot.index;
                            bool ableToCraft = false;
                            for (int n = 0; n < Main.numAvailableRecipes; n++)
                            {
                                if (index == Main.availableRecipe[n])
                                {
                                    ableToCraft = true;
                                    break;
                                }
                            }
                            if (!ableToCraft)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            if (recipe.createItem.Name.ToLower().IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1)
            {
                return(false);
            }

            if (itemDescriptionFilter.currentString.Length > 0)
            {
                if ((recipe.createItem.ToolTip != null && GetTooltipsAsString(recipe.createItem.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }