this won't compile, i forgor how to git

This commit is contained in:
petrak@ 2023-04-24 12:07:10 -05:00
parent 954f8918ae
commit 8fce0de22a
84 changed files with 256 additions and 232 deletions

View file

@ -53,7 +53,7 @@ interface Action {
override val argc: Int
get() = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> =
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> =
listOf(x)
}

View file

@ -16,7 +16,7 @@ interface ConstMediaAction : Action {
val mediaCost: Int
get() = 0
fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota>
fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota>
override fun operate(
env: CastingEnvironment,

View file

@ -18,10 +18,21 @@ data class CastingImage private constructor(
val parenCount: Int,
val parenthesized: List<Iota>,
val escapeNext: Boolean,
val opsConsumed: Long,
val userData: CompoundTag
) {
constructor() : this(listOf(), 0, listOf(), false, CompoundTag())
constructor() : this(listOf(), 0, listOf(), false, 0, CompoundTag())
/**
* Return a copy of this with the given number of ops additionally exhausted
*/
fun withUsedOps(count: Long) = this.copy(opsConsumed = this.opsConsumed + count)
/**
* Return a copy of this with 1 op used
*/
fun withUsedOp() = this.withUsedOps(1)
fun serializeToNbt() = NBTBuilder {
TAG_STACK %= stack.serializeToNBT()
@ -29,6 +40,7 @@ data class CastingImage private constructor(
TAG_PAREN_COUNT %= parenCount
TAG_ESCAPE_NEXT %= escapeNext
TAG_PARENTHESIZED %= parenthesized.serializeToNBT()
TAG_OPS_CONSUMED %= opsConsumed
TAG_USERDATA %= userData
}
@ -38,8 +50,8 @@ data class CastingImage private constructor(
const val TAG_PAREN_COUNT = "open_parens"
const val TAG_PARENTHESIZED = "parenthesized"
const val TAG_ESCAPE_NEXT = "escape_next"
const val TAG_OPS_CONSUMED = "ops_consumed"
const val TAG_USERDATA = "userdata"
const val TAG_RAVENMIND = "ravenmind"
@JvmStatic
public fun loadFromNbt(tag: CompoundTag, world: ServerLevel): CastingImage {
@ -53,10 +65,6 @@ data class CastingImage private constructor(
val userData = if (tag.contains(TAG_USERDATA)) {
tag.getCompound(TAG_USERDATA)
} else if (tag.contains("local")) {
NBTBuilder {
TAG_USERDATA %= tag.getCompound("local")
}
} else {
CompoundTag()
}
@ -69,8 +77,9 @@ data class CastingImage private constructor(
val parenCount = tag.getInt(TAG_PAREN_COUNT)
val escapeNext = tag.getBoolean(TAG_ESCAPE_NEXT)
val opsUsed = tag.getLong(TAG_OPS_CONSUMED)
CastingImage(stack, parenCount, parenthesized, escapeNext, userData)
CastingImage(stack, parenCount, parenthesized, escapeNext, opsUsed, userData)
} catch (exn: Exception) {
HexAPI.LOGGER.warn("error while loading a CastingImage", exn)
CastingImage()

View file

@ -53,19 +53,20 @@ data class FrameForEach(
// If we still have data to process...
val (stackTop, newImage, newCont) = if (data.nonEmpty) {
// Increment the evaluation depth,
// push the next datum to the top of the stack,
Triple(data.car, harness.image.incDepth(), continuation
val cont2 = continuation
// put the next Thoth object back on the stack for the next Thoth cycle,
.pushFrame(FrameForEach(data.cdr, code, stack, acc))
// and prep the Thoth'd code block for evaluation.
.pushFrame(FrameEvaluate(code, true)))
.pushFrame(FrameEvaluate(code, true))
Triple(data.car, harness.image.withUsedOp(), cont2)
} else {
// Else, dump our final list onto the stack.
Triple(ListIota(acc), harness.image, continuation)
}
val tStack = stack.toMutableList()
tStack.add(stackTop)
// TODO: this means we could have Thoth casting do a different sound
return CastResult(
newCont,
newImage.copy(stack = tStack),

View file

@ -1,4 +1,5 @@
@file:Suppress("NOTHING_TO_INLINE")
package at.petrak.hexcasting.api.utils
import net.minecraft.nbt.*
@ -70,6 +71,10 @@ value class NbtCompoundBuilder(val tag: CompoundTag) {
tag.put(this, int(num))
}
inline operator fun String.remAssign(num: Long) {
tag.put(this, long(num))
}
inline operator fun String.remAssign(num: Double) {
tag.put(this, double(num))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,9 +9,9 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpEntityHeight : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val e = args.getEntity(0, argc)
ctx.assertEntityInRange(e)
env.assertEntityInRange(e)
return e.bbHeight.asActionResult
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,9 +9,9 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpEntityLook : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val e = args.getEntity(0, argc)
ctx.assertEntityInRange(e)
env.assertEntityInRange(e)
return e.lookAngle.asActionResult
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,9 +9,9 @@ import at.petrak.hexcasting.api.casting.iota.Iota
class OpEntityPos(val feet: Boolean) : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val e = args.getEntity(0, argc)
ctx.assertEntityInRange(e)
env.assertEntityInRange(e)
return (if (this.feet) e.position() else e.eyePosition).asActionResult
}
}

View file

@ -10,9 +10,9 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpEntityVelocity : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val e = args.getEntity(0, argc)
ctx.assertEntityInRange(e)
env.assertEntityInRange(e)
val vel = HexAPI.instance().getEntityVelocitySpecial(e)
return vel.asActionResult

View file

@ -1,6 +1,5 @@
package at.petrak.hexcasting.common.casting.operators.akashic
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBlockPos
@ -8,22 +7,23 @@ import at.petrak.hexcasting.api.casting.getPattern
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.NullIota
import at.petrak.hexcasting.api.casting.mishaps.MishapNoAkashicRecord
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicRecord
object OpAkashicRead : ConstMediaAction {
override val argc = 2
override val mediaCost = MediaConstants.DUST_UNIT
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val pos = args.getBlockPos(0, argc)
val key = args.getPattern(1, argc)
val record = ctx.world.getBlockState(pos).block
val record = env.world.getBlockState(pos).block
if (record !is BlockAkashicRecord) {
throw MishapNoAkashicRecord(pos)
}
val datum = record.lookupPattern(pos, key, ctx.world)
val datum = record.lookupPattern(pos, key, env.world)
return listOf(datum ?: NullIota())
}
}

View file

@ -1,8 +1,9 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.eval.SpellCircleContext
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
import net.minecraft.world.phys.Vec3
@ -10,9 +11,8 @@ import net.minecraft.world.phys.Vec3
class OpCircleBounds(val max: Boolean) : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val circle = ctx.spellCircle
if (circle == null)
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
if (env !is SpellCircleContext)
throw MishapNoSpellCircle()
val aabb = circle.aabb

View file

@ -1,8 +1,8 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
@ -10,13 +10,13 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
object OpImpetusDir : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val circle = ctx.spellCircle
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val circle = env.spellCircle
if (circle == null)
throw MishapNoSpellCircle()
val pos = circle.impetusPos
val bs = ctx.world.getBlockState(pos)
val bs = env.world.getBlockState(pos)
val dir = bs.getValue(BlockAbstractImpetus.FACING)
return dir.step().asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
@ -9,8 +9,8 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
object OpImpetusPos : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val circle = ctx.spellCircle
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val circle = env.spellCircle
if (circle == null)
throw MishapNoSpellCircle()

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpAppend : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc).toMutableList()
val datum = args[1]
list.add(datum)

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpConcat : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getList(0, argc).toMutableList()
val rhs = args.getList(1, argc)
lhs.addAll(rhs)

View file

@ -1,15 +1,15 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.SpellList
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpCons : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val bottom = args.getList(0, argc)
val top = args[1]
return SpellList.LPair(top, bottom).asActionResult

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
object OpEmptyList : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return emptyList<Iota>().asActionResult // sorry for taking all the easy impls, hudeler
}
}

View file

@ -10,7 +10,7 @@ import kotlin.math.roundToInt
object OpIndex : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc).toMutableList()
val index = args.getDouble(1, argc)
val x = list.getOrElse(index.roundToInt()) { NullIota() }

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
@ -10,7 +10,7 @@ object OpIndexOf : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc).toMutableList()
val value = args[1]
return list.indexOfFirst { Iota.tolerates(value, it) }.asActionResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
// it's still called beancounter's distillation in my heart
object OpListSize : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return args.getList(0, argc).toList().size.asActionResult // mmm one-liner
}
}

View file

@ -1,13 +1,16 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.SpellList
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.getPositiveIntUnder
import at.petrak.hexcasting.api.casting.iota.Iota
object OpModifyInPlace : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc)
val index = args.getPositiveIntUnder(1, list.size(), argc)
val iota = args[2]

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getInt
import at.petrak.hexcasting.api.casting.getList
@ -11,7 +11,7 @@ object OpRemove : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc).toMutableList()
val index = args.getInt(1, argc)
if (index < 0 || index >= list.size)

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpReverski : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return args.getList(0, argc).toList().asReversed().asActionResult // okay kotlin kinda pogged for this
}
}

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
object OpSingleton : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return listOf(args[0]).asActionResult // god i love one-liners
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.getPositiveIntUnderInclusive
@ -11,7 +11,7 @@ import kotlin.math.min
object OpSlice : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc).toList()
val index1 = args.getPositiveIntUnderInclusive(1, list.size, argc)
val index2 = args.getPositiveIntUnderInclusive(2, list.size, argc)

