Skip to content

Commit 9461f3b

Browse files
committed
Fix errors from 0.2.1 backport
1 parent 9cb7d5f commit 9461f3b

File tree

16 files changed

+110
-108
lines changed

16 files changed

+110
-108
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
"*.jcss.jinja": "jinja-css", // for files with a lot of jinja stuff, where the linting isn't useful
3232
"*.json5.jinja": "json5",
3333
},
34+
"kotlin.languageServer.enabled": false,
3435
}

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1414
### Fixed
1515

1616
- Evaluators were unable to cast any spells requiring media.
17-
- When debugging, spells requiring media would fail if a Debugger was not in the hand that the debug session was started with.
1817
- Evaluator mishaps were unintentionally caught by the Uncaught Mishaps option, and did not apply side effects to the stack.
1918

2019
## 0.2.0+1.19.2

Common/src/main/java/gay/object/hexdebug/mixin/MixinCastingContext.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import at.petrak.hexcasting.api.spell.Action;
44
import at.petrak.hexcasting.api.spell.casting.CastingContext;
5+
import gay.object.hexdebug.casting.eval.DebugCastEnvType;
56
import gay.object.hexdebug.casting.eval.IMixinCastingContext;
67
import gay.object.hexdebug.debugger.DebugStepType;
78
import net.minecraft.network.chat.Component;
@@ -39,6 +40,9 @@ public abstract class MixinCastingContext implements IMixinCastingContext {
3940
private boolean isDebugging$hexdebug = false;
4041
@Nullable
4142
@Unique
43+
private DebugCastEnvType debugCastEnvType$hexdebug = null;
44+
@Nullable
45+
@Unique
4246
private Action lastEvaluatedAction$hexdebug = null;
4347
@Nullable
4448
@Unique
@@ -75,4 +79,15 @@ public abstract class MixinCastingContext implements IMixinCastingContext {
7579
public void setLastDebugStepType$hexdebug(@Nullable DebugStepType lastDebugStepType) {
7680
lastDebugStepType$hexdebug = lastDebugStepType;
7781
}
82+
83+
@Nullable
84+
@Override
85+
public DebugCastEnvType getDebugCastEnvType$hexdebug() {
86+
return debugCastEnvType$hexdebug;
87+
}
88+
89+
@Override
90+
public void setDebugCastEnvType$hexdebug(@Nullable DebugCastEnvType debugCastEnvType) {
91+
debugCastEnvType$hexdebug = debugCastEnvType;
92+
}
7893
}

Common/src/main/java/gay/object/hexdebug/mixin/MixinDoMishap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import at.petrak.hexcasting.api.spell.mishaps.Mishap;
66
import gay.object.hexdebug.casting.eval.IMixinCastingContext;
77
import gay.object.hexdebug.casting.eval.IMixinCastingContextKt;
8+
import gay.object.hexdebug.casting.eval.UtilsKt;
89
import org.eclipse.lsp4j.debug.OutputEventArgumentsCategory;
910
import org.spongepowered.asm.mixin.Final;
1011
import org.spongepowered.asm.mixin.Mixin;
@@ -26,10 +27,10 @@ public abstract class MixinDoMishap {
2627
@Inject(method = "performEffect", at = @At("HEAD"), remap = false)
2728
private void printDebugMessage$hexdebug(CastingHarness harness, CallbackInfoReturnable<Boolean> cir) {
2829
var ctx = harness.getCtx();
29-
var msg = mishap.errorMessage(ctx, errorCtx);
3030
var debugCastEnv = (IMixinCastingContext) (Object) ctx;
3131
if (debugCastEnv != null && debugCastEnv.isDebugging$hexdebug()) {
32-
IMixinCastingContextKt.printDebugMessage(ctx.getCaster(), msg, OutputEventArgumentsCategory.STDERR, true);
32+
var msg = mishap.errorMessage(ctx, errorCtx);
33+
UtilsKt.printDebugMessage(ctx.getCaster(), msg, OutputEventArgumentsCategory.STDERR, true);
3334
}
3435
}
3536
}

Common/src/main/java/gay/object/hexdebug/mixin/MixinOpPrintSpell.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import at.petrak.hexcasting.api.spell.iota.Iota;
55
import gay.object.hexdebug.casting.eval.IMixinCastingContext;
66
import gay.object.hexdebug.casting.eval.IMixinCastingContextKt;
7+
import gay.object.hexdebug.casting.eval.UtilsKt;
78
import org.eclipse.lsp4j.debug.OutputEventArgumentsCategory;
89
import org.spongepowered.asm.mixin.Final;
910
import org.spongepowered.asm.mixin.Mixin;
@@ -24,7 +25,7 @@ public class MixinOpPrintSpell {
2425
var msg = datum.display();
2526
var debugCastEnv = (IMixinCastingContext) (Object) ctx;
2627
if (debugCastEnv != null && debugCastEnv.isDebugging$hexdebug()) {
27-
IMixinCastingContextKt.printDebugMessage(ctx.getCaster(), msg, OutputEventArgumentsCategory.STDOUT, true);
28+
UtilsKt.printDebugMessage(ctx.getCaster(), msg, OutputEventArgumentsCategory.STDOUT, true);
2829
}
2930
}
3031
}

