From 4958dc1b2395600d3933b5a9363e1c102498d52e Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sun, 17 Apr 2022 20:28:33 -0400 Subject: [PATCH] fix stack mutability being a problem with certain ops --- .../hexcasting/common/casting/operators/spells/OpColorize.kt | 4 ++-- .../common/casting/operators/spells/OpPlaceBlock.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt index 5fd87e45..f2bb25d4 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt @@ -33,11 +33,11 @@ object OpColorize : SpellOperator { private object Spell : RenderedSpell { override fun cast(ctx: CastingContext) { - val (handStack) = ctx.getHeldItemToOperateOn { FrozenColorizer.isColorizer(it) } + val (handStack) = ctx.getHeldItemToOperateOn { FrozenColorizer.isColorizer(it) }.copy() if (FrozenColorizer.isColorizer(handStack)) { if (ctx.withdrawItem(handStack.item, 1, true)) { HexPlayerDataHelper.setColorizer(ctx.caster, - FrozenColorizer(handStack.copy(), ctx.caster.uuid) + FrozenColorizer(handStack, ctx.caster.uuid) ) } } diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt index 80271d58..e788ccc2 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt @@ -43,7 +43,7 @@ object OpPlaceBlock : SpellOperator { if (bstate.isAir || bstate.material.isReplaceable) { val placeeSlot = ctx.getOperativeSlot { it.item is BlockItem } if (placeeSlot != null) { - val placeeStack = ctx.caster.inventory.getItem(placeeSlot) + val placeeStack = ctx.caster.inventory.getItem(placeeSlot).copy() val placee = placeeStack.item as BlockItem if (ctx.withdrawItem(placee, 1, false)) { // https://github.com/VazkiiMods/Psi/blob/master/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock.java#L143