View file

@ -9,6 +9,6 @@ object OpSplat : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> =
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> =
args.getList(0, argc).toList()
}

View file

@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.NullIota
object OpUnCons : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc)
if (list.nonEmpty) {
return listOf(ListIota(list.cdr), list.car)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpAbsLen : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val x = args.getNumOrVec(0, argc)
return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asActionResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -10,7 +10,7 @@ object OpAdd : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getNumOrVec(0, argc)
val rhs = args.getNumOrVec(1, argc)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.aplKinnie
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpCeil : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getNumOrVec(0, argc)
// i hate this fucking syntax what the hell is ::ceil are you a goddamn homestuck ::c
return listOf(aplKinnie(value, ::ceil))

View file

@ -13,7 +13,7 @@ object OpCoerceToAxial : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getNumOrVec(0, argc)
return value.map({ num ->
num.sign.asActionResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import net.minecraft.world.phys.Vec3
object OpConstructVec : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val x = args.getDouble(0, argc)
val y = args.getDouble(1, argc)
val z = args.getDouble(2, argc)

View file

@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpDeconstructVec : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val v = args.getVec3(0, argc)
return listOf(DoubleIota(v.x), DoubleIota(v.y), DoubleIota(v.z))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -12,7 +12,7 @@ object OpDivCross : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getNumOrVec(0, argc)
val rhs = args.getNumOrVec(1, argc)
val theMishap = MishapDivideByZero.of(args[0], args[1])
@ -30,13 +30,13 @@ object OpDivCross : ConstMediaAction {
}
)
}, { lvec ->
rhs.map(
{ rnum ->
if (lvec == Vec3.ZERO) throw theMishap
lvec.scale(1.0 / rnum).asActionResult
},
{ rvec -> lvec.cross(rvec).asActionResult }
)
})
rhs.map(
{ rnum ->
if (lvec == Vec3.ZERO) throw theMishap
lvec.scale(1.0 / rnum).asActionResult
},
{ rvec -> lvec.cross(rvec).asActionResult }
)
})
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.aplKinnie
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpFloor : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getNumOrVec(0, argc)
return listOf(aplKinnie(value, ::floor))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -12,7 +12,7 @@ object OpLog : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getDouble(0, argc)
val base = args.getDouble(1, argc)
if (value <= 0.0 || base <= 0.0 || base == 1.0)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpModulo : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
// TODO: some wAckY vector operation to go in the vector x vector overload
val l = args.getDouble(0, argc)
val r = args.getDouble(1, argc)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -10,7 +10,7 @@ object OpMulDot : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getNumOrVec(0, OpAdd.argc)
val rhs = args.getNumOrVec(1, OpAdd.argc)
@ -20,10 +20,10 @@ object OpMulDot : ConstMediaAction {
{ rnum -> (lnum * rnum).asActionResult }, { rvec -> rvec.scale(lnum).asActionResult }
)
}, { lvec ->
rhs.map(
{ rnum -> lvec.scale(rnum).asActionResult }, { rvec -> lvec.dot(rvec).asActionResult }
)
})
rhs.map(
{ rnum -> lvec.scale(rnum).asActionResult }, { rvec -> lvec.dot(rvec).asActionResult }
)
})
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -13,7 +13,7 @@ object OpPowProj : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getNumOrVec(0, OpAdd.argc)
val rhs = args.getNumOrVec(1, OpAdd.argc)
val theMishap = MishapDivideByZero.of(args[0], args[1], "exponent")
@ -26,24 +26,24 @@ object OpPowProj : ConstMediaAction {
throw theMishap
lnum.pow(rnum).asActionResult
}, { rvec ->
if (lnum == 0.0 && (rvec.x == 0.0 || rvec.y == 0.0 || rvec.z == 0.0))
throw theMishap
Vec3(lnum.pow(rvec.x), lnum.pow(rvec.y), lnum.pow(rvec.z)).asActionResult
}
if (lnum == 0.0 && (rvec.x == 0.0 || rvec.y == 0.0 || rvec.z == 0.0))
throw theMishap
Vec3(lnum.pow(rvec.x), lnum.pow(rvec.y), lnum.pow(rvec.z)).asActionResult
}
)
}, { lvec ->
rhs.map(
{ rnum ->
if (rnum == 0.0 && (lvec.x == 0.0 || lvec.y == 0.0 || lvec.z == 0.0))
throw theMishap
Vec3(lvec.x.pow(rnum), lvec.y.pow(rnum), lvec.z.pow(rnum)).asActionResult
},
{ rvec ->
if (lvec == Vec3.ZERO)
throw MishapDivideByZero.of(args[0], args[1], "project")
lvec.scale(rvec.dot(lvec) / lvec.dot(lvec)).asActionResult
}
)
})
rhs.map(
{ rnum ->
if (rnum == 0.0 && (lvec.x == 0.0 || lvec.y == 0.0 || lvec.z == 0.0))
throw theMishap
Vec3(lvec.x.pow(rnum), lvec.y.pow(rnum), lvec.z.pow(rnum)).asActionResult
},
{ rvec ->
if (lvec == Vec3.ZERO)
throw MishapDivideByZero.of(args[0], args[1], "project")
lvec.scale(rvec.dot(lvec) / lvec.dot(lvec)).asActionResult
}
)
})
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ object OpRandom : ConstMediaAction {
override val argc: Int
get() = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
return ctx.world.random.nextDouble().asActionResult
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return env.world.random.nextDouble().asActionResult
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getNumOrVec
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpSub : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getNumOrVec(0, OpAdd.argc)
val rhs = args.getNumOrVec(1, OpAdd.argc)

View file

@ -28,7 +28,7 @@ class SpecialHandlerNumberLiteral(val x: Double) : SpecialHandler {
class InnerAction(val x: Double) : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return this.x.asActionResult
}
}

