From 2620ac5de1780efbfabb2a6a406d5475c8b3a1b0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 4 Oct 2024 23:34:36 +0100 Subject: [PATCH] Fix crash when opening the creative inventory --- .../unicopia/ability/magic/spell/effect/SpellType.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java index 5db07ede..ff0974af 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect; +import java.util.function.Supplier; + import org.jetbrains.annotations.Nullable; import com.google.common.base.Suppliers; @@ -103,7 +105,7 @@ public final class SpellType implements Affine, SpellPredicate< private final CustomisedSpellType traited; private final SpellTraits traits; - private final ItemStack defaultStack; + private final Supplier defaultStack; private final TooltipFactory tooltipFunction; @@ -118,7 +120,7 @@ public final class SpellType implements Affine, SpellPredicate< this.traits = traits; this.stackable = stackable; traited = new CustomisedSpellType<>(this, traits, SpellTraits::empty); - defaultStack = EnchantableItem.enchant(UItems.GEMSTONE.getDefaultStack(), this); + defaultStack = Suppliers.memoize(() -> EnchantableItem.enchant(UItems.GEMSTONE.getDefaultStack(), this)); } public boolean isObtainable() { @@ -134,7 +136,7 @@ public final class SpellType implements Affine, SpellPredicate< } public ItemStack getDefualtStack() { - return defaultStack; + return defaultStack.get(); } /**