Spice of Life: Carrot Edition

Spice of Life: Carrot Edition

63M Downloads

Crash when opening Food Book with Pizza Delight installed (missing FoodProperties)

felixer87 opened this issue · 2 comments

commented

Hi!
I encountered a crash when using Spice of Life: Carrot Edition together with Pizza Delight on Minecraft Neoforge(21.1.133) 1.21.1

The crash occurs when opening the Food Book. The root cause seems to be that PizzaSliceItem (from Pizza Delight) does not define any FoodProperties, because it functions like a cake block—consumed via right-click rather than by holding it in hand. This makes sense for that mod.

However, in FoodItems.setUp() inside SolCarrot, a call to .canAlwaysEat() is made on the result of getFoodProperties() without checking for null, which causes a crash when encountering such items.

java.lang.NullPointerException: Cannot invoke "net.minecraft.world.food.FoodProperties.canAlwaysEat()" because "foodProperties" is null
at pizzadelight.items.PizzaSliceItem.getFoodProperties(PizzaSliceItem.java:50)
at solcarrot.client.FoodItems.lambda$setUp$0(FoodItems.java:44)

Thanks in advance for taking a look, and thanks for maintaining the mod!

commented

That's weird as the line mentioned checks specifically if its not null

commented

All we do is check the return value of calling getFoodProperties on the itemstack instance. Pizza Delight seems to be override the method and call canAlwaysEat without null checking themselves.