NotAdam / Lumina.Excel

Do What The F*ck You Want To Public License
13 stars 2 forks source link

References to ingredient items in some recipes are null #7

Closed hardealy closed 2 weeks ago

hardealy commented 2 weeks ago

I apologize if the English is strange as I am using machine translation.

Executing the following code will result in an error on the last line. System.InvalidOperationException: 'Operation is not valid due to the current state of the object.'

When I looked into the contents of recipe.Ingredient, I found that recipe.Ingredient[7].ValueNullable was null. Apparently, a recipe that uses only one type of crystal and one type of Ingredient is incorrect.

using Lumina.Excel.Sheets;

var luminaOptions = new Lumina.LuminaOptions()
{
    DefaultExcelLanguage = Lumina.Data.Language.English
};

const string GameDirectory = "C:/SteamLibrary/steamapps/common/FINAL FANTASY XIV Online";
var lumina = new Lumina.GameData($"{GameDirectory}/game/sqpack", luminaOptions);

var recipesSheet = lumina.GetExcelSheet<Recipe>();

var recipe = recipesSheet.FirstOrDefault(x => x.ItemResult.Value.Name.ToString() == "Iron Ingot");

var ingredientNames = recipe.Ingredient.Select(x=>x.Value.Name.ToString()).ToArray();
WorkingRobot commented 2 weeks ago

Have you updated to Lumina.Excel 7.1.0?

hardealy commented 2 weeks ago

yes. The nuget library version has been updated to Lumina 5.2.1 Lumina.Excel 7.1.0 image

WorkingRobot commented 2 weeks ago

I see the error; please use .ValueNullable instead of .Value .Value will throw an exception if the RowRef points to an invalid row.

hardealy commented 2 weeks ago

thank you. I was able to implement the desired functionality using .ValueNullable