View file

@ -1,14 +1,17 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.getLong
import at.petrak.hexcasting.api.casting.getLongOrList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpAnd : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val firstParam = args.getLongOrList(0, argc)
return firstParam.map(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getLong
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpNot : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val num = args.getLong(0, argc)
return num.inv().asActionResult
}

View file

@ -1,14 +1,17 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.getLong
import at.petrak.hexcasting.api.casting.getLongOrList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpOr : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val firstParam = args.getLongOrList(0, argc)
return firstParam.map(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpToSet : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val list = args.getList(0, argc)
val out = mutableListOf<Iota>()

View file

@ -1,14 +1,17 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getList
import at.petrak.hexcasting.api.casting.getLong
import at.petrak.hexcasting.api.casting.getLongOrList
import at.petrak.hexcasting.api.casting.iota.Iota
object OpXor : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val firstParam = args.getLongOrList(0, argc)
return firstParam.map(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBool
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolAnd : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getBool(0, argc)
val rhs = args.getBool(1, argc)
return (lhs && rhs).asActionResult

View file

@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolIf : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val cond = args.getBool(0, argc)
val t = args[1]
val f = args[2]

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBool
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolNot : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val b = args.getBool(0, argc)
return (!b).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBool
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolOr : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getBool(0, argc)
val rhs = args.getBool(1, argc)
return (lhs || rhs).asActionResult

View file

@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolToNumber : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val arg = args.getBool(0, argc)
return (if (arg) 1.0 else 0.0).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBool
import at.petrak.hexcasting.api.casting.iota.Iota
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolXor : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getBool(0, argc)
val rhs = args.getBool(1, argc)
return (lhs xor rhs).asActionResult

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
object OpCoerceToBool : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
return (args[0].isTruthy).asActionResult
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.DoubleIota
@ -11,7 +11,7 @@ import java.util.function.BiPredicate
class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate<Double, Double>) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args.getDouble(0, argc)
val rhs = args.getDouble(1, argc)
if (DoubleIota.tolerates(lhs, rhs))

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
class OpEquality(val invert: Boolean) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val lhs = args[0]
val rhs = args[1]

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDoubleBetween
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpArcCos : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getDoubleBetween(0, -1.0, 1.0, argc)
return acos(value).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDoubleBetween
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpArcSin : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getDoubleBetween(0, -1.0, 1.0, OpArcCos.argc)
return asin(value).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpArcTan : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val value = args.getDouble(0, argc)
return atan(value).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpArcTan2 : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val y = args.getDouble(0, argc)
val x = args.getDouble(1, argc)
return atan2(y, x).asActionResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpCos : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val angle = args.getDouble(0, argc)
return cos(angle).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ object OpSin : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val angle = args.getDouble(0, argc)
return sin(angle).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.DoubleIota
@ -14,7 +14,7 @@ object OpTan : ConstMediaAction {
override val argc: Int
get() = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val angle = args.getDouble(0, argc)
if (cos(angle) == 0.0)
throw MishapDivideByZero.tan(args[0] as DoubleIota)

View file

@ -15,23 +15,23 @@ import net.minecraft.world.phys.Vec3
object OpBlockAxisRaycast : ConstMediaAction {
override val argc = 2
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)
ctx.assertVecInRange(origin)
env.assertVecInRange(origin)
val blockHitResult = ctx.world.clip(
val blockHitResult = env.world.clip(
ClipContext(
origin,
Action.raycastEnd(origin, look),
ClipContext.Block.COLLIDER,
ClipContext.Fluid.NONE,
ctx.caster
env.caster
)
)
return if (blockHitResult.type == HitResult.Type.BLOCK && ctx.isVecInRange(Vec3.atCenterOf(blockHitResult.blockPos))) {
return if (blockHitResult.type == HitResult.Type.BLOCK && env.isVecInRange(Vec3.atCenterOf(blockHitResult.blockPos))) {
blockHitResult.direction.step().asActionResult
} else {
listOf(NullIota())

View file

@ -15,23 +15,23 @@ import net.minecraft.world.phys.Vec3
object OpBlockRaycast : ConstMediaAction {
override val argc = 2
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)
ctx.assertVecInRange(origin)
env.assertVecInRange(origin)
val blockHitResult = ctx.world.clip(
val blockHitResult = env.world.clip(
ClipContext(
origin,
Action.raycastEnd(origin, look),
ClipContext.Block.COLLIDER,
ClipContext.Fluid.NONE,
ctx.caster
env.caster
)
)
return if (blockHitResult.type == HitResult.Type.BLOCK && ctx.isVecInRange(Vec3.atCenterOf(blockHitResult.blockPos))) {
return if (blockHitResult.type == HitResult.Type.BLOCK && env.isVecInRange(Vec3.atCenterOf(blockHitResult.blockPos))) {
// the position on the bhr is the position of the specific *hit point*, which is actually on the outside of the block
// this is weird (for example, casting OpBreakBlock at this position will not break the block we're looking at)
// so we return the block pos instead

View file

@ -14,15 +14,15 @@ import net.minecraft.world.phys.AABB
object OpEntityRaycast : ConstMediaAction {
override val argc = 2
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)
val endp = Action.raycastEnd(origin, look)
ctx.assertVecInRange(origin)
env.assertVecInRange(origin)
val entityHitResult = ProjectileUtil.getEntityHitResult(
ctx.caster,
env.caster,
origin,
endp,
AABB(origin, endp),
@ -30,7 +30,7 @@ object OpEntityRaycast : ConstMediaAction {
1_000_000.0
)
return if (entityHitResult != null && ctx.isEntityInRange(entityHitResult.entity)) {
return if (entityHitResult != null && env.isEntityInRange(entityHitResult.entity)) {
entityHitResult.entity.asActionResult
} else {
listOf(NullIota())

View file

@ -9,16 +9,16 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpRead : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val (handStack, hand) = ctx.getHeldItemToOperateOn {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val (handStack, hand) = env.getHeldItemToOperateOn {
val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
dataHolder != null && (dataHolder.readIota(ctx.world) != null || dataHolder.emptyIota() != null)
dataHolder != null && (dataHolder.readIota(env.world) != null || dataHolder.emptyIota() != null)
}
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack)
?: throw MishapBadOffhandItem.of(handStack, hand, "iota.read")
val datum = datumHolder.readIota(ctx.world)
val datum = datumHolder.readIota(env.world)
?: datumHolder.emptyIota()
?: throw MishapBadOffhandItem.of(handStack, hand, "iota.read")

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.rw
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
@ -9,15 +9,15 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpReadable : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val (handStack) = ctx.getHeldItemToOperateOn {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val (handStack) = env.getHeldItemToOperateOn {
IXplatAbstractions.INSTANCE.findDataHolder(it) != null
}
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack)
?: return false.asActionResult
datumHolder.readIota(ctx.world)
datumHolder.readIota(env.world)
?: datumHolder.emptyIota()
?: return false.asActionResult

View file

@ -12,16 +12,16 @@ object OpTheCoolerRead : ConstMediaAction {
override fun execute(
args: List<Iota>,
ctx: CastingEnvironment
env: CastingEnvironment
): List<Iota> {
val target = args.getEntity(0, argc)
ctx.assertEntityInRange(target)
env.assertEntityInRange(target)
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(target)
?: throw MishapBadEntity.of(target, "iota.read")
val datum = datumHolder.readIota(ctx.world)
val datum = datumHolder.readIota(env.world)
?: datumHolder.emptyIota()
?: throw MishapBadEntity.of(target, "iota.read")
return listOf(datum)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.rw
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -12,15 +12,15 @@ object OpTheCoolerReadable : ConstMediaAction {
override fun execute(
args: List<Iota>,
ctx: CastingEnvironment
env: CastingEnvironment
): List<Iota> {
val target = args.getEntity(0, argc)
ctx.assertEntityInRange(target)
env.assertEntityInRange(target)
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(target)
?: return false.asActionResult
datumHolder.readIota(ctx.world)
datumHolder.readIota(env.world)
?: datumHolder.emptyIota()
?: return false.asActionResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.rw
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -13,10 +13,10 @@ object OpTheCoolerWritable : ConstMediaAction {
override fun execute(
args: List<Iota>,
ctx: CastingEnvironment
env: CastingEnvironment
): List<Iota> {
val target = args.getEntity(0, argc)
ctx.assertEntityInRange(target)
env.assertEntityInRange(target)
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(target)
?: return false.asActionResult

View file

@ -10,8 +10,8 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpWritable : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val (handStack) = ctx.getHeldItemToOperateOn {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val (handStack) = env.getHeldItemToOperateOn {
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
datumHolder != null

View file

@ -1,15 +1,15 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
object OpGetCaster : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
ctx.assertEntityInRange(ctx.caster)
return ctx.caster.asActionResult
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
env.assertEntityInRange(env.caster)
return env.caster.asActionResult
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getPositiveDouble
import at.petrak.hexcasting.api.casting.getVec3
@ -20,16 +20,16 @@ import java.util.function.Predicate
class OpGetEntitiesBy(val checker: Predicate<Entity>, val negate: Boolean) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val pos = args.getVec3(0, argc)
val radius = args.getPositiveDouble(1, argc)
ctx.assertVecInRange(pos)
env.assertVecInRange(pos)
val aabb = AABB(pos.add(Vec3(-radius, -radius, -radius)), pos.add(Vec3(radius, radius, radius)))
val entitiesGot = ctx.world.getEntities(null, aabb) {
isReasonablySelectable(ctx, it)
&& it.distanceToSqr(pos) <= radius * radius
&& (checker.test(it) != negate)
val entitiesGot = env.world.getEntities(null, aabb) {
isReasonablySelectable(env, it)
&& it.distanceToSqr(pos) <= radius * radius
&& (checker.test(it) != negate)
}.sortedBy { it.distanceToSqr(pos) }
return entitiesGot.map(::EntityIota).asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
@ -12,12 +12,12 @@ import java.util.function.Predicate
class OpGetEntityAt(val checker: Predicate<Entity>) : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val pos = args.getVec3(0, argc)
ctx.assertVecInRange(pos)
env.assertVecInRange(pos)
val aabb = AABB(pos.add(Vec3(-0.5, -0.5, -0.5)), pos.add(Vec3(0.5, 0.5, 0.5)))
val entitiesGot = ctx.world.getEntities(null, aabb) {
OpGetEntitiesBy.isReasonablySelectable(ctx, it) && checker.test(it)
val entitiesGot = env.world.getEntities(null, aabb) {
OpGetEntitiesBy.isReasonablySelectable(env, it) && checker.test(it)
}.sortedBy { it.distanceToSqr(pos) }
val entity = entitiesGot.getOrNull(0)

View file

@ -1,20 +1,20 @@
package at.petrak.hexcasting.common.casting.operators.spells.sentinel
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.NullIota
import at.petrak.hexcasting.api.casting.mishaps.MishapLocationInWrongDimension
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpGetSentinelPos : ConstMediaAction {
override val argc = 0
override val mediaCost = MediaConstants.DUST_UNIT / 10
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
if (sentinel.dimension != ctx.world.dimension())
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(env.caster)
if (sentinel.dimension != env.world.dimension())
throw MishapLocationInWrongDimension(sentinel.dimension.location())
return if (sentinel.hasSentinel)
sentinel.position.asActionResult

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.spells.sentinel
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.NullIota
import at.petrak.hexcasting.api.casting.mishaps.MishapLocationInWrongDimension
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.xplat.IXplatAbstractions
// TODO I don't think anyone has ever used this operation in the history of the world.
@ -15,12 +15,12 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpGetSentinelWayfind : ConstMediaAction {
override val argc = 1
override val mediaCost = MediaConstants.DUST_UNIT / 10
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val from = args.getVec3(0, argc)
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(env.caster)
if (sentinel.dimension != ctx.world.dimension())
if (sentinel.dimension != env.world.dimension())
throw MishapLocationInWrongDimension(sentinel.dimension.location())
return if (!sentinel.hasSentinel)

View file

@ -10,7 +10,7 @@ object OpDuplicateN : ConstMediaAction {
override val argc: Int
get() = 2
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val count = args.getPositiveInt(1, argc)
if (count > 1000) {

View file

@ -10,7 +10,7 @@ class OpMask(val mask: BooleanList, val key: ResourceLocation) : ConstMediaActio
override val argc: Int
get() = mask.size
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val out = ArrayList<Iota>(this.mask.size)
for ((i, include) in this.mask.withIndex()) {
if (include)

View file

@ -8,6 +8,6 @@ class OpTwiddling(val argumentCount: Int, val lookup: IntArray) : ConstMediaActi
override val argc: Int
get() = this.argumentCount
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> =
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> =
this.lookup.map(args::get)
}

View file

@ -35,7 +35,7 @@ class SpecialHandlerMask(val mask: BooleanList) : SpecialHandler {
override val argc: Int
get() = this.mask.size
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val out = ArrayList<Iota>(this.mask.size)
for ((i, include) in this.mask.withIndex()) {
if (include)

View file

@ -44,7 +44,6 @@ public class HexAPIImpl implements HexAPI {
return entity.getDeltaMovement();
}
<<<<<<< HEAD
//region brainsweeping
@Override
@ -75,7 +74,6 @@ public class HexAPIImpl implements HexAPI {
}
//endregion
=======
@Override
public @Nullable Sentinel getSentinel(ServerPlayer player) {
return IXplatAbstractions.INSTANCE.getSentinel(player);
@ -90,5 +88,4 @@ public class HexAPIImpl implements HexAPI {
public FrozenColorizer getColorizer(Player player) {
return IXplatAbstractions.INSTANCE.getColorizer(player);
}
>>>>>>> casting-context
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.interop.pehkui
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -10,7 +10,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpGetScale : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val target = args.getEntity(0, argc)
return IXplatAbstractions.INSTANCE.pehkuiApi.getScale(target).toDouble().asActionResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.fabric.interop.gravity
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.iota.Iota
@ -11,7 +11,7 @@ import net.minecraft.world.phys.Vec3
object OpGetGravity : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val target = args.getEntity(0)
val grav = GravityChangerAPI.getGravityDirection(target)
return Vec3.atLowerCornerOf(grav.normal).asActionResult