Skip to content

Commit

Permalink
Fix an issue with mods setting consumable items with null hunger or f…
Browse files Browse the repository at this point in the history
…ood components raises a NullPointerException, causing the client to crash.
  • Loading branch information
NerjalNosk authored and squeek502 committed May 4, 2023
1 parent 4e4c9d4 commit fc3cd08
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions java/squeek/appleskin/helpers/FoodHelper.java
Expand Up @@ -38,8 +38,8 @@ public static boolean canConsume(ItemStack itemStack, PlayerEntity player)
public static FoodValues getDefaultFoodValues(ItemStack itemStack)
{
FoodComponent itemFood = itemStack.getItem().getFoodComponent();
int hunger = itemFood.getHunger();
float saturationModifier = itemFood.getSaturationModifier();
int hunger = itemFood != null ? itemFood.getHunger() : 0;
float saturationModifier = itemFood != null ? itemFood.getSaturationModifier() : 0;
return new FoodValues(hunger, saturationModifier);
}

Expand Down

0 comments on commit fc3cd08

Please sign in to comment.