From 9561391995c65c420fc41dd713c755d6a5fd5f98 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sat, 30 Apr 2022 00:45:49 -0400 Subject: [PATCH] fix a dumb stupid crash, thanks forge, i hate it --- .../main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt | 2 ++ .../common/casting/operators/spells/OpMakePackagedSpell.kt | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt b/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt index 80e78794..48fa533e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt @@ -9,6 +9,8 @@ object ManaHelper { @JvmStatic fun isManaItem(stack: ItemStack): Boolean { val manaHolder = IXplatAbstractions.INSTANCE.findManaHolder(stack) ?: return false + if (!manaHolder.canProvide()) + return false return manaHolder.withdrawMana(-1, true) > 0 } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt index a88f2594..a8373bcf 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt @@ -56,9 +56,15 @@ class OpMakePackagedSpell(val itemType: T, val cost: Int) : private inner class Spell(val itemEntity: ItemEntity, val patterns: List) : RenderedSpell { override fun cast(ctx: CastingContext) { val (handStack) = ctx.getHeldItemToOperateOn { it.`is`(itemType) } +<<<<<<< HEAD:Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(handStack) if (hexHolder != null && hexHolder.patterns == null +======= + val spellHolder = HexCapabilities.getCapability(handStack, HexCapabilities.SPELL) + if (spellHolder.isPresent + && spellHolder.get().patterns == null +>>>>>>> 0d81ef8 (fix a dumb stupid crash, thanks forge, i hate it):src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt && itemEntity.isAlive ) { val entityStack = itemEntity.item.copy()