This commit is contained in:
gamma-delta 2022-06-12 20:29:47 -05:00
parent fc225b1afa
commit 06c7f97585
3 changed files with 7 additions and 11 deletions

View file

@ -135,12 +135,13 @@ class CastingHarness private constructor(
fun updateWithPattern(newPat: HexPattern, world: ServerLevel, continuation: SpellContinuation): CastResult {
var operatorIdPair: Pair<Operator, ResourceLocation>? = null
try {
// Don't catch this one
operatorIdPair = PatternRegistry.matchPatternAndID(newPat, world)
if (!HexConfig.server().isActionAllowed(operatorIdPair.second)) {
if (this.ctx.spellCircle == null && !HexConfig.server().isActionAllowed(operatorIdPair.second)) {
throw MishapDisallowedSpell()
} else if (this.ctx.spellCircle != null && !HexConfig.server().isActionAllowedInCircles(operatorIdPair.second)) {
} else if (this.ctx.spellCircle != null
&& !HexConfig.server().isActionAllowedInCircles(operatorIdPair.second)
) {
throw MishapDisallowedSpell("disallowed_circle")
}

View file

@ -1,17 +1,12 @@
package at.petrak.hexcasting.api.spell.casting
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult
import net.minecraft.server.level.ServerLevel
/**
* A continuation during the execution of a spell.
*/
sealed interface SpellContinuation {
object Done: SpellContinuation {}
object Done : SpellContinuation
data class NotDone(val frame: ContinuationFrame, val next: SpellContinuation): SpellContinuation {}
data class NotDone(val frame: ContinuationFrame, val next: SpellContinuation) : SpellContinuation
fun pushFrame(frame: ContinuationFrame): SpellContinuation = NotDone(frame, this)
}

View file

@ -20,7 +20,7 @@ object OpFisherman : Operator {
ctx: CastingContext
): OperationResult {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, 0)
throw MishapNotEnoughArgs(2, stack.size)
val arg = stack.getChecked<Double>(stack.lastIndex)
val datum = stack[stack.lastIndex]
val distance = stack.size - (arg + 1) // because getChecked<Int> just gives me a double for some reason