Content Patcher

Content Patcher

378k Downloads

[Lookup Anything] show Custom Farming Redux recipes

Pathoschild opened this issue ยท 3 comments

commented

Show recipes for Custom Farming Redux machines using its new API methods.

commented

Code snippet from Platonymous:

/// <summary>Returns the name, Texture and required stack of all machines that can use the specified item</summary>
/// <param name="item">The item to be used as material.</param>
public List<Tuple<string, Texture2D, int>> getMachinesForItem(StardewValley.Object item)
{
    List<Tuple<string,Texture2D, int>> result = new List<Tuple<string, Texture2D, int>>();

    foreach (CustomMachineBlueprint blueprint in CustomFarmingReduxMod.machines)
    {
        var find = findRecipe(blueprint, new List<Item> { maxed(item) });
        if (find is RecipeBlueprint recipe && recipe.materials != null && recipe.materials.Count > 0) {
            var material = recipe.materials.Find(i => i.index == -999 || i.index == item.ParentSheetIndex || item.Category == i.index);
            if(material is IngredientBlueprint ing)
                result.Add(new Tuple<string, Texture2D, int>(blueprint.name, blueprint.getTexture(),ing.stack));
        }
    }

    return result;
}
commented

Proposed Custom Farming Redux API:

/// <summary>Get the machine name + texture + source rectangle, required ingredient stack, and a sample output for all machines that can use the specified item as an ingredient.</summary>
/// <param name="item">The item to use as an ingredient.</param>
public IEnumerable<Tuple<string, Texture2D, Rectangle, int, Item>> getRecipesForIngredient(Item item);
commented

Custom Farming Redux is increasingly being replaced by Producer Framework Mod, which Lookup Anything does support.