From acab28f1ad38058186378c50a095919ec59eb762 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 14 Aug 2023 22:13:29 +0100 Subject: [PATCH] Fix (potential crash) with empty recipe remainders --- .../java/com/minelittlepony/unicopia/item/DrinkableItem.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java b/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java index 8419bd8e..a9394c3c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java @@ -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