kotlin went great, now for java

This commit is contained in:
gamma-delta 2022-06-13 19:26:39 -05:00
parent e00757331e
commit 7403d87e6f
141 changed files with 273 additions and 273 deletions

View file

@ -13,9 +13,9 @@ interface ConstManaOperator : Operator {
val manaCost: Int
get() = 0
fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>>
fun execute(args: List<Iota>, ctx: CastingContext): List<Iota>
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult {
if (this.argc > stack.size)
throw MishapNotEnoughArgs(this.argc, stack.size)
val args = stack.takeLast(this.argc)

View file

@ -6,4 +6,4 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
/**
* What happens when an operator is through?
*/
data class OperationResult(val newContinuation: SpellContinuation, val newStack: List<LegacySpellDatum<*>>, val newLocalIota: LegacySpellDatum<*>, val sideEffects: List<OperatorSideEffect>)
data class OperationResult(val newContinuation: SpellContinuation, val newStack: List<Iota>, val newLocalIota: Iota, val sideEffects: List<OperatorSideEffect>)

View file

@ -21,7 +21,7 @@ interface Operator {
*
* A particle effect at the cast site and various messages and advancements are done automagically.
*/
fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult
fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult
/**
* Do you need to be enlightened to use this operator? (i.e. is this operator a Great Pattern)
@ -50,11 +50,11 @@ interface Operator {
origin.add(look.normalize().scale(MAX_DISTANCE))
@JvmStatic
fun makeConstantOp(x: LegacySpellDatum<*>): Operator = object : ConstManaOperator {
fun makeConstantOp(x: Iota): Operator = object : ConstManaOperator {
override val argc: Int
get() = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> =
listOf(x)
}
}

View file

@ -13,7 +13,7 @@ import net.minecraft.world.entity.Entity
import net.minecraft.world.phys.Vec3
import kotlin.math.abs
fun numOrVec(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
fun numOrVec(datum: Iota, reverseIdx: Int): Either<Double, Vec3> =
when (datum.payload) {
is Double -> Either.left(datum.payload)
is Vec3 -> Either.right(datum.payload)
@ -24,7 +24,7 @@ fun numOrVec(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, Vec3>
)
}
fun numOrList(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, SpellList> =
fun numOrList(datum: Iota, reverseIdx: Int): Either<Double, SpellList> =
when (datum.payload) {
is Double -> Either.left(datum.payload)
is SpellList -> Either.right(datum.payload)
@ -35,15 +35,15 @@ fun numOrList(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, Spell
)
}
fun spellListOf(vararg vs: Any): List<LegacySpellDatum<*>> {
val out = ArrayList<LegacySpellDatum<*>>(vs.size)
fun spellListOf(vararg vs: Any): List<Iota> {
val out = ArrayList<Iota>(vs.size)
for (v in vs) {
out.add(LegacySpellDatum.make(v))
}
return out
}
inline fun <reified T : Any> List<LegacySpellDatum<*>>.getChecked(idx: Int, argc: Int = 0): T {
inline fun <reified T : Any> List<Iota>.getChecked(idx: Int, argc: Int = 0): T {
val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
if (x.payload is T)
return x.payload
@ -57,7 +57,7 @@ inline val Double.asSpellResult get() = spellListOf(this)
inline val Number.asSpellResult get() = spellListOf(this.toDouble())
inline val SpellList.asSpellResult get() = spellListOf(this)
inline val List<LegacySpellDatum<*>>.asSpellResult get() = spellListOf(this)
inline val List<Iota>.asSpellResult get() = spellListOf(this)
inline val Widget.asSpellResult get() = spellListOf(this)
@ -74,9 +74,9 @@ fun Any.tolerantEquals(other: Any) = tolerantEquals(other, 64)
private fun Any.tolerantEquals(other: Any, recursionsLeft: Int): Boolean {
return when {
this is LegacySpellDatum<*> && other is LegacySpellDatum<*> -> this.payload.tolerantEquals(other.payload, recursionsLeft)
this is LegacySpellDatum<*> -> this.payload.tolerantEquals(other, recursionsLeft)
other is LegacySpellDatum<*> -> this.tolerantEquals(other.payload, recursionsLeft)
this is Iota && other is Iota -> this.payload.tolerantEquals(other.payload, recursionsLeft)
this is Iota -> this.payload.tolerantEquals(other, recursionsLeft)
other is Iota -> this.tolerantEquals(other.payload, recursionsLeft)
this is HexPattern && other is HexPattern -> this.angles == other.angles
this is Double && other is Double -> abs(this - other) < TOLERANCE

View file

@ -13,11 +13,11 @@ interface SpellOperator : Operator {
fun awardsCastingStat(ctx: CastingContext): Boolean = true
fun execute(
args: List<LegacySpellDatum<*>>,
args: List<Iota>,
ctx: CastingContext
): Triple<RenderedSpell, Int, List<ParticleSpray>>?
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult {
if (this.argc > stack.size)
throw MishapNotEnoughArgs(this.argc, stack.size)
val args = stack.takeLast(this.argc)

View file

@ -16,7 +16,7 @@ enum class Widget : ConstManaOperator {
override val argc: Int
get() = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> =
this.asSpellResult
companion object {

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.api.spell.casting
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
/**
* A change to the data in a CastHarness after a pattern is drawn.
*/
data class FunctionalData(
val stack: List<LegacySpellDatum<*>>,
val stack: List<Iota>,
val parenCount: Int,
val parenthesized: List<LegacySpellDatum<*>>,
val parenthesized: List<Iota>,
val escapeNext: Boolean,
) {
/**

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.mod.HexItemTags
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
import at.petrak.hexcasting.api.spell.math.HexPattern
@ -38,7 +38,7 @@ sealed class Mishap : Throwable() {
*
* You can also mess up the stack with this.
*/
abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>)
abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>)
abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.misc.HexDamageSources
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.entity.npc.Villager
@ -12,7 +12,7 @@ class MishapAlreadyBrainswept(val villager: Villager) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.GREEN)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.utils.asTranslatedComponent
import net.minecraft.core.BlockPos
@ -15,7 +15,7 @@ class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.LIME)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
}

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.misc.HexDamageSources
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.core.BlockPos
import net.minecraft.world.entity.npc.Villager
@ -14,7 +14,7 @@ class MishapBadBrainsweep(val villager: Villager, val pos: BlockPos) : Mishap()
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.GREEN)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.utils.asTranslatedComponent
import net.minecraft.network.chat.Component
@ -12,7 +12,7 @@ class MishapBadItem(val item: ItemEntity, val wanted: Component) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BROWN)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.utils.asTranslatedComponent
import net.minecraft.network.chat.Component
@ -13,7 +13,7 @@ class MishapBadOffhandItem(val item: ItemStack, val hand: InteractionHand, val w
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BROWN)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
yeetHeldItem(ctx, hand)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
import net.minecraft.world.item.DyeColor
@ -12,7 +12,7 @@ class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() {
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
// NO-OP
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.misc.HexDamageSources
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.utils.asTranslatedComponent
@ -15,7 +15,7 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.RED)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.Entity
@ -11,7 +11,7 @@ class MishapEntityTooFarAway(val entity: Entity) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.PINK)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
// Knock the player's items out of their hands
yeetHeldItemsTowards(ctx, entity.position())
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.item.DyeColor
@ -9,7 +9,7 @@ class MishapError(val exception: Exception) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BLACK)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
// NO-OP
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.item.DyeColor
@ -9,7 +9,7 @@ class MishapEvalTooDeep : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BLUE)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
ctx.caster.airSupply -= 290
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.entity.Entity
import net.minecraft.world.item.DyeColor
@ -10,7 +10,7 @@ class MishapImmuneEntity(val entity: Entity) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BLUE)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
yeetHeldItemsTowards(ctx, entity.position())
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
@ -22,14 +22,14 @@ import net.minecraft.world.phys.Vec3
* [MishapInvalidIota.reverseIdx] is the index from the *back* of the stack.
*/
class MishapInvalidIota(
val perpetrator: LegacySpellDatum<*>,
val perpetrator: Iota,
val reverseIdx: Int,
val expected: Component
) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.GRAY)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
stack[stack.size - 1 - reverseIdx] = LegacySpellDatum.make(Widget.GARBAGE)
}
@ -39,7 +39,7 @@ class MishapInvalidIota(
companion object {
@JvmStatic
fun ofClass(perpetrator: LegacySpellDatum<*>, reverseIdx: Int, cls: Class<*>): MishapInvalidIota {
fun ofClass(perpetrator: Iota, reverseIdx: Int, cls: Class<*>): MishapInvalidIota {
val key = "hexcasting.mishap.invalid_value.class." + when {
Double::class.java.isAssignableFrom(cls) || Double::class.javaObjectType.isAssignableFrom(cls) -> "double"
Vec3::class.java.isAssignableFrom(cls) -> "vector"

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
@ -13,7 +13,7 @@ class MishapInvalidPattern : Mishap() {
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.item.DyeColor
@ -12,7 +12,7 @@ class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BLACK)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
// NO-OP
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.network.chat.Component
@ -12,7 +12,7 @@ class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mi
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.MAGENTA)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
@ -11,7 +11,7 @@ class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far")
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.MAGENTA)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
yeetHeldItemsTowards(ctx, location)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.core.BlockPos
import net.minecraft.world.item.DyeColor
@ -10,7 +10,7 @@ class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.PURPLE)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
ctx.caster.giveExperiencePoints(-100)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.item.DyeColor
@ -9,7 +9,7 @@ class MishapNoSpellCircle : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.LIGHT_BLUE)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
ctx.caster.inventory.dropAll()
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.network.chat.Component
@ -11,7 +11,7 @@ class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.LIGHT_GRAY)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
for (i in got until expected)
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.effect.MobEffectInstance
@ -13,7 +13,7 @@ class MishapOthersName(val other: Player) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.BLACK)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60))
}
@ -22,14 +22,14 @@ class MishapOthersName(val other: Player) : Mishap() {
companion object {
@JvmStatic
fun getTrueNameFromDatum(datum: LegacySpellDatum<*>, caster: Player): Player? {
fun getTrueNameFromDatum(datum: Iota, caster: Player): Player? {
if (datum.payload is Player && datum.payload != caster)
return datum.payload
else if (datum.payload !is SpellList)
return null
val poolToSearch: MutableList<LegacySpellDatum<*>> =
datum.payload.filterIsInstance<LegacySpellDatum<*>>().toMutableList()
val poolToSearch: MutableList<Iota> =
datum.payload.filterIsInstance<Iota>().toMutableList()
while (poolToSearch.isNotEmpty()) {
val datumToCheck = poolToSearch[0]
@ -38,14 +38,14 @@ class MishapOthersName(val other: Player) : Mishap() {
if (datumToCheck.payload is Player && datumToCheck.payload != caster)
return datumToCheck.payload
else if (datumToCheck.payload is SpellList)
poolToSearch.addAll(datumToCheck.payload.filterIsInstance<LegacySpellDatum<*>>())
poolToSearch.addAll(datumToCheck.payload.filterIsInstance<Iota>())
}
return null
}
@JvmStatic
fun getTrueNameFromArgs(datums: List<LegacySpellDatum<*>>, caster: Player): Player? {
fun getTrueNameFromArgs(datums: List<Iota>, caster: Player): Player? {
return datums.firstNotNullOfOrNull { getTrueNameFromDatum(it, caster) }
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
@ -10,7 +10,7 @@ class MishapTooManyCloseParens : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.ORANGE)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
stack.add(LegacySpellDatum.make(errorCtx.pattern))
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.mishaps
import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import net.minecraft.world.item.DyeColor
@ -9,12 +9,12 @@ import net.minecraft.world.item.DyeColor
* The value was a naked iota without being Considered or Retrospected.
*/
class MishapUnescapedValue(
val perpetrator: LegacySpellDatum<*>
val perpetrator: Iota
) : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
dyeColor(DyeColor.GRAY)
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) {
// TODO
/*
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }

View file

@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
object OpBlockAxisRaycast : ConstManaOperator {
override val argc = 2
override val manaCost = ManaConstants.DUST_UNIT / 100
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin: Vec3 = args.getChecked(0, argc)
val look: Vec3 = args.getChecked(1, argc)

View file

@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
object OpBlockRaycast : ConstManaOperator {
override val argc = 2
override val manaCost = ManaConstants.DUST_UNIT / 100
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin: Vec3 = args.getChecked(0, argc)
val look: Vec3 = args.getChecked(1, argc)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity
object OpEntityHeight : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val e: Entity = args.getChecked(0, argc)
ctx.assertEntityInRange(e)
return e.bbHeight.asSpellResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity
object OpEntityLook : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val e: Entity = args.getChecked(0, argc)
ctx.assertEntityInRange(e)
return e.lookAngle.asSpellResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ import net.minecraft.world.entity.player.Player
object OpEntityPos : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val e: Entity = args.getChecked(0, argc)
ctx.assertEntityInRange(e)
// If this is a player, "expected behavior" is to get the *eye* position so raycasts don't immediately

View file

@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
object OpEntityRaycast : ConstManaOperator {
override val argc = 2
override val manaCost = ManaConstants.DUST_UNIT / 100
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin: Vec3 = args.getChecked(0, argc)
val look: Vec3 = args.getChecked(1, argc)
val endp = Operator.raycastEnd(origin, look)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -12,7 +12,7 @@ import net.minecraft.world.entity.Entity
object OpEntityVelocity : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val e: Entity = args.getChecked(0, argc)
ctx.assertEntityInRange(e)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
import at.petrak.hexcasting.xplat.IXplatAbstractions
@ -9,7 +9,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpRead : ConstManaOperator {
override val argc = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val (handStack, hand) = ctx.getHeldItemToOperateOn {
val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
dataHolder != null && (dataHolder.readIota(ctx.world) != null || dataHolder.emptyIota() != null)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.xplat.IXplatAbstractions
@ -9,7 +9,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpReadable : ConstManaOperator {
override val argc = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val (handStack) = ctx.getHeldItemToOperateOn {
IXplatAbstractions.INSTANCE.findDataHolder(it) != null
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem
@ -12,9 +12,9 @@ object OpTheCoolerRead : ConstManaOperator {
override val argc = 1
override fun execute(
args: List<LegacySpellDatum<*>>,
args: List<Iota>,
ctx: CastingContext
): List<LegacySpellDatum<*>> {
): List<Iota> {
val target = args.getChecked<ItemEntity>(0, argc)
ctx.assertEntityInRange(target)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -12,9 +12,9 @@ object OpTheCoolerReadable : ConstManaOperator {
override val argc = 1
override fun execute(
args: List<LegacySpellDatum<*>>,
args: List<Iota>,
ctx: CastingContext
): List<LegacySpellDatum<*>> {
): List<Iota> {
val target = args.getChecked<ItemEntity>(0, argc)
ctx.assertEntityInRange(target)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
@ -10,7 +10,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpWritable : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val datum = args[0]
val (handStack) = ctx.getHeldItemToOperateOn {

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellOperator
@ -13,7 +13,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpWrite : SpellOperator {
override val argc = 1
override fun execute(
args: List<LegacySpellDatum<*>>,
args: List<Iota>,
ctx: CastingContext
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val datum = args[0]
@ -41,7 +41,7 @@ object OpWrite : SpellOperator {
)
}
private data class Spell(val datum: LegacySpellDatum<*>) : RenderedSpell {
private data class Spell(val datum: Iota) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val (handStack) = ctx.getHeldItemToOperateOn {
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.akashic
import at.petrak.hexcasting.api.misc.ManaConstants
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -16,7 +16,7 @@ object OpAkashicRead : ConstManaOperator {
override val argc = 2
override val manaCost = ManaConstants.DUST_UNIT
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val pos = args.getChecked<Vec3>(0, argc)
val key = args.getChecked<HexPattern>(1, argc)

View file

@ -20,7 +20,7 @@ object OpAkashicWrite : SpellOperator {
override val causesBlindDiversion = false
override fun execute(
args: List<LegacySpellDatum<*>>,
args: List<Iota>,
ctx: CastingContext
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val pos = args.getChecked<Vec3>(0, argc)
@ -46,7 +46,7 @@ object OpAkashicWrite : SpellOperator {
)
}
private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: LegacySpellDatum<*>) :
private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: Iota) :
RenderedSpell {
override fun cast(ctx: CastingContext) {
record.addNewDatum(key, datum)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
class OpCircleBounds(val max: Boolean) : ConstManaOperator {
override val argc = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
if (ctx.spellCircle == null)
throw MishapNoSpellCircle()

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
@ -10,7 +10,7 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
object OpImpetusDir : ConstManaOperator {
override val argc = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
if (ctx.spellCircle == null)
throw MishapNoSpellCircle()

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
object OpImpetusPos : ConstManaOperator {
override val argc = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
if (ctx.spellCircle == null)
throw MishapNoSpellCircle()

View file

@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.ContinuationFrame
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpEval : Operator {
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult {
val instrs: SpellList = stack.getChecked(stack.lastIndex)
stack.removeLastOrNull()

View file

@ -2,12 +2,12 @@ package at.petrak.hexcasting.common.casting.operators.eval
import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpEvalDelay : Operator {
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult {
return OperationResult(continuation, stack, local, listOf())
}
}

View file

@ -9,8 +9,8 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
object OpForEach : Operator {
override fun operate(
continuation: SpellContinuation,
stack: MutableList<LegacySpellDatum<*>>,
local: LegacySpellDatum<*>,
stack: MutableList<Iota>,
local: Iota,
ctx: CastingContext
): OperationResult {
if (stack.size < 2)

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.eval
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.casting.CastingContext
@ -9,8 +9,8 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpHalt : Operator {
override fun operate(
continuation: SpellContinuation,
stack: MutableList<LegacySpellDatum<*>>,
local: LegacySpellDatum<*>,
stack: MutableList<Iota>,
local: Iota,
ctx: CastingContext
): OperationResult {
var newStack = stack.toList()

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpAppend : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc).toMutableList()
val datum = args[1]
list.add(datum)

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpConcat : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = args.getChecked<SpellList>(0, argc).toMutableList()
val rhs = args.getChecked<SpellList>(1, argc)
lhs.addAll(rhs)

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpCons : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val bottom = args.getChecked<SpellList>(0, argc)
val top = args[1]
return SpellList.LPair(top, bottom).asSpellResult

View file

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

View file

@ -6,7 +6,7 @@ import kotlin.math.roundToInt
object OpIndex : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc).toMutableList()
val index = args.getChecked<Double>(1, argc)
val x = list.getOrElse(index.roundToInt()) { LegacySpellDatum.make(Widget.NULL) }

View file

@ -7,7 +7,7 @@ object OpIndexOf : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc).toMutableList()
val value = args[1]
return list.indexOfFirst(value::tolerantEquals).asSpellResult

View file

@ -10,7 +10,7 @@ import kotlin.math.abs
import kotlin.math.roundToInt
object OpLastNToList : Operator {
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
override fun operate(continuation: SpellContinuation, stack: MutableList<Iota>, local: Iota, ctx: CastingContext): OperationResult {
if (stack.isEmpty())
throw MishapNotEnoughArgs(1, 0)
val arg = stack.takeLast(1).getChecked<Double>(0)
@ -23,7 +23,7 @@ object OpLastNToList : Operator {
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, stack.size)
)
}
val output = mutableListOf<LegacySpellDatum<*>>()
val output = mutableListOf<Iota>()
output.addAll(stack.takeLast(arg.toInt()))
val endSize = stack.size - output.toList().size
while (stack.size != endSize) {

View file

@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
// it's still called beancounter's distillation in my heart
object OpListSize : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return args.getChecked<SpellList>(0, argc).toList().size.asSpellResult // mmm one-liner
}
}

View file

@ -6,7 +6,7 @@ import kotlin.math.roundToInt
object OpModifyInPlace : ConstManaOperator {
override val argc = 3
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc)
val index = args.getChecked<Double>(1, argc).roundToInt()
val iota = args[2]

View file

@ -7,7 +7,7 @@ object OpRemove : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc).toMutableList()
val index = args.getChecked<Double>(1, argc).toInt()
if (index < 0 || index >= list.size)

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpReverski : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return args.getChecked<SpellList>(0, argc).toList().asReversed().asSpellResult // 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.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpSingleton : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return listOf(args[0]).asSpellResult // god i love one-liners
}
}

View file

@ -9,13 +9,13 @@ import kotlin.math.roundToInt
object OpSlice : ConstManaOperator {
override val argc = 3
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc).toList()
val index1 = Mth.clamp(args.getChecked<Double>(1, argc).roundToInt(), 0, list.size)
val index2 = Mth.clamp(args.getChecked<Double>(2, argc).roundToInt(), 0, list.size)
if (index1 == index2)
return emptyList<LegacySpellDatum<*>>().asSpellResult
return emptyList<Iota>().asSpellResult
return list.subList(min(index1, index2), max(index1, index2)).asSpellResult
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.getChecked
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.CastingContext
@ -10,6 +10,6 @@ object OpSplat : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> =
args.getChecked<SpellList>(0, argc).toMutableList()
}

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpUnCons : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getChecked<SpellList>(0, argc)
if (list.nonEmpty) {
return spellListOf(list.cdr, list.car)

View file

@ -2,15 +2,15 @@ package at.petrak.hexcasting.common.casting.operators.local
import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpPeekLocal : Operator {
override fun operate(
continuation: SpellContinuation,
stack: MutableList<LegacySpellDatum<*>>,
local: LegacySpellDatum<*>,
stack: MutableList<Iota>,
local: Iota,
ctx: CastingContext
): OperationResult {
stack.add(local)

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.local
import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
@ -10,8 +10,8 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpPushLocal : Operator {
override fun operate(
continuation: SpellContinuation,
stack: MutableList<LegacySpellDatum<*>>,
local: LegacySpellDatum<*>,
stack: MutableList<Iota>,
local: Iota,
ctx: CastingContext
): OperationResult {
if (stack.isEmpty())

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import kotlin.math.absoluteValue
@ -11,7 +11,7 @@ object OpAbsLen : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val x = numOrVec(args[0], 0)
return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asSpellResult

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.spellListOf
@ -10,7 +10,7 @@ object OpAdd : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = numOrVec(args[0], 1)
val rhs = numOrVec(args[1], 0)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpCeil : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
return ceil(value).asSpellResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -12,7 +12,7 @@ object OpCoerceToAxial : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val vec = args.getChecked<Vec3>(0, argc)
if (vec == Vec3.ZERO)
return vec.asSpellResult

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -9,7 +9,7 @@ import net.minecraft.world.phys.Vec3
object OpConstructVec : ConstManaOperator {
override val argc = 3
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val x = args.getChecked<Double>(0, argc)
val y = args.getChecked<Double>(1, argc)
val z = args.getChecked<Double>(2, argc)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
import at.petrak.hexcasting.api.spell.spellListOf
@ -9,7 +9,7 @@ import net.minecraft.world.phys.Vec3
object OpDeconstructVec : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val v = args.getChecked<Vec3>(0, argc)
return spellListOf(v.x, v.y, v.z)
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import at.petrak.hexcasting.api.spell.spellListOf
@ -12,7 +12,7 @@ object OpDivCross : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = numOrVec(args[0], 1)
val rhs = numOrVec(args[1], 0)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpFloor : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
return floor(value).asSpellResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -12,7 +12,7 @@ object OpLog : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
val base = args.getChecked<Double>(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.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpModulo : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val l = args.getChecked<Double>(0, argc)
val r = args.getChecked<Double>(1, argc)
if (r == 0.0)

View file

@ -3,14 +3,14 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.spellListOf
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpMulDot : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = numOrVec(args[0], 1)
val rhs = numOrVec(args[1], 0)

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import at.petrak.hexcasting.api.spell.spellListOf
@ -13,7 +13,7 @@ object OpPowProj : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = numOrVec(args[0], 1)
val rhs = numOrVec(args[1], 0)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
@ -9,7 +9,7 @@ object OpRandom : ConstManaOperator {
override val argc: Int
get() = 0
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return ctx.world.random.nextDouble().asSpellResult
}
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.spellListOf
import net.minecraft.world.phys.Vec3
@ -11,7 +11,7 @@ object OpSub : ConstManaOperator {
override val argc: Int
get() = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = numOrVec(args[0], 1)
val rhs = numOrVec(args[1], 0)

View file

@ -7,7 +7,7 @@ import kotlin.math.roundToInt
object OpAnd : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) {

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -10,7 +10,7 @@ import kotlin.math.roundToInt
object OpNot : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val num = args.getChecked<Double>(0, argc).roundToInt()
return num.inv().asSpellResult
}

View file

@ -7,7 +7,7 @@ import kotlin.math.roundToInt
object OpOr : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) {

View file

@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpToSet : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return args.getChecked<SpellList>(0, argc).toSet().toList().asSpellResult
}
}

View file

@ -7,7 +7,7 @@ import kotlin.math.roundToInt
object OpXor : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) {

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpBoolAnd : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return listOf(
if (args[0].payload == Widget.NULL)
LegacySpellDatum.make(Widget.NULL)

View file

@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpBoolIdentityKindOf : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val payload = args[0].payload
if (payload == Widget.NULL)

View file

@ -7,7 +7,7 @@ import net.minecraft.world.phys.Vec3
object OpBoolNot : ConstManaOperator {
override val argc = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val payload = args[0].payload
val falsy =
payload == Widget.NULL || payload.tolerantEquals(0.0) || payload.tolerantEquals(Vec3.ZERO) || (payload is SpellList && !payload.nonEmpty)

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpBoolOr : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return listOf(
if (args[0].payload == Widget.NULL)
args[1]

View file

@ -1,14 +1,14 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpBoolXor : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return listOf(
if (args[0].payload != Widget.NULL && args[1].payload == Widget.NULL)
args[0]

View file

@ -7,7 +7,7 @@ import java.util.function.BiPredicate
class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate<Double, Double>) : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = args.getChecked<Double>(0, argc)
val rhs = args.getChecked<Double>(1, argc)
if (lhs.tolerantEquals(rhs))

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.tolerantEquals
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.spell.tolerantEquals
class OpEquality(val invert: Boolean) : ConstManaOperator {
override val argc = 2
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): 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.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -13,7 +13,7 @@ object OpArcCos : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
if (value < -1 || value > 1)
throw MishapInvalidIota(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -13,7 +13,7 @@ object OpArcSin : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
if (value < -1 || value > 1)
throw MishapInvalidIota(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpArcTan : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val value = args.getChecked<Double>(0, argc)
return atan(value).asSpellResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpCos : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val angle = args.getChecked<Double>(0, argc)
return cos(angle).asSpellResult
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.LegacySpellDatum
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asSpellResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getChecked
@ -11,7 +11,7 @@ object OpSin : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val angle = args.getChecked<Double>(0, argc)
return sin(angle).asSpellResult
}

Some files were not shown because too many files have changed in this diff Show more