Skip to content

Commit e2ae8fb

Browse files
committed
Reimplement intro/retro {} special case
1 parent 8054c92 commit e2ae8fb

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Common/src/main/kotlin/gay/object/hexdebug/debugger/HexDebugger.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.spell.SpellList
66
import at.petrak.hexcasting.api.spell.casting.CastingHarness
77
import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult
88
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
9+
import at.petrak.hexcasting.api.spell.casting.SpecialPatterns
910
import at.petrak.hexcasting.api.spell.casting.eval.*
1011
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation.Done
1112
import at.petrak.hexcasting.api.spell.casting.eval.SpellContinuation.NotDone
@@ -23,6 +24,7 @@ import gay.`object`.hexdebug.casting.eval.*
2324
import gay.`object`.hexdebug.debugger.allocators.SourceAllocator
2425
import gay.`object`.hexdebug.debugger.allocators.VariablesAllocator
2526
import gay.`object`.hexdebug.utils.ceilToPow
27+
import net.minecraft.network.chat.Component
2628
import net.minecraft.server.level.ServerLevel
2729
import net.minecraft.sounds.SoundSource
2830
import net.minecraft.world.level.gameevent.GameEvent
@@ -671,11 +673,7 @@ class HexDebugger(
671673
}
672674

673675
private fun iotaToString(iota: Iota, isSource: Boolean = false): String = when (iota) {
674-
is PatternIota -> try {
675-
PatternRegistry.matchPattern(iota.pattern, vm.ctx.world).displayName
676-
} catch (e: MishapInvalidPattern) {
677-
PatternNameHelper.representationForPattern(iota.pattern)
678-
}.string
676+
is PatternIota -> patternToString(iota.pattern, isSource).string
679677

680678
else -> {
681679
val result = when (iota) {
@@ -690,6 +688,21 @@ class HexDebugger(
690688
}
691689
}
692690
}
691+
692+
private fun patternToString(pattern: HexPattern, isSource: Boolean = false): Component {
693+
if (isSource) {
694+
when (pattern) {
695+
SpecialPatterns.INTROSPECTION -> return Component.literal("{")
696+
SpecialPatterns.RETROSPECTION -> return Component.literal("}")
697+
else -> {}
698+
}
699+
}
700+
return try {
701+
PatternRegistry.matchPattern(pattern, vm.ctx.world).displayName
702+
} catch (e: MishapInvalidPattern) {
703+
PatternNameHelper.representationForPattern(pattern)
704+
}
705+
}
693706
}
694707

695708
val SpellContinuation.frame get() = (this as? NotDone)?.frame

0 commit comments

Comments
 (0)