fix a dumb stupid crash, thanks forge, i hate it

This commit is contained in:
yrsegal@gmail.com 2022-04-30 00:45:49 -04:00
parent 10f16e9199
commit 9561391995
2 changed files with 8 additions and 0 deletions

View file

@ -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
}

View file

@ -56,9 +56,15 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
private inner class Spell(val itemEntity: ItemEntity, val patterns: List<HexPattern>) : 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()