Skip to content

Fix NPE when FoodProperties is null#6

Open
Huoyuuu wants to merge 1 commit intoevanbones:mainfrom
Huoyuuu:fix-null-foodproperties
Open

Fix NPE when FoodProperties is null#6
Huoyuuu wants to merge 1 commit intoevanbones:mainfrom
Huoyuuu:fix-null-foodproperties

Conversation

@Huoyuuu
Copy link
Copy Markdown

@Huoyuuu Huoyuuu commented Jan 16, 2026

ModConfig.getFoodConfig can crash with NPE when SOLValheim.getter.get(stack) returns null and we call food.getNutrition().

var food = item == Items.CAKE
        ? new FoodProperties.Builder().nutrition(10).saturationMod(0.7f).build()
        : SOLValheim.getter.get(stack);
// ...
existing.nutrition = food.getNutrition();

This PR adds a null guard if (!isDrink && food == null) return null; to skip autogen for such items and avoid client crashes (e.g. tooltip/UI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant