slightly updated docs

This commit is contained in:
petrak@ 2023-02-04 12:49:04 -06:00
parent 1623d29653
commit 29b6f536b9
19 changed files with 133 additions and 111 deletions

View file

@ -1,9 +1,10 @@
package at.petrak.hexcasting.api.casting.castables
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.phys.Vec3
import java.text.DecimalFormat
@ -24,25 +25,26 @@ interface Action {
*
* Although this is passed a [MutableList], this is only for the convenience of implementors.
* It is a clone of the stack and modifying it does nothing. You must return the new stack
* with the [OperationResult].
* with the [OperationResult]. Similar with the `userData`.
*
* A particle effect at the cast site and various messages and advancements are done automagically.
*/
fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult
companion object {
// I see why vzakii did this: you can't raycast out to infinity!
const val MAX_DISTANCE: Double = 32.0
const val MAX_DISTANCE_FROM_SENTINEL: Double = 16.0
// I see why vazkii did this: you can't raycast out to infinity!
const val RAYCAST_DISTANCE: Double = 32.0
// TODO: currently, this means you can't raycast in a very long spell circle, or out of your local ambit into
// your sentinel's.
@JvmStatic
fun raycastEnd(origin: Vec3, look: Vec3): Vec3 =
origin.add(look.normalize().scale(MAX_DISTANCE))
origin.add(look.normalize().scale(RAYCAST_DISTANCE))
@JvmStatic
fun makeConstantOp(x: Iota): Action = object : ConstMediaAction {

View file

@ -1,11 +1,12 @@
package at.petrak.hexcasting.api.casting.castables
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
/**
* A SimpleOperator that always costs the same amount of media.
@ -18,20 +19,20 @@ interface ConstMediaAction : Action {
fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota>
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (this.argc > stack.size)
throw MishapNotEnoughArgs(this.argc, stack.size)
val args = stack.takeLast(this.argc)
repeat(this.argc) { stack.removeLast() }
val newData = this.execute(args, ctx)
val newData = this.execute(args, env)
stack.addAll(newData)
val sideEffects = mutableListOf<OperatorSideEffect>(OperatorSideEffect.ConsumeMedia(this.mediaCost))
return OperationResult(continuation, stack, ravenmind, sideEffects)
return OperationResult(stack, userData, sideEffects, continuation)
}
}

View file

@ -1,13 +1,14 @@
package at.petrak.hexcasting.api.casting.castables
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.ParticleSpray
import at.petrak.hexcasting.api.casting.RenderedSpell
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
interface SpellAction : Action {
val argc: Int
@ -22,16 +23,16 @@ interface SpellAction : Action {
): Triple<RenderedSpell, Int, List<ParticleSpray>>?
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (this.argc > stack.size)
throw MishapNotEnoughArgs(this.argc, stack.size)
val args = stack.takeLast(this.argc)
for (_i in 0 until this.argc) stack.removeLast()
val executeResult = this.execute(args, ctx) ?: return OperationResult(continuation, stack, ravenmind, listOf())
val executeResult = this.execute(args, env) ?: return OperationResult(stack, userData, listOf(), continuation)
val (spell, media, particles) = executeResult
val sideEffects = mutableListOf<OperatorSideEffect>()
@ -42,15 +43,15 @@ interface SpellAction : Action {
sideEffects.add(
OperatorSideEffect.AttemptSpell(
spell,
this.hasCastingSound(ctx),
this.awardsCastingStat(ctx)
this.hasCastingSound(env),
this.awardsCastingStat(env)
)
)
for (spray in particles)
sideEffects.add(OperatorSideEffect.Particles(spray))
return OperationResult(continuation, stack, ravenmind, sideEffects)
return OperationResult(stack, userData, sideEffects, continuation)
}
}

View file

@ -1,15 +1,16 @@
package at.petrak.hexcasting.api.casting
package at.petrak.hexcasting.api.casting.eval
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import net.minecraft.nbt.CompoundTag
/**
* What happens when an operator is through?
*/
data class OperationResult(
val newContinuation: SpellContinuation,
val newStack: List<Iota>,
val newRavenmind: Iota?,
val sideEffects: List<OperatorSideEffect>
val newUserdata: CompoundTag,
val sideEffects: List<OperatorSideEffect>,
val newContinuation: SpellContinuation
)

View file

@ -23,16 +23,17 @@ because I keep forgetting.
makes sure that the passed iota is a pattern and passes *that* on to `executePattern`.
6. `executePattern` is where the execution actually happens. The pattern is matched to an action or special handler.
and executed.
7. That execution doesn't mutate anything, but returns a [CastResult]. It contains:
7. The execution returns an [OperationResult], containing:
- the rest of the current continuation (read as: the patterns to execute next);
- the updated state of the [CastingImage];
- a list of `OperatorSideEffects`, like withdrawing media, casting spells or mishaping;
- misc display info like the color the pattern should be when drawn to the staff GUI and the sound.
8. Each of the side effects is applied to the world in turn. If any of them make the casting stop (like mishaping),
8. The operation result is composed with some misc display info, like the color the pattern should be when drawn to
the staff GUI and the sound.
9. Each of the side effects is applied to the world in turn. If any of them make the casting stop (like mishaping),
then it does!
9. If there's still iotas left in the current continuation, then control goes back to step 5, called on the next iota in
continuation.
10. Otherwise, control goes to the top frame of the stack (step 3). And if there are no stack frames, execution is
10. If there's still iotas left in the current continuation, then control goes back to step 5, called on the next iota
in the continuation.
11. Otherwise, control goes to the top frame of the stack (step 3). And if there are no stack frames, execution is
finished! What a ride.
## The Hell's A Continuation And A Continuation Frame
@ -70,5 +71,7 @@ Continuations are just a linked list of iotas to execute. The VM goes through ea
[FrameEvaluate]: vm/FrameEvaluate.kt
[OperationResult]: OperationResult.kt
[CastResult]: CastResult.kt

View file

@ -175,10 +175,10 @@ class CastingVM(val image: CastingImage, val env: CastingEnvironment) {
var ravenmind2: Iota? = null
val result = action.operate(
continuation,
this.ctx,
this.stack.toMutableList(),
this.ravenmind,
this.ctx
continuation
)
cont2 = result.newContinuation
stack2 = result.newStack

View file

@ -4,7 +4,6 @@ import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers;
import at.petrak.hexcasting.api.casting.ParticleSpray;
import at.petrak.hexcasting.api.casting.castables.Action;
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect;
import at.petrak.hexcasting.api.casting.mishaps.Mishap;
@ -28,6 +27,9 @@ import java.util.List;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public abstract class PlayerBasedCastEnv extends CastingEnvironment {
public static final double AMBIT_RADIUS = 32.0;
public static final double SENTINEL_RADIUS = 16.0;
protected final ServerPlayer caster;
protected final InteractionHand castingHand;
@ -98,12 +100,12 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
if (sentinel != null
&& sentinel.extendsRange()
&& this.caster.getLevel().dimension() == sentinel.dimension()
&& vec.distanceToSqr(sentinel.position()) <= Action.MAX_DISTANCE_FROM_SENTINEL * Action.MAX_DISTANCE_FROM_SENTINEL
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS
) {
return true;
}
return vec.distanceToSqr(this.caster.position()) <= Action.MAX_DISTANCE * Action.MAX_DISTANCE;
return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS;
}
@Override

View file

@ -1,9 +1,9 @@
package at.petrak.hexcasting.common.casting.operators.eval
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.SpellList
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.FrameEvaluate
import at.petrak.hexcasting.api.casting.eval.vm.FrameFinishEval
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
@ -11,19 +11,20 @@ import at.petrak.hexcasting.api.casting.evaluatable
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.PatternIota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
object OpEval : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
val datum = stack.removeLastOrNull() ?: throw MishapNotEnoughArgs(1, 0)
val instrs = evaluatable(datum, 0)
instrs.ifRight {
ctx.incDepth()
env.incDepth()
}
// if not installed already...
@ -37,6 +38,6 @@ object OpEval : Action {
val instrsList = instrs.map({ SpellList.LList(0, listOf(PatternIota(it))) }, { it })
val frame = FrameEvaluate(instrsList, true)
return OperationResult(newCont.pushFrame(frame), stack, ravenmind, listOf())
return OperationResult(stack, userData, listOf(), newCont.pushFrame(frame))
}
}

View file

@ -1,20 +1,21 @@
package at.petrak.hexcasting.common.casting.operators.eval
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.FrameForEach
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
object OpForEach : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)
@ -27,10 +28,10 @@ object OpForEach : Action {
val frame = FrameForEach(datums, instrs, null, mutableListOf())
return OperationResult(
continuation.pushFrame(frame),
stack,
ravenmind,
listOf()
userData,
listOf(),
continuation.pushFrame(frame)
)
}
}

View file

@ -1,17 +1,18 @@
package at.petrak.hexcasting.common.casting.operators.eval
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import net.minecraft.nbt.CompoundTag
object OpHalt : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
var newStack = stack.toList()
var done = false
@ -29,6 +30,6 @@ object OpHalt : Action {
newStack = listOf()
}
return OperationResult(newCont, newStack, ravenmind, listOf())
return OperationResult(newStack, userData, listOf(), newCont)
}
}

View file

@ -1,20 +1,21 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getPositiveIntUnderInclusive
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
object OpLastNToList : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.isEmpty())
throw MishapNotEnoughArgs(1, 0)
@ -27,6 +28,6 @@ object OpLastNToList : Action {
}
stack.addAll(output.asActionResult)
return OperationResult(continuation, stack, ravenmind, listOf())
return OperationResult(stack, userData, listOf(), continuation)
}
}

View file

@ -1,20 +1,21 @@
package at.petrak.hexcasting.common.casting.operators.local
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.orNull
import net.minecraft.nbt.CompoundTag
object OpPeekLocal : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
stack.add(ravenmind.orNull())
return OperationResult(continuation, stack, ravenmind, listOf())
stack.add(userData.orNull())
return OperationResult(stack, userData, listOf(), continuation)
}
}

View file

@ -1,22 +1,23 @@
package at.petrak.hexcasting.common.casting.operators.local
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
object OpPushLocal : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.isEmpty())
throw MishapNotEnoughArgs(1, 0)
val newLocal = stack.removeLast()
return OperationResult(continuation, stack, newLocal, listOf())
return OperationResult(stack, newLocal, listOf(), continuation)
}
}

View file

@ -1,30 +1,31 @@
package at.petrak.hexcasting.common.casting.operators.spells
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.RenderedSpell
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
// TODO should this dump the whole stack
object OpPrint : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.isEmpty()) {
throw MishapNotEnoughArgs(1, 0)
}
val datum = stack[stack.lastIndex]
return OperationResult(
continuation, stack, ravenmind, listOf(
stack, userData, listOf(
OperatorSideEffect.AttemptSpell(Spell(datum), hasCastingSound = false, awardStat = false)
)
), continuation
)
}