Common/src/main/kotlin/gay/object/hexdebug/adapter/DebugAdapter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ open class DebugAdapter(val player: ServerPlayer) : IDebugProtocolServer {
108108
})
109109
}
110110

111-
fun evaluate(env: CastingEnvironment, pattern: HexPattern) = evaluate(env, PatternIota(pattern))
111+
fun evaluate(env: CastingContext, pattern: HexPattern) = evaluate(env, PatternIota(pattern))
112112

113-
fun evaluate(env: CastingEnvironment, iota: Iota) = evaluate(env, SpellList.LList(listOf(iota)))
113+
fun evaluate(env: CastingContext, iota: Iota) = evaluate(env, SpellList.LList(listOf(iota)))
114114

115-
fun evaluate(env: CastingEnvironment, list: SpellList) = debugger?.let {
115+
fun evaluate(env: CastingContext, list: SpellList) = debugger?.let {
116116
val result = it.evaluate(env, list)
117117
if (result.startedEvaluating) {
118118
setEvaluatorState(ItemEvaluator.EvalState.MODIFIED)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package gay.`object`.hexdebug.casting.eval
2+
3+
enum class DebugCastEnvType {
4+
DEBUGGER,
5+
EVALUATOR,
6+
}

Common/src/main/kotlin/gay/object/hexdebug/casting/eval/DebuggerCastEnv.kt

Lines changed: 0 additions & 56 deletions
This file was deleted.

Common/src/main/kotlin/gay/object/hexdebug/casting/eval/IMixinCastingContext.kt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1+
@file:Suppress("CAST_NEVER_SUCCEEDS")
2+
13
package gay.`object`.hexdebug.casting.eval
24

35
import at.petrak.hexcasting.api.spell.Action
6+
import at.petrak.hexcasting.api.spell.casting.CastingContext
7+
import at.petrak.hexcasting.api.spell.casting.CastingContext.CastSource
8+
import at.petrak.hexcasting.api.spell.casting.CastingHarness
9+
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
410
import gay.`object`.hexdebug.adapter.DebugAdapterManager
511
import gay.`object`.hexdebug.debugger.DebugStepType
612
import net.minecraft.network.chat.Component
713
import net.minecraft.server.level.ServerPlayer
14+
import net.minecraft.world.InteractionHand
815
import org.eclipse.lsp4j.debug.OutputEventArgumentsCategory
916

1017
@Suppress("PropertyName")
1118
interface IMixinCastingContext {
1219
var `isDebugging$hexdebug`: Boolean
20+
var `debugCastEnvType$hexdebug`: DebugCastEnvType?
1321
var `lastEvaluatedAction$hexdebug`: Action?
1422
var `lastDebugStepType$hexdebug`: DebugStepType?
1523
}
@@ -19,23 +27,19 @@ fun IMixinCastingContext.reset() {
1927
`lastDebugStepType$hexdebug` = null
2028
}
2129

22-
fun printDebugMessage(
23-
caster: ServerPlayer,
24-
message: Component,
25-
category: String = OutputEventArgumentsCategory.STDOUT,
26-
withSource: Boolean = true,
27-
) {
28-
DebugAdapterManager[caster]?.print(message.string + "\n", category, withSource)
30+
fun newDebuggerCastEnv(caster: ServerPlayer, castingHand: InteractionHand): CastingContext {
31+
return CastingContext(caster, castingHand, CastSource.PACKAGED_HEX).apply {
32+
this as IMixinCastingContext
33+
`isDebugging$hexdebug` = true
34+
`debugCastEnvType$hexdebug` = DebugCastEnvType.DEBUGGER
35+
}
2936
}
3037

31-
fun printDebugMishap(
32-
env: CastingContext,
33-
caster: ServerPlayer,
34-
mishap: OperatorSideEffect.DoMishap,
35-
) {
36-
mishap.mishap.errorMessageWithName(env, mishap.errorCtx)?.also {
37-
printDebugMessage(caster, it, OutputEventArgumentsCategory.STDERR)
38+
fun newEvaluatorCastEnv(caster: ServerPlayer, castingHand: InteractionHand): CastingContext {
39+
return CastingContext(caster, castingHand, CastSource.STAFF).apply {
40+
this as IMixinCastingContext
41+
`isDebugging$hexdebug` = true
42+
`debugCastEnvType$hexdebug` = DebugCastEnvType.EVALUATOR
3843
}
3944
}
4045

41-
val CastingVM.debugCastEnv get() = ctx as IMixinCastingContext
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
package gay.`object`.hexdebug.casting.eval
3+
4+
import at.petrak.hexcasting.api.spell.casting.CastingHarness
5+
import gay.`object`.hexdebug.adapter.DebugAdapterManager
6+
import net.minecraft.network.chat.Component
7+
import net.minecraft.server.level.ServerPlayer
8+
import org.eclipse.lsp4j.debug.OutputEventArgumentsCategory
9+
10+
@Suppress("CAST_NEVER_SUCCEEDS")
11+
val CastingHarness.debugCastEnv get() = ctx as IMixinCastingContext
12+
13+
fun printDebugMessage(
14+
caster: ServerPlayer,
15+
message: Component,
16+
category: String = OutputEventArgumentsCategory.STDOUT,
17+
withSource: Boolean = true,
18+
) {
19+
DebugAdapterManager[caster]?.print(message.string + "\n", category, withSource)
20+
}
21+

0 commit comments

Comments
 (0)