Esempio n. 1
0
        /// <summary>
        /// Safely accesses the crafting data from a Modded or Vanilla item.<para/>
        /// WARNING: This method is highly dependent on mod load order.
        /// Make sure your mod is loading after the mod whose TechData you are trying to access.
        /// </summary>
        /// <param name="techType">The TechType whose TechData you want to access.</param>
        /// <returns>The RecipeData from the item if it exists; Otherwise, returns <c>null</c>.</returns>
        RecipeData ICraftDataHandler.GetRecipeData(TechType techType)
        {
            RecipeData moddedRecipeData = GetModdedRecipeData(techType);

            if (moddedRecipeData != null)
            {
                return(moddedRecipeData);
            }

            if (!TechData.Contains(TechType.Knife))
            {
                TechData.Initialize();
            }

            if (TechData.TryGetValue(techType, out JsonValue techData))
            {
                return(ConvertToRecipeData(techData));
            }

            return(null);
        }