View file

@ -1,21 +1,22 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getPositiveInt
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import it.unimi.dsi.fastutil.ints.IntArrayList
import net.minecraft.nbt.CompoundTag
// "lehmer code"
object OpAlwinfyHasAscendedToABeingOfPureMath : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.isEmpty())
throw MishapNotEnoughArgs(1, 0)
@ -45,10 +46,10 @@ object OpAlwinfyHasAscendedToABeingOfPureMath : Action {
}
return OperationResult(
continuation,
stack,
ravenmind,
listOf()
userData,
listOf(),
continuation
)
}

View file

@ -1,21 +1,22 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getPositiveInt
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
// Yes this is weird in that 1=remove, 0=keep, but i think the UX is better
// todo this is untested
object OpBitMask : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.size < 1)
throw MishapNotEnoughArgs(1, 0)
@ -38,6 +39,6 @@ object OpBitMask : Action {
}
}
return OperationResult(continuation, out.asReversed(), ravenmind, listOf())
return OperationResult(out.asReversed(), userData, listOf(), continuation)
}
}

View file

@ -1,22 +1,23 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.DoubleIota
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
import kotlin.math.abs
import kotlin.math.roundToInt
object OpFisherman : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)
@ -38,6 +39,6 @@ object OpFisherman : Action {
val fish = stack.removeAt(stack.size - depth)
stack.add(fish)
return OperationResult(continuation, stack, ravenmind, listOf())
return OperationResult(stack, userData, listOf(), continuation)
}
}

View file

@ -1,19 +1,20 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.getPositiveIntUnderInclusive
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import net.minecraft.nbt.CompoundTag
object OpFishermanButItCopies : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)
@ -23,6 +24,6 @@ object OpFishermanButItCopies : Action {
val fish = stack.get(stack.size - 1 - depth)
stack.add(fish)
return OperationResult(continuation, stack, ravenmind, listOf())
return OperationResult(stack, userData, listOf(), continuation)
}
}

View file

@ -1,20 +1,21 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.casting.castables.Action
import at.petrak.hexcasting.api.casting.OperationResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.OperationResult
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
import at.petrak.hexcasting.api.casting.iota.DoubleIota
import at.petrak.hexcasting.api.casting.iota.Iota
import net.minecraft.nbt.CompoundTag
object OpStackSize : Action {
override fun operate(
continuation: SpellContinuation,
env: CastingEnvironment,
stack: MutableList<Iota>,
ravenmind: Iota?,
ctx: CastingEnvironment
userData: CompoundTag,
continuation: SpellContinuation
): OperationResult {
stack.add(DoubleIota(stack.size.toDouble()))
return OperationResult(continuation, stack, ravenmind, listOf())
return OperationResult(stack, userData, listOf(), continuation)
}
}