From 13bfc6558373e50b3a77b0af694e2df658ed9148 Mon Sep 17 00:00:00 2001 From: Talia-12 Date: Thu, 1 Jun 2023 19:48:24 +1000 Subject: [PATCH] Fix #461 (iotas added to ravenmind not serialised properly), and make it so staff cast data only gets reset when both stack and ravenmind are clear. Also made it so writing null to the ravenmind clears it. --- .../hexcasting/api/casting/eval/env/StaffCastEnv.java | 3 ++- .../common/casting/operators/local/OpPushLocal.kt | 7 ++++++- .../hexcasting/common/msgs/MsgNewSpellPatternS2C.java | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/StaffCastEnv.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/StaffCastEnv.java index ea969c14..21aba4e9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/StaffCastEnv.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/StaffCastEnv.java @@ -97,7 +97,8 @@ public class StaffCastEnv extends PlayerBasedCastEnv { ExecutionClientView clientInfo = vm.queueExecuteAndWrapIota(new PatternIota(msg.pattern()), sender.getLevel()); - if (clientInfo.isStackClear()) { +// if (clientInfo.isStackClear()) { + if (clientInfo.isStackClear() && clientInfo.getRavenmind() == null) { IXplatAbstractions.INSTANCE.setStaffcastImage(sender, null); IXplatAbstractions.INSTANCE.setPatterns(sender, List.of()); } else { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt index 133307f7..d0e7041b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt @@ -6,8 +6,10 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.eval.OperationResult import at.petrak.hexcasting.api.casting.eval.vm.CastingImage import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation +import at.petrak.hexcasting.api.casting.iota.IotaType import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.common.lib.hex.HexEvalSounds +import at.petrak.hexcasting.common.lib.hex.HexIotaTypes object OpPushLocal : Action { override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult { @@ -17,7 +19,10 @@ object OpPushLocal : Action { throw MishapNotEnoughArgs(1, 0) val newLocal = stack.removeLast() - image.userData.put(HexAPI.RAVENMIND_USERDATA, newLocal.serialize()) + if (newLocal.type == HexIotaTypes.NULL) + image.userData.remove(HexAPI.RAVENMIND_USERDATA) + else + image.userData.put(HexAPI.RAVENMIND_USERDATA, IotaType.serialize(newLocal)) val image2 = image.withUsedOp().copy(stack = stack) return OperationResult(image2, listOf(), continuation, HexEvalSounds.NORMAL_EXECUTE) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/msgs/MsgNewSpellPatternS2C.java b/Common/src/main/java/at/petrak/hexcasting/common/msgs/MsgNewSpellPatternS2C.java index c0c23d95..e67869cc 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/msgs/MsgNewSpellPatternS2C.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/msgs/MsgNewSpellPatternS2C.java @@ -52,7 +52,7 @@ public record MsgNewSpellPatternS2C(ExecutionClientView info, int index) impleme public static void handle(MsgNewSpellPatternS2C self) { Minecraft.getInstance().execute(() -> { var mc = Minecraft.getInstance(); - if (self.info().isStackClear()) { + if (self.info().isStackClear() && self.info().getRavenmind() == null) { // don't pay attention to the screen, so it also stops when we die mc.getSoundManager().stop(HexSounds.CASTING_AMBIANCE.getLocation(), null); }