Fix (potential crash) with empty recipe remainders

This commit is contained in:
Sollace 2023-08-14 22:13:29 +01:00
parent e3bb03f53b
commit acab28f1ad
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.item;
import java.util.Optional;
import com.minelittlepony.unicopia.item.toxin.ToxicHolder;
import net.minecraft.advancement.criterion.Criteria;
@ -31,7 +33,7 @@ public class DrinkableItem extends Item {
stack.decrement(1);
}
return stack.isEmpty() ? new ItemStack(getRecipeRemainder()) : stack;
return stack.isEmpty() ? Optional.ofNullable(getRecipeRemainder()).map(Item::getDefaultStack).orElse(ItemStack.EMPTY) : stack;
}
@Override