diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt index 87f53b7e..76b63899 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt @@ -16,6 +16,8 @@ object OpAkashicWrite : SpellOperator { override val argc = 3 override val isGreat = true + override val alwaysProcessGreatSpell = false + override val causesBlindDiversion = false override fun execute( args: List>, diff --git a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java index 71b11539..b1faf30c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java @@ -61,55 +61,57 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern } public void handle(MinecraftServer server, ServerPlayer sender) { - var held = sender.getItemInHand(this.handUsed); - if (held.is(HexItemTags.WANDS)) { - boolean autoFail = false; + server.execute(() -> { + var held = sender.getItemInHand(this.handUsed); + if (held.is(HexItemTags.WANDS)) { + boolean autoFail = false; - if (!resolvedPatterns.isEmpty()) { - var allPoints = new ArrayList(); - for (int i = 0; i < resolvedPatterns.size() - 1; i++) { - ResolvedPattern pat = resolvedPatterns.get(i); - allPoints.addAll(pat.getPattern().positions(pat.getOrigin())); - } - var currentResolvedPattern = resolvedPatterns.get(resolvedPatterns.size() - 1); - var currentSpellPoints = currentResolvedPattern.getPattern() - .positions(currentResolvedPattern.getOrigin()); - if (currentSpellPoints.stream().anyMatch(allPoints::contains)) { - autoFail = true; - } - } - - sender.awardStat(HexStatistics.PATTERNS_DRAWN); - - var harness = IXplatAbstractions.INSTANCE.getHarness(sender, this.handUsed); - - ControllerInfo clientInfo; - if (autoFail) { - clientInfo = new ControllerInfo(false, harness.getStack().isEmpty(), ResolvedPatternType.INVALID, - harness.generateDescs()); - } else { - clientInfo = harness.executeIota(SpellDatum.make(this.pattern), sender.getLevel()); - - if (clientInfo.getMakesCastSound()) { - sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(), - HexSounds.ACTUALLY_CAST, SoundSource.PLAYERS, 1f, - 1f + ((float) Math.random() - 0.5f) * 0.2f); - } - } - - if (clientInfo.isStackClear()) { - IXplatAbstractions.INSTANCE.setHarness(sender, null); - IXplatAbstractions.INSTANCE.setPatterns(sender, List.of()); - } else { - IXplatAbstractions.INSTANCE.setHarness(sender, harness); if (!resolvedPatterns.isEmpty()) { - resolvedPatterns.get(resolvedPatterns.size() - 1).setType(clientInfo.getResolutionType()); + var allPoints = new ArrayList(); + for (int i = 0; i < resolvedPatterns.size() - 1; i++) { + ResolvedPattern pat = resolvedPatterns.get(i); + allPoints.addAll(pat.getPattern().positions(pat.getOrigin())); + } + var currentResolvedPattern = resolvedPatterns.get(resolvedPatterns.size() - 1); + var currentSpellPoints = currentResolvedPattern.getPattern() + .positions(currentResolvedPattern.getOrigin()); + if (currentSpellPoints.stream().anyMatch(allPoints::contains)) { + autoFail = true; + } } - IXplatAbstractions.INSTANCE.setPatterns(sender, resolvedPatterns); - } - IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender, new MsgNewSpellPatternAck(clientInfo)); - } + sender.awardStat(HexStatistics.PATTERNS_DRAWN); + + var harness = IXplatAbstractions.INSTANCE.getHarness(sender, this.handUsed); + + ControllerInfo clientInfo; + if (autoFail) { + clientInfo = new ControllerInfo(false, harness.getStack().isEmpty(), ResolvedPatternType.INVALID, + harness.generateDescs()); + } else { + clientInfo = harness.executeIota(SpellDatum.make(this.pattern), sender.getLevel()); + + if (clientInfo.getMakesCastSound()) { + sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(), + HexSounds.ACTUALLY_CAST, SoundSource.PLAYERS, 1f, + 1f + ((float) Math.random() - 0.5f) * 0.2f); + } + } + + if (clientInfo.isStackClear()) { + IXplatAbstractions.INSTANCE.setHarness(sender, null); + IXplatAbstractions.INSTANCE.setPatterns(sender, List.of()); + } else { + IXplatAbstractions.INSTANCE.setHarness(sender, harness); + if (!resolvedPatterns.isEmpty()) { + resolvedPatterns.get(resolvedPatterns.size() - 1).setType(clientInfo.getResolutionType()); + } + IXplatAbstractions.INSTANCE.setPatterns(sender, resolvedPatterns); + } + + IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender, new MsgNewSpellPatternAck(clientInfo)); + } + }); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java index 64f014a4..e9a0d904 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java @@ -48,13 +48,15 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea } public void handle(MinecraftServer server, ServerPlayer sender) { - var stack = sender.getItemInHand(hand); + server.execute(() -> { + var stack = sender.getItemInHand(hand); - if (stack.getItem() == HexItems.SPELLBOOK) { - spellbook(sender, stack); - } else if (stack.getItem() == HexItems.ABACUS) { - abacus(sender, stack); - } + if (stack.getItem() == HexItems.SPELLBOOK) { + spellbook(sender, stack); + } else if (stack.getItem() == HexItems.ABACUS) { + abacus(sender, stack); + } + }); } private void spellbook(ServerPlayer sender, ItemStack stack) {