fix akashic records not working on fabric

This commit is contained in:
yrsegal@gmail.com 2022-06-04 10:17:56 -04:00
parent 2d049114ba
commit f08959d90e
3 changed files with 57 additions and 51 deletions

View file

@ -16,6 +16,8 @@ object OpAkashicWrite : SpellOperator {
override val argc = 3 override val argc = 3
override val isGreat = true override val isGreat = true
override val alwaysProcessGreatSpell = false
override val causesBlindDiversion = false
override fun execute( override fun execute(
args: List<SpellDatum<*>>, args: List<SpellDatum<*>>,

View file

@ -61,55 +61,57 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
} }
public void handle(MinecraftServer server, ServerPlayer sender) { public void handle(MinecraftServer server, ServerPlayer sender) {
var held = sender.getItemInHand(this.handUsed); server.execute(() -> {
if (held.is(HexItemTags.WANDS)) { var held = sender.getItemInHand(this.handUsed);
boolean autoFail = false; if (held.is(HexItemTags.WANDS)) {
boolean autoFail = false;
if (!resolvedPatterns.isEmpty()) {
var allPoints = new ArrayList<HexCoord>();
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()) { if (!resolvedPatterns.isEmpty()) {
resolvedPatterns.get(resolvedPatterns.size() - 1).setType(clientInfo.getResolutionType()); var allPoints = new ArrayList<HexCoord>();
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));
}
});
} }
} }

View file

@ -48,13 +48,15 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea
} }
public void handle(MinecraftServer server, ServerPlayer sender) { public void handle(MinecraftServer server, ServerPlayer sender) {
var stack = sender.getItemInHand(hand); server.execute(() -> {
var stack = sender.getItemInHand(hand);
if (stack.getItem() == HexItems.SPELLBOOK) { if (stack.getItem() == HexItems.SPELLBOOK) {
spellbook(sender, stack); spellbook(sender, stack);
} else if (stack.getItem() == HexItems.ABACUS) { } else if (stack.getItem() == HexItems.ABACUS) {
abacus(sender, stack); abacus(sender, stack);
} }
});
} }
private void spellbook(ServerPlayer sender, ItemStack stack) { private void spellbook(ServerPlayer sender, ItemStack stack) {