fix stack mutability being a problem with certain ops

This commit is contained in:
yrsegal@gmail.com 2022-04-17 20:28:33 -04:00
parent bdaa3d22c4
commit 4958dc1b23
2 changed files with 3 additions and 3 deletions

View file

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

View file

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