diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java index b16923df..ae323a8a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.Nullable; @@ -10,19 +10,19 @@ public interface DataHolder { CompoundTag readRawDatum(); @Nullable - default SpellDatum readDatum(ServerLevel world) { + default LegacySpellDatum readDatum(ServerLevel world) { var tag = readRawDatum(); if (tag != null) { - return SpellDatum.fromNBT(tag, world); + return LegacySpellDatum.fromNBT(tag, world); } else { return null; } } @Nullable - default SpellDatum emptyDatum() { + default LegacySpellDatum emptyDatum() { return null; } - boolean writeDatum(@Nullable SpellDatum datum, boolean simulate); + boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java index c90fc68f..a0a73bba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.Nullable; @@ -13,9 +13,9 @@ public interface HexHolder { boolean hasHex(); @Nullable - List> getHex(ServerLevel level); + List> getHex(ServerLevel level); - void writeHex(List> patterns, int mana); + void writeHex(List> patterns, int mana); void clearHex(); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java b/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java index 15528529..b5dcd503 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/block/circle/BlockEntityAbstractImpetus.java @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer; import at.petrak.hexcasting.api.misc.ManaConstants; import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.api.spell.ParticleSpray; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.casting.CastingContext; import at.petrak.hexcasting.api.spell.casting.CastingHarness; import at.petrak.hexcasting.api.spell.casting.SpellCircleContext; @@ -287,7 +287,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen if (bs.getBlock() instanceof BlockCircleComponent cc) { var newPattern = cc.getPattern(tracked, bs, this.level); if (newPattern != null) { - var info = harness.executeIota(SpellDatum.make(newPattern), splayer.getLevel()); + var info = harness.executeIota(LegacySpellDatum.make(newPattern), splayer.getLevel()); if (info.getMakesCastSound()) { makeSound = true; } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java index 6c11a534..880bca65 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.item; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.utils.NBTHelper; import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; @@ -21,29 +21,34 @@ public interface DataHolderItem { @Nullable CompoundTag readDatumTag(ItemStack stack); @Nullable - default SpellDatum readDatum(ItemStack stack, ServerLevel world) { - var tag = readDatumTag(stack); + default LegacySpellDatum readDatum(ItemStack stack, ServerLevel world) { + if (!(stack.getItem() instanceof DataHolderItem dh)) { + // this should be checked via mishap beforehand + throw new IllegalArgumentException("stack's item must be an ItemDataholder but was " + stack.getItem()); + } + + var tag = dh.readDatumTag(stack); if (tag != null) { - return SpellDatum.fromNBT(tag, world); + return LegacySpellDatum.fromNBT(tag, world); } else { return null; } } @Nullable - default SpellDatum emptyDatum(ItemStack stack) { + default LegacySpellDatum emptyDatum(ItemStack stack) { return null; } - boolean canWrite(ItemStack stack, @Nullable SpellDatum datum); + boolean canWrite(ItemStack stack, @Nullable LegacySpellDatum datum); - void writeDatum(ItemStack stack, @Nullable SpellDatum datum); + void writeDatum(ItemStack stack, @Nullable LegacySpellDatum datum); static void appendHoverText(DataHolderItem self, ItemStack pStack, List pTooltipComponents, - TooltipFlag pIsAdvanced) { + TooltipFlag pIsAdvanced) { var datumTag = self.readDatumTag(pStack); if (datumTag != null) { - var component = SpellDatum.displayFromNBT(datumTag); + var component = LegacySpellDatum.displayFromNBT(datumTag); pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component)); if (pIsAdvanced.isAdvanced()) { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java index f2f875d8..80ba9866 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.item; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; @@ -14,9 +14,9 @@ public interface HexHolderItem extends ManaHolderItem { boolean hasHex(ItemStack stack); @Nullable - List> getHex(ItemStack stack, ServerLevel level); + List> getHex(ItemStack stack, ServerLevel level); - void writeHex(ItemStack stack, List> patterns, int mana); + void writeHex(ItemStack stack, List> patterns, int mana); void clearHex(ItemStack stack); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstManaOperator.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstManaOperator.kt index 6790f846..c1425ec1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstManaOperator.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/ConstManaOperator.kt @@ -13,9 +13,9 @@ interface ConstManaOperator : Operator { val manaCost: Int get() = 0 - fun execute(args: List>, ctx: CastingContext): List> + fun execute(args: List>, ctx: CastingContext): List> - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { if (this.argc > stack.size) throw MishapNotEnoughArgs(this.argc, stack.size) val args = stack.takeLast(this.argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/DatumType.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/DatumType.java deleted file mode 100644 index 4228a4bd..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/DatumType.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.petrak.hexcasting.api.spell; - -import net.minecraft.util.StringRepresentable; - -public enum DatumType implements StringRepresentable { - EMPTY("empty"), - ENTITY("entity"), - WIDGET("widget"), - LIST("list"), - PATTERN("pattern"), - DOUBLE("double"), - VEC("vec"), - OTHER("other"); - - public final String serializedName; - - DatumType(String serializedName) { - this.serializedName = serializedName; - } - - @Override - public String getSerializedName() { - return this.serializedName; - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellDatum.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/LegacySpellDatum.kt similarity index 89% rename from Common/src/main/java/at/petrak/hexcasting/api/spell/SpellDatum.kt rename to Common/src/main/java/at/petrak/hexcasting/api/spell/LegacySpellDatum.kt index a2edd790..b753954e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellDatum.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/LegacySpellDatum.kt @@ -28,7 +28,7 @@ import java.util.* * * */ -class SpellDatum private constructor(val payload: T) { +class LegacySpellDatum private constructor(val payload: T) { val clazz: Class = payload.javaClass fun serializeToNBT(): CompoundTag = this.serializeToNBTWithDepthCheck(0, 0)?.first @@ -77,12 +77,12 @@ class SpellDatum private constructor(val payload: T) { override fun toString(): String = buildString { append("SpellDatum[") - append(this@SpellDatum.payload.toString()) + append(this@LegacySpellDatum.payload.toString()) append(']') } override fun equals(other: Any?): Boolean { - return other is SpellDatum<*> && other.payload == payload + return other is LegacySpellDatum<*> && other.payload == payload } override fun hashCode(): Int { @@ -111,18 +111,18 @@ class SpellDatum private constructor(val payload: T) { @JvmStatic @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - fun make(payload: Any): SpellDatum<*> = - if (payload is SpellDatum<*>) { + fun make(payload: Any): LegacySpellDatum<*> = + if (payload is LegacySpellDatum<*>) { payload } else if (payload is List<*>) { - SpellDatum(SpellList.LList(0, payload.map { + LegacySpellDatum(SpellList.LList(0, payload.map { when (it) { null -> make(Widget.NULL) else -> make(it) } })) } else if (payload is Vec3) { - SpellDatum( + LegacySpellDatum( Vec3( fixNAN(payload.x), fixNAN(payload.y), @@ -130,17 +130,17 @@ class SpellDatum private constructor(val payload: T) { ) ) } else if (isValidType(payload)) { - SpellDatum(payload) + LegacySpellDatum(payload) } else if (payload is java.lang.Double) { // Check to see if it's a java *boxed* double, for when we call this from Java val num = payload.toDouble() - SpellDatum(fixNAN(num)) + LegacySpellDatum(fixNAN(num)) } else { throw MishapInvalidSpellDatumType(payload) } @JvmStatic - fun fromNBT(nbt: CompoundTag, world: ServerLevel): SpellDatum<*> { + fun fromNBT(nbt: CompoundTag, world: ServerLevel): LegacySpellDatum<*> { val keys = nbt.allKeys if (keys.size != 1) return SpellDatum(Widget.GARBAGE) // Invalid iota format @@ -151,18 +151,18 @@ class SpellDatum private constructor(val payload: T) { val uuid = subtag.getUUID(TAG_ENTITY_UUID) // and throw away name val entity = world.getEntity(uuid) // If the entity died or something return Unit - SpellDatum(if (entity == null || !entity.isAlive) Widget.NULL else entity) + LegacySpellDatum(if (entity == null || !entity.isAlive) Widget.NULL else entity) } - TAG_DOUBLE -> SpellDatum(nbt.getDouble(key)) - TAG_VEC3 -> SpellDatum(vecFromNBT(nbt.getLongArray(key))) + TAG_DOUBLE -> LegacySpellDatum(nbt.getDouble(key)) + TAG_VEC3 -> LegacySpellDatum(vecFromNBT(nbt.getLongArray(key))) TAG_LIST -> { - SpellDatum(SpellList.fromNBT(nbt.getList(key, Tag.TAG_COMPOUND), world)) + LegacySpellDatum(SpellList.fromNBT(nbt.getList(key, Tag.TAG_COMPOUND), world)) } TAG_WIDGET -> { - SpellDatum(Widget.fromString(nbt.getString(key))) + LegacySpellDatum(Widget.fromString(nbt.getString(key))) } TAG_PATTERN -> { - SpellDatum(HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN))) + LegacySpellDatum(HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN))) } else -> SpellDatum(Widget.GARBAGE) // Invalid iota type } @@ -175,7 +175,7 @@ class SpellDatum private constructor(val payload: T) { ) ) @JvmStatic - fun fromNBT(nbt: CompoundTag, ctx: CastingContext): SpellDatum<*> = + fun fromNBT(nbt: CompoundTag, ctx: CastingContext): LegacySpellDatum<*> = fromNBT(nbt, ctx.world) @JvmStatic @@ -282,7 +282,5 @@ class SpellDatum private constructor(val payload: T) { DatumType.OTHER, DatumType.EMPTY -> "" } } - - } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperationResult.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperationResult.kt index 5bf47985..6454b5b6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperationResult.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperationResult.kt @@ -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>, val newLocalIota: SpellDatum<*>, val sideEffects: List) +data class OperationResult(val newContinuation: SpellContinuation, val newStack: List>, val newLocalIota: LegacySpellDatum<*>, val sideEffects: List) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/Operator.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/Operator.kt index a5b24adc..f2398d02 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/Operator.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/Operator.kt @@ -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>, local: SpellDatum<*>, ctx: CastingContext): OperationResult + fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, 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: SpellDatum<*>): Operator = object : ConstManaOperator { + fun makeConstantOp(x: LegacySpellDatum<*>): Operator = object : ConstManaOperator { override val argc: Int get() = 0 - override fun execute(args: List>, ctx: CastingContext): List> = + override fun execute(args: List>, ctx: CastingContext): List> = listOf(x) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt index 0dc23016..95e8f981 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt @@ -13,7 +13,7 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.phys.Vec3 import kotlin.math.abs -fun numOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either = +fun numOrVec(datum: LegacySpellDatum<*>, reverseIdx: Int): Either = when (datum.payload) { is Double -> Either.left(datum.payload) is Vec3 -> Either.right(datum.payload) @@ -24,7 +24,7 @@ fun numOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either = ) } -fun numOrList(datum: SpellDatum<*>, reverseIdx: Int): Either = +fun numOrList(datum: LegacySpellDatum<*>, reverseIdx: Int): Either = when (datum.payload) { is Double -> Either.left(datum.payload) is SpellList -> Either.right(datum.payload) @@ -35,15 +35,15 @@ fun numOrList(datum: SpellDatum<*>, reverseIdx: Int): Either ) } -fun spellListOf(vararg vs: Any): List> { - val out = ArrayList>(vs.size) +fun spellListOf(vararg vs: Any): List> { + val out = ArrayList>(vs.size) for (v in vs) { - out.add(SpellDatum.make(v)) + out.add(LegacySpellDatum.make(v)) } return out } -inline fun List>.getChecked(idx: Int, argc: Int = 0): T { +inline fun List>.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>.asSpellResult get() = spellListOf(this) +inline val List>.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 SpellDatum<*> && other is SpellDatum<*> -> this.payload.tolerantEquals(other.payload, recursionsLeft) - this is SpellDatum<*> -> this.payload.tolerantEquals(other, recursionsLeft) - other is SpellDatum<*> -> this.tolerantEquals(other.payload, recursionsLeft) + 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 HexPattern && other is HexPattern -> this.angles == other.angles this is Double && other is Double -> abs(this - other) < TOLERANCE diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt index d7399a06..784698a7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt @@ -1,35 +1,35 @@ package at.petrak.hexcasting.api.spell -import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.ListTag -import net.minecraft.server.level.ServerLevel +import at.petrak.hexcasting.api.spell.datum.SpellDatum /** * Restricted interface for functional lists. * * ...Surely this won't have any performance implications. */ -sealed class SpellList : Iterable> { +sealed class SpellList : Iterable { abstract val nonEmpty: Boolean - abstract val car: SpellDatum<*> + abstract val car: SpellDatum abstract val cdr: SpellList - class LPair(override val car: SpellDatum<*>, override val cdr: SpellList) : SpellList() { + class LPair(override val car: SpellDatum, override val cdr: SpellList) : SpellList() { override val nonEmpty = true } - class LList(val idx: Int, val list: List>) : SpellList() { + class LList(val idx: Int, val list: List) : SpellList() { override val nonEmpty: Boolean get() = idx < list.size - override val car: SpellDatum<*> + override val car: SpellDatum get() = list[idx] override val cdr: SpellList get() = LList(idx + 1, list) + + constructor(list: List) : this(0, list) } fun modifyAt(startIdx: Int, modify: (SpellList) -> SpellList): SpellList { - val stack = mutableListOf>() + val stack = mutableListOf() val ptr = iterator() var idx = startIdx if (idx < 0) { @@ -49,7 +49,7 @@ sealed class SpellList : Iterable> { return value } - fun getAt(startIdx: Int): SpellDatum<*> { + fun getAt(startIdx: Int): SpellDatum { var ptr = this var idx = startIdx if (idx < 0) { @@ -69,24 +69,12 @@ sealed class SpellList : Iterable> { override fun iterator() = SpellListIterator(this) - class SpellListIterator(var list: SpellList) : Iterator> { + class SpellListIterator(var list: SpellList) : Iterator { override fun hasNext() = list.nonEmpty - override operator fun next(): SpellDatum<*> { + override operator fun next(): SpellDatum { val car = list.car list = list.cdr return car } } - - companion object { - @JvmStatic - fun fromNBT(nbt: ListTag, world: ServerLevel): LList { - val out = ArrayList>(nbt.size) - for (subtag in nbt) { - // this is safe because otherwise we wouldn't have been able to get the list before - out.add(SpellDatum.fromNBT(subtag as CompoundTag, world)) - } - return LList(0, out) - } - } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellOperator.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellOperator.kt index b46a994b..ea94e702 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellOperator.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/SpellOperator.kt @@ -13,11 +13,11 @@ interface SpellOperator : Operator { fun awardsCastingStat(ctx: CastingContext): Boolean = true fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple>? - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { if (this.argc > stack.size) throw MishapNotEnoughArgs(this.argc, stack.size) val args = stack.takeLast(this.argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/Widget.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/Widget.kt index 50fba977..e2458244 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/Widget.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/Widget.kt @@ -16,7 +16,7 @@ enum class Widget : ConstManaOperator { override val argc: Int get() = 0 - override fun execute(args: List>, ctx: CastingContext): List> = + override fun execute(args: List>, ctx: CastingContext): List> = this.asSpellResult companion object { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt index 35e42293..395233b7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt @@ -9,6 +9,7 @@ import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.mod.HexItemTags import at.petrak.hexcasting.api.mod.HexStatistics import at.petrak.hexcasting.api.spell.* +import at.petrak.hexcasting.api.spell.datum.SpellDatum import at.petrak.hexcasting.api.spell.math.HexDir import at.petrak.hexcasting.api.spell.math.HexPattern import at.petrak.hexcasting.api.spell.mishaps.* @@ -27,10 +28,10 @@ import kotlin.math.min * It's stored as NBT on the wand. */ class CastingHarness private constructor( - var stack: MutableList>, - var localIota: SpellDatum<*>, + var stack: MutableList>, + var localIota: LegacySpellDatum<*>, var parenCount: Int, - var parenthesized: List>, + var parenthesized: List>, var escapeNext: Boolean, val ctx: CastingContext, val prepackagedColorizer: FrozenColorizer? // for trinkets with colorizers @@ -40,17 +41,17 @@ class CastingHarness private constructor( constructor( ctx: CastingContext, prepackagedColorizer: FrozenColorizer? = null - ) : this(mutableListOf(), SpellDatum.make(Widget.NULL), 0, mutableListOf(), false, ctx, prepackagedColorizer) + ) : this(mutableListOf(), LegacySpellDatum.make(Widget.NULL), 0, mutableListOf(), false, ctx, prepackagedColorizer) /** * Execute a single iota. */ - fun executeIota(iota: SpellDatum<*>, world: ServerLevel): ControllerInfo = executeIotas(listOf(iota), world) + fun executeIota(iota: LegacySpellDatum<*>, world: ServerLevel): ControllerInfo = executeIotas(listOf(iota), world) /** * Given a list of iotas, execute them in sequence. */ - fun executeIotas(iotas: List>, world: ServerLevel): ControllerInfo { + fun executeIotas(iotas: List>, world: ServerLevel): ControllerInfo { // Initialize the continuation stack to a single top-level eval for all iotas. var continuation = SpellContinuation.Done.pushFrame(ContinuationFrame.Evaluate(SpellList.LList(0, iotas))) // Begin aggregating info @@ -79,7 +80,7 @@ class CastingHarness private constructor( ) } - fun getUpdate(iota: SpellDatum<*>, world: ServerLevel, continuation: SpellContinuation): CastResult { + fun getUpdate(iota: LegacySpellDatum<*>, world: ServerLevel, continuation: SpellContinuation): CastResult { try { this.handleParentheses(iota)?.let { (data, resolutionType) -> return@getUpdate CastResult(continuation, data, resolutionType, listOf()) @@ -150,7 +151,7 @@ class CastingHarness private constructor( val unenlightened = pattern.isGreat && !ctx.isCasterEnlightened val sideEffects = mutableListOf() - var stack2: List>? = null + var stack2: List>? = null var cont2 = continuation if (!unenlightened || pattern.alwaysProcessGreatSpell) { @@ -237,7 +238,7 @@ class CastingHarness private constructor( } } - fun generateDescs() = stack.map(SpellDatum<*>::display) + fun generateDescs() = stack.map(SpellDatum::display) /** * Return the functional update represented by the current state (for use with `copy`) @@ -264,7 +265,7 @@ class CastingHarness private constructor( * Return a non-null value if we handled this in some sort of parenthesey way, * either escaping it onto the stack or changing the parenthese-handling state. */ - private fun handleParentheses(iota: SpellDatum<*>): Pair? { + private fun handleParentheses(iota: LegacySpellDatum<*>): Pair? { val operator = (iota.payload as? HexPattern)?.let { try { PatternRegistry.matchPattern(it, this.ctx.world) @@ -297,7 +298,7 @@ class CastingHarness private constructor( val newParenCount = this.parenCount - 1 if (newParenCount == 0) { val newStack = this.stack.toMutableList() - newStack.add(SpellDatum.make(this.parenthesized.toList())) + newStack.add(LegacySpellDatum.make(this.parenthesized.toList())) this.getFunctionalData().copy( stack = newStack, parenCount = newParenCount, @@ -457,26 +458,26 @@ class CastingHarness private constructor( @JvmStatic fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness { return try { - val stack = mutableListOf>() + val stack = mutableListOf>() val stackTag = nbt.getList(TAG_STACK, Tag.TAG_COMPOUND) for (subtag in stackTag) { - val datum = SpellDatum.fromNBT(subtag.asCompound, ctx.world) + val datum = LegacySpellDatum.fromNBT(subtag.asCompound, ctx.world) stack.add(datum) } val localTag = nbt.getCompound(TAG_LOCAL) val localIota = - if (localTag.size() == 1) SpellDatum.fromNBT(localTag, ctx.world) else SpellDatum.make( + if (localTag.size() == 1) LegacySpellDatum.fromNBT(localTag, ctx.world) else LegacySpellDatum.make( Widget.NULL ) - val parenthesized = mutableListOf>() + val parenthesized = mutableListOf>() val parenTag = nbt.getList(TAG_PARENTHESIZED, Tag.TAG_COMPOUND) for (subtag in parenTag) { if (subtag.asCompound.size() != 1) - parenthesized.add(SpellDatum.make(HexPattern.fromNBT(subtag.asCompound))) + parenthesized.add(LegacySpellDatum.make(HexPattern.fromNBT(subtag.asCompound))) else - parenthesized.add(SpellDatum.fromNBT(subtag.asCompound, ctx.world)) + parenthesized.add(LegacySpellDatum.fromNBT(subtag.asCompound, ctx.world)) } val parenCount = nbt.getInt(TAG_PAREN_COUNT) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ContinuationFrame.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ContinuationFrame.kt index 2eb1632a..d5115da9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ContinuationFrame.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/ContinuationFrame.kt @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.spell.casting -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult import at.petrak.hexcasting.api.utils.NBTBuilder @@ -36,7 +36,7 @@ sealed interface ContinuationFrame { * In other words, we should consume Evaluate frames until we hit a FinishEval or Thoth frame. * @return whether the break should stop here, alongside the new stack state (e.g. for finalizing a Thoth) */ - fun breakDownwards(stack: List>): Pair>> + fun breakDownwards(stack: List>): Pair>> /** * Serializes this frame. Used for things like delays, where we pause execution. @@ -49,7 +49,7 @@ sealed interface ContinuationFrame { */ data class Evaluate(val list: SpellList) : ContinuationFrame { // Discard this frame and keep discarding frames. - override fun breakDownwards(stack: List>) = false to stack + override fun breakDownwards(stack: List>) = false to stack // Step the list of patterns, evaluating a single one. override fun evaluate( @@ -83,7 +83,7 @@ sealed interface ContinuationFrame { */ object FinishEval : ContinuationFrame { // Don't do anything else to the stack, just finish the halt statement. - override fun breakDownwards(stack: List>) = true to stack + override fun breakDownwards(stack: List>) = true to stack // Evaluating it does nothing; it's only a boundary condition. override fun evaluate( @@ -116,15 +116,15 @@ sealed interface ContinuationFrame { data class ForEach( val data: SpellList, val code: SpellList, - val baseStack: List>?, - val acc: MutableList> + val baseStack: List>?, + val acc: MutableList> ) : ContinuationFrame { /** When halting, we add the stack state at halt to the stack accumulator, then return the original pre-Thoth stack, plus the accumulator. */ - override fun breakDownwards(stack: List>): Pair>> { + override fun breakDownwards(stack: List>): Pair>> { val newStack = baseStack?.toMutableList() ?: mutableListOf() acc.addAll(stack) - newStack.add(SpellDatum.make(acc)) + newStack.add(LegacySpellDatum.make(acc)) return true to newStack } @@ -154,7 +154,7 @@ sealed interface ContinuationFrame { .pushFrame(Evaluate(code)) } else { // Else, dump our final list onto the stack. - SpellDatum.make(acc) to continuation + LegacySpellDatum.make(acc) to continuation } val tStack = stack.toMutableList() tStack.add(stackTop) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/FunctionalData.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/FunctionalData.kt index 21d7a6e9..6be36e6b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/FunctionalData.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/FunctionalData.kt @@ -1,14 +1,14 @@ package at.petrak.hexcasting.api.spell.casting -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum /** * A change to the data in a CastHarness after a pattern is drawn. */ data class FunctionalData( - val stack: List>, + val stack: List>, val parenCount: Int, - val parenthesized: List>, + val parenthesized: List>, val escapeNext: Boolean, ) { /** diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumDouble.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumDouble.java new file mode 100644 index 00000000..98bcc1e4 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumDouble.java @@ -0,0 +1,49 @@ +package at.petrak.hexcasting.api.spell.datum; + +import net.minecraft.nbt.DoubleTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class DatumDouble extends SpellDatum { + public static final double TOLERANCE = 0.0001; + + public DatumDouble(double d) { + super(d); + } + + public double getDouble() { + return (Double) this.datum; + } + + @Override + public boolean equalsOther(SpellDatum that) { + return that instanceof DatumDouble dd && Math.abs(this.getDouble() - dd.getDouble()) < TOLERANCE; + } + + @Override + public @NotNull Tag serialize() { + return DoubleTag.valueOf(this.getDouble()); + } + + public static SpellDatum.Type TYPE = new Type<>() { + @Nullable + @Override + public DatumDouble deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException { + var dtag = (DoubleTag) tag; + return new DatumDouble(dtag.getAsDouble()); + } + + @Override + public Component display(Tag tag) { + return null; + } + + @Override + public int color() { + return 0; + } + }; +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumEntity.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumEntity.java new file mode 100644 index 00000000..0bc1ac91 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumEntity.java @@ -0,0 +1,50 @@ +package at.petrak.hexcasting.api.spell.datum; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class DatumEntity extends SpellDatum { + protected DatumEntity(@NotNull Entity e) { + super(e); + } + + public Entity getEntity() { + return (Entity) this.datum; + } + + @Override + public boolean equalsOther(SpellDatum that) { + return that instanceof DatumEntity dent && this.getEntity() == dent.getEntity(); + } + + @Override + public @NotNull Tag serialize() { + var out = new CompoundTag(); + out.putUUID("uuid", this.getEntity().getUUID()); + out.putString("name", Component.Serializer.toJson(this.getEntity().getDisplayName())); + return out; + } + + public static SpellDatum.Type TYPE = new Type<>() { + + @Nullable + @Override + public DatumEntity deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException { + return null; + } + + @Override + public Component display(Tag tag) { + return null; + } + + @Override + public int color() { + return 0; + } + }; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumList.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumList.java new file mode 100644 index 00000000..87ba5d09 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumList.java @@ -0,0 +1,53 @@ +package at.petrak.hexcasting.api.spell.datum; + +import at.petrak.hexcasting.api.spell.SpellList; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import org.jetbrains.annotations.NotNull; + +/** + * Similar to {@link DatumWidget}, this is a wrapper for {@link SpellList}. + */ +public class DatumList extends SpellDatum { + public DatumList(@NotNull SpellList list) { + super(list); + } + + public SpellList getList() { + return (SpellList) this.datum; + } + + @Override + public boolean equalsOther(SpellDatum that) { + var a = this.getList(); + if (!(that instanceof DatumList list)) { + return false; + } + var b = list.getList(); + + SpellList.SpellListIterator aIter = a.iterator(), bIter = b.iterator(); + for (; ; ) { + if (!aIter.hasNext() && !bIter.hasNext()) { + // we ran out together! + return true; + } + if (aIter.hasNext() != bIter.hasNext()) { + // one remains full before the other + return false; + } + SpellDatum x = aIter.next(), y = bIter.next(); + if (!SpellDatums.equalsWithTolerance(x, y)) { + return false; + } + } + } + + @Override + public @NotNull Tag serialize() { + var out = new ListTag(); + for (var subdatum : this.getList()) { + out.add(subdatum.serialize()); + } + return out; + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumPattern.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumPattern.java new file mode 100644 index 00000000..09a3a650 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumPattern.java @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.api.spell.datum; + +import at.petrak.hexcasting.api.spell.math.HexPattern; +import net.minecraft.nbt.Tag; +import org.jetbrains.annotations.NotNull; + +public class DatumPattern extends SpellDatum { + public DatumPattern(@NotNull HexPattern pattern) { + super(pattern); + } + + public HexPattern getPattern() { + return (HexPattern) this.datum; + } + + @Override + public @NotNull Tag serialize() { + return this.getPattern().serializeToNBT(); + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumVec3.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumVec3.java new file mode 100644 index 00000000..e3fb68f0 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumVec3.java @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.api.spell.datum; + +import net.minecraft.nbt.Tag; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +public class DatumVec3 extends SpellDatum { + public DatumVec3(@NotNull Vec3 datum) { + super(datum); + } + + public Vec3 getVec3() { + return (Vec3) this.datum; + } + + @Override + public @NotNull Tag serialize() { + return null; + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumWidget.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumWidget.java new file mode 100644 index 00000000..91c91b5e --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/DatumWidget.java @@ -0,0 +1,23 @@ +package at.petrak.hexcasting.api.spell.datum; + +import at.petrak.hexcasting.api.spell.Widget; +import net.minecraft.nbt.Tag; +import org.jetbrains.annotations.NotNull; + +/** + * Note this is different than the widget itself; this is a widget wrapper. + */ +public class DatumWidget extends SpellDatum { + public DatumWidget(@NotNull Widget widget) { + super(widget); + } + + public Widget getWidget() { + return (Widget) this.datum; + } + + @Override + public Tag serialize() { + return null; + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatum.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatum.java new file mode 100644 index 00000000..9d682bde --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatum.java @@ -0,0 +1,56 @@ +package at.petrak.hexcasting.api.spell.datum; + +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; + +public abstract class SpellDatum { + @NotNull + protected final Object datum; + + protected SpellDatum(@NotNull Object datum) { + this.datum = datum; + } + + public @NotNull Object getDatum() { + return datum; + } + + /** + * Compare this to another object, within a tolerance. + *

+ * Don't call this directly; use {@link SpellDatums#equalsWithTolerance}. + */ + abstract public boolean equalsOther(SpellDatum that); + + + abstract public @NotNull Tag serialize(); + + public interface Type { + /** + * Spell datums are stored as such: {@code { "type": "modid:type", "datum": a_tag }}. + *

+ * The {@code type} key is given when registering the spell datum type; this method + * deserializes the tag associated with {@code "datum"}. + *

+ * Returning {@code null} makes the resulting datum be {@link at.petrak.hexcasting.api.spell.Widget Widget.NULL}. + * Throwing an exception raises a mishap. + */ + @Nullable + T deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException; + + /** + * Get a display of this datum from the tag, without the world. + * This is for use on the client. + */ + Component display(Tag tag); + + /** + * Get the color associated with this datum type. + */ + int color(); + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatums.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatums.java new file mode 100644 index 00000000..f06f44a7 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/datum/SpellDatums.java @@ -0,0 +1,87 @@ +package at.petrak.hexcasting.api.spell.datum; + +import at.petrak.hexcasting.api.HexAPI; +import at.petrak.hexcasting.api.spell.SpellList; +import at.petrak.hexcasting.api.spell.Widget; +import at.petrak.hexcasting.api.spell.math.HexPattern; +import at.petrak.hexcasting.api.utils.HexUtils; +import net.minecraft.nbt.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class SpellDatums { + private static final Map> controllers = new ConcurrentHashMap<>(); + + public static final String + TAG_TYPE = HexAPI.MOD_ID + ":type", + TAG_DATA = HexAPI.MOD_ID + ":data"; + + public static SpellDatum deserializeFromRootTag(CompoundTag tag, + ServerLevel world) throws IllegalArgumentException { + if (tag.contains(TAG_TYPE, Tag.TAG_STRING) && tag.contains(TAG_DATA)) { + var typeKey = new ResourceLocation(tag.getString(TAG_TYPE)); + var overseer = controllers.get(typeKey); + if (overseer == null) { + throw new IllegalArgumentException("Unknown type " + typeKey + "(did you remember to register it?)"); + } + + var datumTag = tag.get(TAG_DATA); + return overseer.deserialize(datumTag, world); + } + + // For legacy reasons we need to check if it's the old serialization method + var legacyKeys = List.of( + "entity", "double", "vec3", "list", "widget", "pattern" + ); + for (var legacyKey : legacyKeys) { + if (tag.contains(legacyKey)) { + return legacyDeserialize(legacyKey, tag.get(legacyKey), world); + } + } + + throw new IllegalArgumentException("could not deserialize this tag: " + tag); + } + + public static boolean equalsWithTolerance(SpellDatum a, SpellDatum b) { + return a == b || a.equalsOther(b) || b.equalsOther(a); + } + + private static SpellDatum legacyDeserialize(String key, Tag inner, + ServerLevel world) throws IllegalArgumentException { + return switch (key) { + case "entity" -> { + var subtag = (CompoundTag) inner; + var uuid = subtag.getUUID("uuid"); // throw away the name + var entity = world.getEntity(uuid); + yield (entity == null) + ? new DatumWidget(Widget.NULL) + : new DatumEntity(entity); + } + case "double" -> new DatumDouble(((DoubleTag) inner).getAsDouble()); + case "vec3" -> new DatumVec3(HexUtils.vecFromNBT(((LongArrayTag) inner).getAsLongArray())); + case "list" -> { + var listTag = (ListTag) inner; + var out = new ArrayList(); + for (var subtag : listTag) { + var subdatum = deserializeFromRootTag((CompoundTag) subtag, world); + out.add(subdatum); + } + yield new DatumList(new SpellList.LList(out)); + } + case "widget" -> { + var str = (StringTag) inner; + yield new DatumWidget(Widget.valueOf(str.getAsString())); + } + case "pattern" -> { + var ctag = (CompoundTag) inner; + yield new DatumPattern(HexPattern.fromNBT(ctag)); + } + default -> throw new IllegalArgumentException("bruh this should literally be impossible"); + }; + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt index da61d73f..f4150750 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/Mishap.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) + abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt index 9e199151..0e5699f0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt @@ -2,8 +2,8 @@ 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.ParticleSpray -import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.world.entity.npc.Villager import net.minecraft.world.item.DyeColor @@ -12,8 +12,8 @@ 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>) { - trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) } override fun particleSpray(ctx: CastingContext) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt index 55788104..69662fc3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBlock.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt index f52d3b72..8972f768 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt index abc9b921..8db9820b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadItem.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt index 4453c829..641a8db6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadOffhandItem.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { yeetHeldItem(ctx, hand) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt index 81123a87..39c59275 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDisallowedSpell.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { // NO-OP } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt index 555abf01..bb1bfa3a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapDivideByZero.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.utils.asTranslatedComponent @@ -15,8 +15,8 @@ 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>) { - stack.add(SpellDatum.make(Widget.GARBAGE)) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + stack.add(LegacySpellDatum.make(Widget.GARBAGE)) trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2) } @@ -60,14 +60,14 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s @JvmStatic fun powerOf(datum: Any) = when (datum) { 0.0 -> zerothPower - else -> powerOf(SpellDatum.make(datum).display()) + else -> powerOf(LegacySpellDatum.make(datum).display()) } @JvmStatic fun translate(datum: Any): Component = when (datum) { 0.0 -> zero Vec3.ZERO -> zeroVector - else -> SpellDatum.make(datum).display() + else -> LegacySpellDatum.make(datum).display() } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt index 30c418c2..c42c1cdc 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt @@ -1,8 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext +import net.minecraft.network.chat.Component import net.minecraft.world.entity.Entity import net.minecraft.world.item.DyeColor @@ -10,10 +11,11 @@ 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + // Knock the player's items out of their hands yeetHeldItemsTowards(ctx, entity.position()) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("entity_too_far", SpellDatum.make(entity).display(), actionName(errorCtx.action)) + override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = + error("entity_too_far", LegacySpellDatum.make(entity).display(), actionName(errorCtx.action)) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt index a0e99b17..1771d64b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapError.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { // NO-OP } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt index 36203743..9c74a3a5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEvalTooDeep.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { ctx.caster.airSupply -= 290 } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt index a0d6a79b..b06cc288 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapImmuneEntity.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { yeetHeldItemsTowards(ctx, entity.position()) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt index 4296a0aa..0bc1fdac 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidIota.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.casting.CastingContext @@ -22,15 +22,15 @@ import net.minecraft.world.phys.Vec3 * [MishapInvalidIota.reverseIdx] is the index from the *back* of the stack. */ class MishapInvalidIota( - val perpetrator: SpellDatum<*>, + val perpetrator: LegacySpellDatum<*>, 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>) { - stack[stack.size - 1 - reverseIdx] = SpellDatum.make(Widget.GARBAGE) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + stack[stack.size - 1 - reverseIdx] = LegacySpellDatum.make(Widget.GARBAGE) } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = @@ -39,7 +39,7 @@ class MishapInvalidIota( companion object { @JvmStatic - fun ofClass(perpetrator: SpellDatum<*>, reverseIdx: Int, cls: Class<*>): MishapInvalidIota { + fun ofClass(perpetrator: LegacySpellDatum<*>, 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" diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt index 6ad4ca9e..8d3fc82d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidPattern.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType @@ -13,8 +13,8 @@ class MishapInvalidPattern : Mishap() { override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { - stack.add(SpellDatum.make(Widget.GARBAGE)) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + stack.add(LegacySpellDatum.make(Widget.GARBAGE)) } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt index e0c768f5..96f9efb5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapInvalidSpellDatumType.kt @@ -1,9 +1,8 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.Util import net.minecraft.world.item.DyeColor /** @@ -13,10 +12,8 @@ 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>) { - // Send it twice, just to make it clear - val msg = this.errorMessage(ctx, errorCtx) - ctx.caster.sendMessage(msg, Util.NIL_UUID) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + // NO-OP } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt index 321e1f3a..cbbf306b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationInWrongDimension.kt @@ -1,9 +1,10 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.casting.CastingContext +import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor @@ -11,11 +12,13 @@ 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>) { - stack.add(SpellDatum.make(Widget.GARBAGE)) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + stack.add(LegacySpellDatum.make(Widget.GARBAGE)) } - - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("wrong_dimension", actionName(errorCtx.action), properDimension.toString(), - ctx.world.dimension().location().toString()) + + override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = + error( + "wrong_dimension", actionName(errorCtx.action!!), properDimension.toString(), + ctx.world.dimension().location().toString() + ) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt index 8b1fa206..d0d08cc0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt @@ -1,8 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext +import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor import net.minecraft.world.phys.Vec3 @@ -10,10 +11,10 @@ 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { yeetHeldItemsTowards(ctx, location) } - override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("location_$type", SpellDatum.make(location).display(), actionName(errorCtx.action)) + override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = + error("location_$type", LegacySpellDatum.make(location).display(), actionName(errorCtx.action!!)) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt index fd49c74d..b44226db 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoAkashicRecord.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { ctx.caster.giveExperiencePoints(-100) } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt index b5f3e8b9..e6f06a31 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNoSpellCircle.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { ctx.caster.inventory.dropAll() } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt index 33ef2159..3b846bb2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapNotEnoughArgs.kt @@ -1,9 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps -import at.petrak.hexcasting.api.spell.SpellDatum -import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.misc.FrozenColorizer +import at.petrak.hexcasting.api.spell.LegacySpellDatum +import at.petrak.hexcasting.api.spell.Widget +import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor @@ -11,9 +11,9 @@ 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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { for (i in got until expected) - stack.add(SpellDatum.make(Widget.GARBAGE)) + stack.add(LegacySpellDatum.make(Widget.GARBAGE)) } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt index 7c93912f..440db1f9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt @@ -1,10 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.network.chat.Component import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.player.Player @@ -14,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>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60)) } @@ -23,14 +22,14 @@ class MishapOthersName(val other: Player) : Mishap() { companion object { @JvmStatic - fun getTrueNameFromDatum(datum: SpellDatum<*>, caster: Player): Player? { + fun getTrueNameFromDatum(datum: LegacySpellDatum<*>, 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> = - datum.payload.filterIsInstance>().toMutableList() + val poolToSearch: MutableList> = + datum.payload.filterIsInstance>().toMutableList() while (poolToSearch.isNotEmpty()) { val datumToCheck = poolToSearch[0] @@ -39,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>()) + poolToSearch.addAll(datumToCheck.payload.filterIsInstance>()) } return null } @JvmStatic - fun getTrueNameFromArgs(datums: List>, caster: Player): Player? { + fun getTrueNameFromArgs(datums: List>, caster: Player): Player? { return datums.firstNotNullOfOrNull { getTrueNameFromDatum(it, caster) } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt index e5048f25..3c2a3cca 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapTooManyCloseParens.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor @@ -10,8 +10,8 @@ class MishapTooManyCloseParens : Mishap() { override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.ORANGE) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { - stack.add(SpellDatum.make(errorCtx.pattern)) + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + stack.add(LegacySpellDatum.make(errorCtx.pattern)) } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt index 5ecfcaec..f9c79bd5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapUnescapedValue.kt @@ -1,10 +1,7 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer -import at.petrak.hexcasting.api.spell.DatumType -import at.petrak.hexcasting.api.spell.SpellDatum -import at.petrak.hexcasting.api.spell.SpellList -import at.petrak.hexcasting.api.spell.Widget +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.world.item.DyeColor @@ -12,12 +9,14 @@ import net.minecraft.world.item.DyeColor * The value was a naked iota without being Considered or Retrospected. */ class MishapUnescapedValue( - val perpetrator: SpellDatum<*> + val perpetrator: LegacySpellDatum<*> ) : Mishap() { override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.GRAY) - override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList>) { + // TODO + /* val idx = stack.indexOfLast { it.getType() == DatumType.LIST } if (idx != -1) { val list = stack[idx].payload as SpellList @@ -28,6 +27,7 @@ class MishapUnescapedValue( }) } } + */ } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt b/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt index 1db696f6..ca01cd90 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/utils/HexUtils.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.utils -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.math.HexCoord import net.minecraft.ChatFormatting @@ -88,7 +88,7 @@ fun pxToCoord(px: Vec2, size: Float, offset: Vec2): HexCoord { else HexCoord(q, r + (rf + 0.5 * qf).roundToInt()) } - +s fun String.withStyle(op: (Style) -> Style): MutableComponent = asTextComponent.withStyle(op) fun String.withStyle(style: Style): MutableComponent = asTextComponent.withStyle(style) fun String.withStyle(formatting: ChatFormatting): MutableComponent = asTextComponent.withStyle(formatting) @@ -234,12 +234,12 @@ inline operator fun WeakValue.setValue(thisRef: Any?, property: KProperty /** * Returns an empty list if it's too complicated. */ -fun Iterable>.serializeToNBT(): ListTag { - val out = SpellDatum.make(SpellList.LList(0, this.toList())).serializeToNBT() - return if (out.contains(SpellDatum.TAG_WIDGET)) +fun Iterable>.serializeToNBT(): ListTag { + val out = LegacySpellDatum.make(SpellList.LList(0, this.toList())).serializeToNBT() + return if (out.contains(LegacySpellDatum.TAG_WIDGET)) ListTag() else - out.getList(SpellDatum.TAG_LIST, Tag.TAG_COMPOUND) + out.getList(LegacySpellDatum.TAG_LIST, Tag.TAG_COMPOUND) } // Copy the impl from forge diff --git a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java index 0faac5ba..4341a357 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java @@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry; import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.item.ManaHolderItem; import at.petrak.hexcasting.api.misc.ManaConstants; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer; @@ -266,17 +266,17 @@ public class RegisterClientStuff { } return typename == null ? 0f : switch (typename) { - case SpellDatum.TAG_ENTITY -> 1f; - case SpellDatum.TAG_DOUBLE -> 2f; - case SpellDatum.TAG_VEC3 -> 3f; - case SpellDatum.TAG_WIDGET -> 4f; - case SpellDatum.TAG_LIST -> 5f; - case SpellDatum.TAG_PATTERN -> 6f; + case LegacySpellDatum.TAG_ENTITY -> 1f; + case LegacySpellDatum.TAG_DOUBLE -> 2f; + case LegacySpellDatum.TAG_VEC3 -> 3f; + case LegacySpellDatum.TAG_WIDGET -> 4f; + case LegacySpellDatum.TAG_LIST -> 5f; + case LegacySpellDatum.TAG_PATTERN -> 6f; default -> 0f; // uh oh }; }); IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.SEALED_PRED, - (stack, level, holder, holderID) -> item.canWrite(stack, SpellDatum.make(Widget.NULL)) ? 0f : 1f); + (stack, level, holder, holderID) -> item.canWrite(stack, LegacySpellDatum.make(Widget.NULL)) ? 0f : 1f); } private static void registerPackagedSpellOverrides(ItemPackagedHex item) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java index 4531383e..d4605c1f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic; import at.petrak.hexcasting.annotations.SoftImplement; import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.common.items.ItemScroll; import at.petrak.hexcasting.common.lib.HexBlocks; import at.petrak.hexcasting.common.lib.HexSounds; @@ -59,7 +59,7 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En var stack = pPlayer.getItemInHand(pHand); if (stack.getItem() instanceof ItemScroll scroll) { if (!pLevel.isClientSide()) { - scroll.writeDatum(stack, SpellDatum.make(shelf.getPattern())); + scroll.writeDatum(stack, LegacySpellDatum.make(shelf.getPattern())); } pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE, SoundSource.BLOCKS, 1f, 1f); return InteractionResult.sidedSuccess(pLevel.isClientSide); diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java index b770b82e..40655a3d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicRecord.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic; import at.petrak.hexcasting.api.block.HexBlockEntity; import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexDir; import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.common.lib.HexBlockEntities; @@ -45,7 +45,7 @@ public class BlockEntityAkashicRecord extends HexBlockEntity { * Will never clobber anything. */ public @Nullable - BlockPos addNewDatum(HexPattern key, SpellDatum datum) { + BlockPos addNewDatum(HexPattern key, LegacySpellDatum datum) { String entryKey = getKey(key); if (this.entries.containsKey(entryKey)) { return null; // would clobber @@ -76,19 +76,19 @@ public class BlockEntityAkashicRecord extends HexBlockEntity { } public @Nullable - SpellDatum lookupPattern(HexPattern key, ServerLevel slevel) { + LegacySpellDatum lookupPattern(HexPattern key, ServerLevel slevel) { var entry = this.entries.get(getKey(key)); if (entry == null) { return null; } else { - return SpellDatum.fromNBT(entry.datum, slevel); + return LegacySpellDatum.fromNBT(entry.datum, slevel); } } public Component getDisplayAt(HexPattern key) { var entry = this.entries.get(getKey(key)); if (entry != null) { - return SpellDatum.displayFromNBT(entry.datum); + return LegacySpellDatum.displayFromNBT(entry.datum); } else { return new TranslatableComponent("hexcasting.spelldata.akashic.nopos").withStyle(ChatFormatting.RED); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockSlate.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockSlate.java index 574c23f8..62751258 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockSlate.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockSlate.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.circles; import at.petrak.hexcasting.annotations.SoftImplement; import at.petrak.hexcasting.api.block.circle.BlockCircleComponent; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.common.lib.HexItems; import net.minecraft.core.BlockPos; @@ -102,7 +102,7 @@ public class BlockSlate extends BlockCircleComponent implements EntityBlock, Sim if (be instanceof BlockEntitySlate slate) { ItemStack stack = new ItemStack(HexItems.SLATE); if (slate.pattern != null) { - HexItems.SLATE.writeDatum(stack, SpellDatum.make(slate.pattern)); + HexItems.SLATE.writeDatum(stack, LegacySpellDatum.make(slate.pattern)); } return stack; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java b/Common/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java index 23d08e1c..45bc277b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting; import at.petrak.hexcasting.api.PatternRegistry; import at.petrak.hexcasting.api.misc.ManaConstants; import at.petrak.hexcasting.api.spell.Operator; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.spell.math.HexAngle; import at.petrak.hexcasting.api.spell.math.HexDir; @@ -352,29 +352,29 @@ public class RegisterPatterns { PatternRegistry.mapPattern(HexPattern.fromAngles("d", HexDir.EAST), modLoc("const/null"), Widget.NULL); PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqea", HexDir.NORTH_WEST), modLoc("const/vec/px"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(1.0, 0.0, 0.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(1.0, 0.0, 0.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqew", HexDir.NORTH_WEST), modLoc("const/vec/py"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 1.0, 0.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(0.0, 1.0, 0.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqed", HexDir.NORTH_WEST), modLoc("const/vec/pz"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, 1.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(0.0, 0.0, 1.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeeqa", HexDir.SOUTH_WEST), modLoc("const/vec/nx"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(-1.0, 0.0, 0.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(-1.0, 0.0, 0.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeeqw", HexDir.SOUTH_WEST), modLoc("const/vec/ny"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, -1.0, 0.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(0.0, -1.0, 0.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeeqd", HexDir.SOUTH_WEST), modLoc("const/vec/nz"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, -1.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(0.0, 0.0, -1.0)))); // Yep, this is what I spend the "plain hexagon" pattern on. PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqq", HexDir.NORTH_WEST), modLoc("const/vec/0"), - Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, 0.0)))); + Operator.makeConstantOp(LegacySpellDatum.make(new Vec3(0.0, 0.0, 0.0)))); PatternRegistry.mapPattern(HexPattern.fromAngles("qdwdq", HexDir.NORTH_EAST), modLoc("const/double/pi"), - Operator.makeConstantOp(SpellDatum.make(Math.PI))); + Operator.makeConstantOp(LegacySpellDatum.make(Math.PI))); PatternRegistry.mapPattern(HexPattern.fromAngles("eawae", HexDir.NORTH_WEST), modLoc("const/double/tau"), - Operator.makeConstantOp(SpellDatum.make(HexUtils.TAU))); + Operator.makeConstantOp(LegacySpellDatum.make(HexUtils.TAU))); // e PatternRegistry.mapPattern(HexPattern.fromAngles("aaq", HexDir.EAST), modLoc("const/double/e"), - Operator.makeConstantOp(SpellDatum.make(Math.E))); + Operator.makeConstantOp(LegacySpellDatum.make(Math.E))); // == Entities == @@ -490,7 +490,7 @@ public class RegisterPatterns { if (negate) { accumulator = -accumulator; } - return Operator.makeConstantOp(SpellDatum.make(accumulator)); + return Operator.makeConstantOp(LegacySpellDatum.make(accumulator)); } else { return null; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockAxisRaycast.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockAxisRaycast.kt index 2ee55971..8bdd53f7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockAxisRaycast.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockAxisRaycast.kt @@ -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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val origin: Vec3 = args.getChecked(0, argc) val look: Vec3 = args.getChecked(1, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockRaycast.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockRaycast.kt index e747c514..027222c8 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockRaycast.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpBlockRaycast.kt @@ -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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val origin: Vec3 = args.getChecked(0, argc) val look: Vec3 = args.getChecked(1, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityHeight.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityHeight.kt index c45e245d..a8c5f743 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityHeight.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityHeight.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val e: Entity = args.getChecked(0, argc) ctx.assertEntityInRange(e) return e.bbHeight.asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityLook.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityLook.kt index 4caaa563..aadee9ae 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityLook.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityLook.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val e: Entity = args.getChecked(0, argc) ctx.assertEntityInRange(e) return e.lookAngle.asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityPos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityPos.kt index c7ce6918..1c1c52bf 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityPos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityPos.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { 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 diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityRaycast.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityRaycast.kt index 8dfff6c6..45c01950 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityRaycast.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityRaycast.kt @@ -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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val origin: Vec3 = args.getChecked(0, argc) val look: Vec3 = args.getChecked(1, argc) val endp = Operator.raycastEnd(origin, look) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityVelocity.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityVelocity.kt index c595edd4..bb0f1b47 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityVelocity.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpEntityVelocity.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val e: Entity = args.getChecked(0, argc) ctx.assertEntityInRange(e) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt index 8ef48601..ea550d43 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val (handStack, hand) = ctx.getHeldItemToOperateOn { val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) dataHolder != null && (dataHolder.readDatum(ctx.world) != null || dataHolder.emptyDatum() != null) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt index 222b2e62..edfa2f1e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val (handStack) = ctx.getHeldItemToOperateOn { IXplatAbstractions.INSTANCE.findDataHolder(it) != null } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt index a4be799a..99f3021a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.getChecked -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -12,9 +12,9 @@ object OpTheCoolerRead : ConstManaOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext - ): List> { + ): List> { val target = args.getChecked(0, argc) ctx.assertEntityInRange(target) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt index 39252905..88d95db7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, + args: List>, ctx: CastingContext - ): List> { + ): List> { val target = args.getChecked(0, argc) ctx.assertEntityInRange(target) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt index f9067062..7db4f1bd 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val datum = args[0] val (handStack) = ctx.getHeldItemToOperateOn { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt index c91c318c..ab1fddd1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem @@ -13,7 +13,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions object OpWrite : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val datum = args[0] @@ -41,7 +41,7 @@ object OpWrite : SpellOperator { ) } - private data class Spell(val datum: SpellDatum<*>) : RenderedSpell { + private data class Spell(val datum: LegacySpellDatum<*>) : RenderedSpell { override fun cast(ctx: CastingContext) { val (handStack) = ctx.getHeldItemToOperateOn { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicRead.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicRead.kt index 8ccc2bab..4f8cd59f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicRead.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicRead.kt @@ -2,10 +2,10 @@ 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.getChecked -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.math.HexPattern import at.petrak.hexcasting.api.spell.mishaps.MishapNoAkashicRecord import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord @@ -16,7 +16,7 @@ object OpAkashicRead : ConstManaOperator { override val argc = 2 override val manaCost = ManaConstants.DUST_UNIT - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val pos = args.getChecked(0, argc) val key = args.getChecked(1, argc) @@ -27,6 +27,6 @@ object OpAkashicRead : ConstManaOperator { } val datum = tile.lookupPattern(key, ctx.world) - return listOf(datum ?: SpellDatum.make(Widget.NULL)) + return listOf(datum ?: LegacySpellDatum.make(Widget.NULL)) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt index 76b63899..2d0fdcba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/akashic/OpAkashicWrite.kt @@ -20,7 +20,7 @@ object OpAkashicWrite : SpellOperator { override val causesBlindDiversion = false override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val pos = args.getChecked(0, argc) @@ -46,7 +46,7 @@ object OpAkashicWrite : SpellOperator { ) } - private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: SpellDatum<*>) : + private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: LegacySpellDatum<*>) : RenderedSpell { override fun cast(ctx: CastingContext) { record.addNewDatum(key, datum) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpCircleBounds.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpCircleBounds.kt index fc267fec..9fe358ca 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpCircleBounds.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpCircleBounds.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { if (ctx.spellCircle == null) throw MishapNoSpellCircle() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusDir.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusDir.kt index 477a6061..22915b74 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusDir.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusDir.kt @@ -2,15 +2,15 @@ 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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.asSpellResult import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle object OpImpetusDir : ConstManaOperator { override val argc = 0 - - override fun execute(args: List>, ctx: CastingContext): List> { + + override fun execute(args: List>, ctx: CastingContext): List> { if (ctx.spellCircle == null) throw MishapNoSpellCircle() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusPos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusPos.kt index 3865168f..243d6878 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusPos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/circles/OpImpetusPos.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { if (ctx.spellCircle == null) throw MishapNoSpellCircle() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt index c63af6a5..64dfc5c1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt @@ -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>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { val instrs: SpellList = stack.getChecked(stack.lastIndex) stack.removeLastOrNull() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEvalDelay.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEvalDelay.kt index ec0082b5..20f4bfe4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEvalDelay.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEvalDelay.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { return OperationResult(continuation, stack, local, listOf()) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt index a528dff9..76d3e193 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt @@ -1,19 +1,18 @@ 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.getChecked -import at.petrak.hexcasting.api.spell.SpellDatum -import at.petrak.hexcasting.api.spell.SpellList +import at.petrak.hexcasting.api.spell.* import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.casting.CastingHarness import at.petrak.hexcasting.api.spell.casting.ContinuationFrame -import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect -import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.api.spell.casting.SpellContinuation +import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs object OpForEach : Operator { - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate( + continuation: SpellContinuation, + stack: MutableList>, + local: LegacySpellDatum<*>, + ctx: CastingContext + ): OperationResult { if (stack.size < 2) throw MishapNotEnoughArgs(2, stack.size) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpHalt.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpHalt.kt index 19aa7c04..c73082af 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpHalt.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpHalt.kt @@ -1,16 +1,16 @@ package at.petrak.hexcasting.common.casting.operators.eval +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator -import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.SpellContinuation object OpHalt : Operator { override fun operate( continuation: SpellContinuation, - stack: MutableList>, - local: SpellDatum<*>, + stack: MutableList>, + local: LegacySpellDatum<*>, ctx: CastingContext ): OperationResult { var newStack = stack.toList() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpAppend.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpAppend.kt index cf94cf6b..2af98124 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpAppend.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpAppend.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpAppend : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc).toMutableList() val datum = args[1] list.add(datum) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpConcat.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpConcat.kt index 64ab7845..2d32126b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpConcat.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpConcat.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpConcat : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = args.getChecked(0, argc).toMutableList() val rhs = args.getChecked(1, argc) lhs.addAll(rhs) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpCons.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpCons.kt index a2f8552a..c3bc6eac 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpCons.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpCons.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpCons : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val bottom = args.getChecked(0, argc) val top = args[1] return SpellList.LPair(top, bottom).asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpEmptyList.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpEmptyList.kt index e2e597d4..abcb213a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpEmptyList.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpEmptyList.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { - return emptyList>().asSpellResult // sorry for taking all the easy impls, hudeler + override fun execute(args: List>, ctx: CastingContext): List> { + return emptyList>().asSpellResult // sorry for taking all the easy impls, hudeler } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndex.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndex.kt index 32e590a2..e067b800 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndex.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndex.kt @@ -1,19 +1,15 @@ 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.SpellDatum -import at.petrak.hexcasting.api.spell.SpellList +import at.petrak.hexcasting.api.spell.* import at.petrak.hexcasting.api.spell.casting.CastingContext -import at.petrak.hexcasting.api.spell.Widget import kotlin.math.roundToInt object OpIndex : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc).toMutableList() val index = args.getChecked(1, argc) - val x = list.getOrElse(index.roundToInt()) { SpellDatum.make(Widget.NULL) } + val x = list.getOrElse(index.roundToInt()) { LegacySpellDatum.make(Widget.NULL) } return listOf(x) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndexOf.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndexOf.kt index ecb12448..c62c1832 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndexOf.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpIndexOf.kt @@ -7,7 +7,7 @@ object OpIndexOf : ConstManaOperator { override val argc: Int get() = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc).toMutableList() val value = args[1] return list.indexOfFirst(value::tolerantEquals).asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt index bfc8f6fe..895f8dd2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt @@ -10,7 +10,7 @@ import kotlin.math.abs import kotlin.math.roundToInt object OpLastNToList : Operator { - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { if (stack.isEmpty()) throw MishapNotEnoughArgs(1, 0) val arg = stack.takeLast(1).getChecked(0) @@ -23,7 +23,7 @@ object OpLastNToList : Operator { "hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, stack.size) ) } - val output = mutableListOf>() + val output = mutableListOf>() output.addAll(stack.takeLast(arg.toInt())) val endSize = stack.size - output.toList().size while (stack.size != endSize) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpListSize.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpListSize.kt index 91f6f7c2..6c37fb51 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpListSize.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpListSize.kt @@ -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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return args.getChecked(0, argc).toList().size.asSpellResult // mmm one-liner } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpModifyInPlace.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpModifyInPlace.kt index 77f7aa54..a95b10a3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpModifyInPlace.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpModifyInPlace.kt @@ -6,7 +6,7 @@ import kotlin.math.roundToInt object OpModifyInPlace : ConstManaOperator { override val argc = 3 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc) val index = args.getChecked(1, argc).roundToInt() val iota = args[2] diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpRemove.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpRemove.kt index d91d66d1..d2605f1b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpRemove.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpRemove.kt @@ -7,7 +7,7 @@ object OpRemove : ConstManaOperator { override val argc: Int get() = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc).toMutableList() val index = args.getChecked(1, argc).toInt() if (index < 0 || index >= list.size) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpReverski.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpReverski.kt index 2ac282a3..cf3de86d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpReverski.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpReverski.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpReverski : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return args.getChecked(0, argc).toList().asReversed().asSpellResult // okay kotlin kinda pogged for this } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSingleton.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSingleton.kt index 50407845..6d2404c4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSingleton.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSingleton.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return listOf(args[0]).asSpellResult // god i love one-liners } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSlice.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSlice.kt index 826df2b7..1458ad1f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSlice.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSlice.kt @@ -9,13 +9,13 @@ import kotlin.math.roundToInt object OpSlice : ConstManaOperator { override val argc = 3 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc).toList() val index1 = Mth.clamp(args.getChecked(1, argc).roundToInt(), 0, list.size) val index2 = Mth.clamp(args.getChecked(2, argc).roundToInt(), 0, list.size) if (index1 == index2) - return emptyList>().asSpellResult + return emptyList>().asSpellResult return list.subList(min(index1, index2), max(index1, index2)).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSplat.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSplat.kt index c27efcd8..8908c2b2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSplat.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpSplat.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> = + override fun execute(args: List>, ctx: CastingContext): List> = args.getChecked(0, argc).toMutableList() } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpUnCons.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpUnCons.kt index 5903b394..0fa5eaad 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpUnCons.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpUnCons.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpUnCons : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val list = args.getChecked(0, argc) if (list.nonEmpty) { return spellListOf(list.cdr, list.car) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPeekLocal.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPeekLocal.kt index 1271b513..448ad6e1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPeekLocal.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPeekLocal.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, - local: SpellDatum<*>, + stack: MutableList>, + local: LegacySpellDatum<*>, ctx: CastingContext ): OperationResult { stack.add(local) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt index 7fb1facd..da7efbbb 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/local/OpPushLocal.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, - local: SpellDatum<*>, + stack: MutableList>, + local: LegacySpellDatum<*>, ctx: CastingContext ): OperationResult { if (stack.isEmpty()) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAbsLen.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAbsLen.kt index 4689d523..1a12bbb5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAbsLen.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAbsLen.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val x = numOrVec(args[0], 0) return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAdd.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAdd.kt index 5e198419..39d16205 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAdd.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpAdd.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = numOrVec(args[0], 1) val rhs = numOrVec(args[1], 0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCeil.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCeil.kt index 186607a8..009c49a2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCeil.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCeil.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) return ceil(value).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCoerceToAxial.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCoerceToAxial.kt index eb565ba7..c310e239 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCoerceToAxial.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpCoerceToAxial.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val vec = args.getChecked(0, argc) if (vec == Vec3.ZERO) return vec.asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpConstructVec.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpConstructVec.kt index 40fe7a45..a7bf403d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpConstructVec.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpConstructVec.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val x = args.getChecked(0, argc) val y = args.getChecked(1, argc) val z = args.getChecked(2, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDeconstructVec.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDeconstructVec.kt index d9706892..d69c2c3a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDeconstructVec.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDeconstructVec.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val v = args.getChecked(0, argc) return spellListOf(v.x, v.y, v.z) } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDivCross.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDivCross.kt index 3d9a8339..2f11848e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDivCross.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpDivCross.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = numOrVec(args[0], 1) val rhs = numOrVec(args[1], 0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpFloor.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpFloor.kt index a0090f5e..8472fbb7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpFloor.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpFloor.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) return floor(value).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpLog.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpLog.kt index 26d6aefa..7a036d78 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpLog.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpLog.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) val base = args.getChecked(1, argc) if (value <= 0.0 || base <= 0.0 || base == 1.0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpModulo.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpModulo.kt index 4b879d7f..e5c1dd4a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpModulo.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpModulo.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val l = args.getChecked(0, argc) val r = args.getChecked(1, argc) if (r == 0.0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpMulDot.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpMulDot.kt index 51190788..c952fc94 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpMulDot.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpMulDot.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext object OpMulDot : ConstManaOperator { override val argc: Int get() = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = numOrVec(args[0], 1) val rhs = numOrVec(args[1], 0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpPowProj.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpPowProj.kt index 3dce748e..4f916498 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpPowProj.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpPowProj.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = numOrVec(args[0], 1) val rhs = numOrVec(args[1], 0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt index 2ae8b09f..3c88e05c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return ctx.world.random.nextDouble().asSpellResult } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpSub.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpSub.kt index 01bd708a..64bd528c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpSub.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpSub.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = numOrVec(args[0], 1) val rhs = numOrVec(args[1], 0) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpAnd.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpAnd.kt index 28eca0e4..c9b00f7f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpAnd.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpAnd.kt @@ -7,7 +7,7 @@ import kotlin.math.roundToInt object OpAnd : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val firstParam = numOrList(args[0], 0) if (firstParam.right().isPresent) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpNot.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpNot.kt index 5566822d..6917b4d5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpNot.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpNot.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val num = args.getChecked(0, argc).roundToInt() return num.inv().asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpOr.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpOr.kt index 8183b65f..7640339f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpOr.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpOr.kt @@ -7,7 +7,7 @@ import kotlin.math.roundToInt object OpOr : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val firstParam = numOrList(args[0], 0) if (firstParam.right().isPresent) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpToSet.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpToSet.kt index f92e4e6a..f3ab4a15 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpToSet.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpToSet.kt @@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpToSet : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return args.getChecked(0, argc).toSet().toList().asSpellResult } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpXor.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpXor.kt index 1bca8ecb..01f388d6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpXor.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/bit/OpXor.kt @@ -7,7 +7,7 @@ import kotlin.math.roundToInt object OpXor : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val firstParam = numOrList(args[0], 0) if (firstParam.right().isPresent) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolAnd.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolAnd.kt index a1ed4220..22946066 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolAnd.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolAnd.kt @@ -1,17 +1,17 @@ package at.petrak.hexcasting.common.casting.operators.math.logic import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return listOf( if (args[0].payload == Widget.NULL) - SpellDatum.make(Widget.NULL) + LegacySpellDatum.make(Widget.NULL) else args[1] ) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolIdentityKindOf.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolIdentityKindOf.kt index 612bf5ac..cb140cfa 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolIdentityKindOf.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolIdentityKindOf.kt @@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext object OpBoolIdentityKindOf : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val payload = args[0].payload if (payload == Widget.NULL) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolNot.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolNot.kt index 1927f5c8..7c4f93c6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolNot.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolNot.kt @@ -7,9 +7,10 @@ import net.minecraft.world.phys.Vec3 object OpBoolNot : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val payload = args[0].payload - val falsy = payload == Widget.NULL || payload.tolerantEquals(0.0) || payload.tolerantEquals(Vec3.ZERO) || (payload is SpellList && !payload.nonEmpty) + val falsy = + payload == Widget.NULL || payload.tolerantEquals(0.0) || payload.tolerantEquals(Vec3.ZERO) || (payload is SpellList && !payload.nonEmpty) return falsy.asSpellResult } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolOr.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolOr.kt index 87aa9c34..7e420455 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolOr.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolOr.kt @@ -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.SpellDatum -import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return listOf( if (args[0].payload == Widget.NULL) args[1] diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolXor.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolXor.kt index 757dede1..cae0a83b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolXor.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpBoolXor.kt @@ -1,21 +1,21 @@ package at.petrak.hexcasting.common.casting.operators.math.logic import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum -import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { return listOf( if (args[0].payload != Widget.NULL && args[1].payload == Widget.NULL) args[0] else if (args[0].payload == Widget.NULL && args[1].payload != Widget.NULL) args[1] else - SpellDatum.make(Widget.NULL) + LegacySpellDatum.make(Widget.NULL) ) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpCompare.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpCompare.kt index 7bcc6ace..0577f300 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpCompare.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpCompare.kt @@ -7,7 +7,7 @@ import java.util.function.BiPredicate class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate) : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = args.getChecked(0, argc) val rhs = args.getChecked(1, argc) if (lhs.tolerantEquals(rhs)) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpEquality.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpEquality.kt index c9087d27..782816ea 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpEquality.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/logic/OpEquality.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val lhs = args[0] val rhs = args[1] diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcCos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcCos.kt index 8cda419a..a0597fd3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcCos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcCos.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.asSpellResult import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.getChecked @@ -13,11 +13,11 @@ object OpArcCos : ConstManaOperator { override val argc: Int get() = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) if (value < -1 || value > 1) throw MishapInvalidIota( - SpellDatum.make(value), + LegacySpellDatum.make(value), 0, "hexcasting.mishap.invalid_value.double.between".asTranslatedComponent(-1, 1) ) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcSin.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcSin.kt index 1bf6792f..76468f30 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcSin.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcSin.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.asSpellResult import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.getChecked @@ -13,11 +13,11 @@ object OpArcSin : ConstManaOperator { override val argc: Int get() = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) if (value < -1 || value > 1) throw MishapInvalidIota( - SpellDatum.make(value), + LegacySpellDatum.make(value), 0, "hexcasting.mishap.invalid_value.double.between".asTranslatedComponent(-1, 1) ) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcTan.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcTan.kt index edf92c10..38615522 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcTan.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpArcTan.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val value = args.getChecked(0, argc) return atan(value).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpCos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpCos.kt index 17c8993e..01885ce9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpCos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpCos.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val angle = args.getChecked(0, argc) return cos(angle).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpSin.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpSin.kt index 25ca5bbe..18a6dc2b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpSin.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpSin.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val angle = args.getChecked(0, argc) return sin(angle).asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpTan.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpTan.kt index ec424527..7219d3d0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpTan.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/math/trig/OpTan.kt @@ -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.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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 OpTan : ConstManaOperator { override val argc: Int get() = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val angle = args.getChecked(0, argc) if (cos(angle) == 0.0) throw MishapDivideByZero.tan(angle) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetCaster.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetCaster.kt index 3329bb8e..b153cab7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetCaster.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetCaster.kt @@ -1,14 +1,14 @@ package at.petrak.hexcasting.common.casting.operators.selectors import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.asSpellResult import at.petrak.hexcasting.api.spell.casting.CastingContext object OpGetCaster : ConstManaOperator { override val argc = 0 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { ctx.assertEntityInRange(ctx.caster) return ctx.caster.asSpellResult } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntitiesBy.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntitiesBy.kt index dbd21d34..45a9999b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntitiesBy.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntitiesBy.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.selectors import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.Operator.Companion.MAX_DISTANCE -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.spellListOf @@ -20,7 +20,7 @@ import java.util.function.Predicate class OpGetEntitiesBy(val checker: Predicate, val negate: Boolean) : ConstManaOperator { override val argc = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val pos = args.getChecked(0, argc) val maybeRadius = args.getChecked(1, argc) ctx.assertVecInRange(pos) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntityAt.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntityAt.kt index a9ba9a48..6b47ccd9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntityAt.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/selectors/OpGetEntityAt.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators.selectors import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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 java.util.function.Predicate class OpGetEntityAt(val checker: Predicate) : ConstManaOperator { override val argc = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val pos = args.getChecked(0, argc) ctx.assertVecInRange(pos) val aabb = AABB(pos.add(Vec3(-0.5, -0.5, -0.5)), pos.add(Vec3(0.5, 0.5, 0.5))) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt index 518f131e..a714dc1d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt @@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.world.entity.Entity @@ -15,7 +15,7 @@ object OpAddMotion : SpellOperator { get() = 2 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBeep.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBeep.kt index 8b762177..d8a7da0f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBeep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBeep.kt @@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.common.network.MsgBeepAck @@ -16,7 +16,7 @@ object OpBeep : SpellOperator { override val argc = 3 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBlink.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBlink.kt index ad0f2675..b6ef67ec 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBlink.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBlink.kt @@ -15,7 +15,7 @@ import kotlin.math.roundToInt object OpBlink : SpellOperator { override val argc = 2 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBreakBlock.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBreakBlock.kt index abd9706b..96138479 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBreakBlock.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpBreakBlock.kt @@ -13,7 +13,7 @@ object OpBreakBlock : SpellOperator { get() = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val pos = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt index 269b5fc3..043c3a76 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpColorize.kt @@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem @@ -14,7 +14,7 @@ object OpColorize : SpellOperator { override val argc = 0 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val (handStack, hand) = ctx.getHeldItemToOperateOn(IXplatAbstractions.INSTANCE::isColorizer) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpConjure.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpConjure.kt index 6eca6d16..56824369 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpConjure.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpConjure.kt @@ -16,7 +16,7 @@ import net.minecraft.world.phys.Vec3 class OpConjure(val light: Boolean) : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple>? { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpCreateWater.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpCreateWater.kt index 7dd8121e..0be47437 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpCreateWater.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpCreateWater.kt @@ -18,7 +18,7 @@ import net.minecraft.world.phys.Vec3 object OpCreateWater : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpDestroyWater.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpDestroyWater.kt index 7337faff..ef85b5df 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpDestroyWater.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpDestroyWater.kt @@ -20,7 +20,7 @@ import net.minecraft.world.phys.Vec3 object OpDestroyWater : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpEdifySapling.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpEdifySapling.kt index aa285d63..065902a7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpEdifySapling.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpEdifySapling.kt @@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadBlock @@ -17,7 +17,7 @@ object OpEdifySapling : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val pos = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt index 627a4820..3d7baf09 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.spells import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem @@ -13,7 +13,7 @@ class OpErase : SpellOperator { override val argc = 0 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val (handStack, hand) = ctx.getHeldItemToOperateOn { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExplode.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExplode.kt index 8d664d3a..241460ec 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExplode.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExplode.kt @@ -13,7 +13,7 @@ class OpExplode(val fire: Boolean) : SpellOperator { get() = 2 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val pos = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExtinguish.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExtinguish.kt index 30df546f..a16bc450 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExtinguish.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpExtinguish.kt @@ -19,7 +19,7 @@ import net.minecraft.world.phys.Vec3 object OpExtinguish : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpIgnite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpIgnite.kt index 793a2a5d..c6154100 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpIgnite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpIgnite.kt @@ -17,7 +17,7 @@ import net.minecraft.world.phys.Vec3 object OpIgnite : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt index 4ecd79e9..182d335b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.mod.HexItemTags import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem @@ -23,7 +23,7 @@ object OpMakeBattery : SpellOperator { override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val entity = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt index c8f3b9fd..ae91f4cb 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakePackagedSpell.kt @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.spells import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext @@ -19,7 +19,7 @@ import net.minecraft.world.entity.item.ItemEntity class OpMakePackagedSpell(val itemType: T, val cost: Int) : SpellOperator { override val argc = 2 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val entity = args.getChecked(0, argc) @@ -56,7 +56,7 @@ class OpMakePackagedSpell(val itemType: T, val cost: Int) : return Triple(Spell(entity, patterns), cost, listOf(ParticleSpray.burst(entity.position(), 0.5))) } - private inner class Spell(val itemEntity: ItemEntity, val patterns: List>) : RenderedSpell { + private inner class Spell(val itemEntity: ItemEntity, val patterns: List>) : RenderedSpell { override fun cast(ctx: CastingContext) { val (handStack) = ctx.getHeldItemToOperateOn { it.`is`(itemType) } val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(handStack) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt index 8948f0a6..74d0c95c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPlaceBlock.kt @@ -20,7 +20,7 @@ object OpPlaceBlock : SpellOperator { get() = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple>? { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPotionEffect.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPotionEffect.kt index 0e305be6..0219e5b1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPotionEffect.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPotionEffect.kt @@ -20,12 +20,12 @@ class OpPotionEffect( get() = if (this.allowPotency) 3 else 2 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) if (target is ArmorStand) - throw MishapInvalidIota.ofClass(SpellDatum.make(target), 0, LivingEntity::class.java) + throw MishapInvalidIota.ofClass(LegacySpellDatum.make(target), 0, LivingEntity::class.java) val duration = max(args.getChecked(1, argc), 0.0) ctx.assertEntityInRange(target) val potency = if (this.allowPotency) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPrint.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPrint.kt index 2af66865..c560c012 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPrint.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpPrint.kt @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.spells import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect import at.petrak.hexcasting.api.spell.casting.SpellContinuation @@ -11,7 +11,7 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs import net.minecraft.Util object OpPrint : Operator { - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { if (stack.isEmpty()) { throw MishapNotEnoughArgs(1, 0) } @@ -23,7 +23,7 @@ object OpPrint : Operator { ) } - private data class Spell(val datum: SpellDatum<*>) : RenderedSpell { + private data class Spell(val datum: LegacySpellDatum<*>) : RenderedSpell { override fun cast(ctx: CastingContext) { ctx.caster.sendMessage( datum.display(), diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt index c9dc25ce..14cb3ac7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt @@ -13,7 +13,7 @@ import net.minecraft.world.entity.item.ItemEntity object OpRecharge : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple>? { val (handStack, hand) = ctx.getHeldItemToOperateOn { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpTheOnlyReasonAnyoneDownloadedPsi.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpTheOnlyReasonAnyoneDownloadedPsi.kt index 71c8c7fd..b9c2805c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpTheOnlyReasonAnyoneDownloadedPsi.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpTheOnlyReasonAnyoneDownloadedPsi.kt @@ -16,7 +16,7 @@ import net.minecraft.world.phys.Vec3 object OpTheOnlyReasonAnyoneDownloadedPsi : SpellOperator { override val argc = 1 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt index 4cd97986..4dcab445 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt @@ -23,7 +23,7 @@ object OpBrainsweep : SpellOperator { override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val sacrifice = args.getChecked(0, argc) @@ -49,7 +49,12 @@ object OpBrainsweep : SpellOperator { ) } - private data class Spell(val pos: BlockPos, val state: BlockState, val sacrifice: Villager, val recipe: BrainsweepRecipe) : RenderedSpell { + private data class Spell( + val pos: BlockPos, + val state: BlockState, + val sacrifice: Villager, + val recipe: BrainsweepRecipe + ) : RenderedSpell { override fun cast(ctx: CastingContext) { ctx.world.setBlockAndUpdate(pos, BrainsweepRecipe.copyProperties(state, recipe.result)) Brainsweeping.brainsweep(sacrifice) @@ -61,6 +66,4 @@ object OpBrainsweep : SpellOperator { ctx.world.playSound(null, sacrifice, SoundEvents.PLAYER_LEVELUP, SoundSource.AMBIENT, 0.5f, 0.8f) } } - - } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpCreateLava.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpCreateLava.kt index f0c8f0c6..ae60ea2d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpCreateLava.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpCreateLava.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -22,7 +22,7 @@ object OpCreateLava : SpellOperator { override val argc = 1 override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpFlight.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpFlight.kt index 6b35d657..d2de2aad 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpFlight.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpFlight.kt @@ -15,7 +15,7 @@ object OpFlight : SpellOperator { override val argc = 3 override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpLightning.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpLightning.kt index 71a7ee73..9a882a3b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpLightning.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpLightning.kt @@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import net.minecraft.core.BlockPos @@ -17,7 +17,7 @@ object OpLightning : SpellOperator { override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpTeleport.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpTeleport.kt index fa7e4ba6..4d629b54 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpTeleport.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpTeleport.kt @@ -15,7 +15,7 @@ object OpTeleport : SpellOperator { override val argc = 2 override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val teleportee = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpWeather.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpWeather.kt index 309dabc1..1d8ce396 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpWeather.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpWeather.kt @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.spells.great import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext @@ -12,7 +12,7 @@ class OpWeather(val rain: Boolean) : SpellOperator { override val isGreat = true override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple>? { if (ctx.world.isRaining == rain) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpCreateSentinel.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpCreateSentinel.kt index 0711f252..9fd5bbd4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpCreateSentinel.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpCreateSentinel.kt @@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.player.Sentinel import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -17,7 +17,7 @@ class OpCreateSentinel(val extendsRange: Boolean) : SpellOperator { override val isGreat = this.extendsRange override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val target = args.getChecked(0, argc) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpDestroySentinel.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpDestroySentinel.kt index 9a339535..6a215eb7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpDestroySentinel.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpDestroySentinel.kt @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.player.Sentinel import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapLocationInWrongDimension @@ -14,7 +14,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions object OpDestroySentinel : SpellOperator { override val argc = 0 override fun execute( - args: List>, + args: List>, ctx: CastingContext ): Triple> { val particles = mutableListOf() diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelPos.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelPos.kt index 07deb4ec..11ef3c2d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelPos.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelPos.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.spells.sentinel import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.asSpellResult import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapLocationInWrongDimension @@ -11,7 +11,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions object OpGetSentinelPos : ConstManaOperator { override val argc = 0 override val manaCost = ManaConstants.DUST_UNIT / 10 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster) if (sentinel.dimension != ctx.world.dimension()) throw MishapLocationInWrongDimension(sentinel.dimension.location()) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelWayfind.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelWayfind.kt index ae57f0af..c652f8d8 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelWayfind.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/sentinel/OpGetSentinelWayfind.kt @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.spells.sentinel import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum 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 @@ import net.minecraft.world.phys.Vec3 object OpGetSentinelWayfind : ConstManaOperator { override val argc = 1 override val manaCost = ManaConstants.DUST_UNIT / 10 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val from = args.getChecked(0, argc) val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpAlwinfyHasAscendedToABeingOfPureMath.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpAlwinfyHasAscendedToABeingOfPureMath.kt index 5eaf531f..307b984a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpAlwinfyHasAscendedToABeingOfPureMath.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpAlwinfyHasAscendedToABeingOfPureMath.kt @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect import at.petrak.hexcasting.api.spell.casting.SpellContinuation @@ -20,8 +20,8 @@ import kotlin.math.roundToInt object OpAlwinfyHasAscendedToABeingOfPureMath : Operator { override fun operate( continuation: SpellContinuation, - stack: MutableList>, - local: SpellDatum<*>, + stack: MutableList>, + local: LegacySpellDatum<*>, ctx: CastingContext ): OperationResult { if (stack.isEmpty()) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicate.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicate.kt index b69a2b29..ee11e82f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicate.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicate.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.spellListOf @@ -10,7 +10,7 @@ object OpDuplicate : ConstManaOperator { override val argc: Int get() = 1 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val datum = args.getChecked(0, argc) return spellListOf(datum, datum) } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicateN.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicateN.kt index e8812508..2b995a05 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicateN.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpDuplicateN.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota @@ -13,7 +13,7 @@ object OpDuplicateN : ConstManaOperator { override val argc: Int get() = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val countDouble = args.getChecked(1, argc) if (abs(countDouble.roundToInt() - countDouble) >= 0.05f) @@ -25,7 +25,7 @@ object OpDuplicateN : ConstManaOperator { val count = countDouble.roundToInt() // there's gotta be a better way to do this - val out = mutableListOf>() + val out = mutableListOf>() for (n in 0 until count) out.add(args[0]) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpFisherman.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpFisherman.kt index 0623f905..b4b9d9d5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpFisherman.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpFisherman.kt @@ -1,8 +1,8 @@ package at.petrak.hexcasting.common.casting.operators.stack +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator -import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.SpellContinuation import at.petrak.hexcasting.api.spell.getChecked @@ -15,8 +15,8 @@ import kotlin.math.roundToInt object OpFisherman : Operator { override fun operate( continuation: SpellContinuation, - stack: MutableList>, - local: SpellDatum<*>, + stack: MutableList>, + local: LegacySpellDatum<*>, ctx: CastingContext ): OperationResult { if (stack.size < 2) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpMask.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpMask.kt index 40631da9..a9a1ae6e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpMask.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpMask.kt @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import it.unimi.dsi.fastutil.booleans.BooleanList @@ -9,8 +9,8 @@ class OpMask(val mask: BooleanList) : ConstManaOperator { override val argc: Int get() = mask.size - override fun execute(args: List>, ctx: CastingContext): List> { - val out = ArrayList>(this.mask.size) + override fun execute(args: List>, ctx: CastingContext): List> { + val out = ArrayList>(this.mask.size) for ((i, include) in this.mask.withIndex()) { if (include) out.add(args[i]) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpStackSize.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpStackSize.kt index 011adfea..66169112 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpStackSize.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpStackSize.kt @@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.SpellContinuation object OpStackSize : Operator { - override fun operate(continuation: SpellContinuation, stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { - stack.add(SpellDatum.make(stack.size.toDouble())) + override fun operate(continuation: SpellContinuation, stack: MutableList>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult { + stack.add(LegacySpellDatum.make(stack.size.toDouble())) return OperationResult(continuation, stack, local, listOf()) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpSwap.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpSwap.kt index 8fe895ec..aa396f3d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpSwap.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/stack/OpSwap.kt @@ -3,14 +3,14 @@ package at.petrak.hexcasting.common.casting.operators.stack import at.petrak.hexcasting.api.spell.ConstManaOperator import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.spellListOf -import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext object OpSwap : ConstManaOperator { override val argc: Int get() = 2 - override fun execute(args: List>, ctx: CastingContext): List> { + override fun execute(args: List>, ctx: CastingContext): List> { val a = args.getChecked(0, argc) val b = args.getChecked(1, argc) return spellListOf(b, a) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/command/ListPatternsCommand.java b/Common/src/main/java/at/petrak/hexcasting/common/command/ListPatternsCommand.java index 701b6895..753e51e2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/command/ListPatternsCommand.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/command/ListPatternsCommand.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.command; import at.petrak.hexcasting.api.PatternRegistry; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.common.items.ItemScroll; import at.petrak.hexcasting.common.lib.HexItems; @@ -32,7 +32,7 @@ public class ListPatternsCommand { for (var pair : listing) { ctx.getSource().sendSuccess(new TextComponent(pair.getValue().getFirst().toString()) .append(": ") - .append(SpellDatum.make(HexPattern.fromAngles(pair.getKey(), pair.getValue().getSecond())) + .append(LegacySpellDatum.make(HexPattern.fromAngles(pair.getKey(), pair.getValue().getSecond())) .display()), false); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java index 584e9ce2..3db355c2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.lib.HexSounds; import net.minecraft.nbt.CompoundTag; @@ -27,17 +27,17 @@ public class ItemAbacus extends Item implements DataHolderItem { @Override public @Nullable CompoundTag readDatumTag(ItemStack stack) { - var datum = SpellDatum.make(NBTHelper.getDouble(stack, TAG_VALUE)); + var datum = LegacySpellDatum.make(NBTHelper.getDouble(stack, TAG_VALUE)); return datum.serializeToNBT(); } @Override - public boolean canWrite(ItemStack stack, SpellDatum datum) { + public boolean canWrite(ItemStack stack, LegacySpellDatum datum) { return false; } @Override - public void writeDatum(ItemStack stack, SpellDatum datum) { + public void writeDatum(ItemStack stack, LegacySpellDatum datum) { // nope } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java index c106e362..36f357cd 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; import net.minecraft.nbt.CompoundTag; @@ -39,22 +39,23 @@ public class ItemFocus extends Item implements DataHolderItem { } @Override - public @Nullable SpellDatum emptyDatum(ItemStack stack) { - return SpellDatum.make(Widget.NULL); + public @Nullable LegacySpellDatum emptyDatum(ItemStack stack) { + return LegacySpellDatum.make(Widget.NULL); } @Override - public boolean canWrite(ItemStack stack, SpellDatum datum) { + public boolean canWrite(ItemStack stack, LegacySpellDatum datum) { return datum == null || !NBTHelper.getBoolean(stack, TAG_SEALED); } @Override - public void writeDatum(ItemStack stack, SpellDatum datum) { + public void writeDatum(ItemStack stack, LegacySpellDatum datum) { if (datum == null) { stack.removeTagKey(TAG_DATA); stack.removeTagKey(TAG_SEALED); - } else if (!NBTHelper.getBoolean(stack, TAG_SEALED)) + } else if (!NBTHelper.getBoolean(stack, TAG_SEALED)) { NBTHelper.put(stack, TAG_DATA, datum.serializeToNBT()); + } } @Override diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java index c6c5c288..2b65a915 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.client.gui.PatternTooltipGreeble; @@ -55,17 +55,17 @@ public class ItemScroll extends Item implements DataHolderItem { return null; } var out = new CompoundTag(); - out.put(SpellDatum.TAG_PATTERN, pattern); + out.put(LegacySpellDatum.TAG_PATTERN, pattern); return out; } @Override - public boolean canWrite(ItemStack stack, SpellDatum datum) { + public boolean canWrite(ItemStack stack, LegacySpellDatum datum) { return datum != null && datum.getType() == DatumType.PATTERN && !NBTHelper.hasCompound(stack, TAG_PATTERN); } @Override - public void writeDatum(ItemStack stack, SpellDatum datum) { + public void writeDatum(ItemStack stack, LegacySpellDatum datum) { if (this.canWrite(stack, datum) && datum.getPayload() instanceof HexPattern pat) { NBTHelper.putCompound(stack, TAG_PATTERN, pat.serializeToNBT()); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java index 79fb7fbf..980d69b3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java @@ -4,7 +4,7 @@ import at.petrak.hexcasting.annotations.SoftImplement; import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.client.gui.PatternTooltipGreeble; import at.petrak.hexcasting.api.utils.NBTHelper; @@ -75,17 +75,17 @@ public class ItemSlate extends BlockItem implements DataHolderItem { return null; } var out = new CompoundTag(); - out.put(SpellDatum.TAG_PATTERN, patTag); + out.put(LegacySpellDatum.TAG_PATTERN, patTag); return out; } @Override - public boolean canWrite(ItemStack stack, SpellDatum datum) { + public boolean canWrite(ItemStack stack, LegacySpellDatum datum) { return datum == null || datum.getType() == DatumType.PATTERN; } @Override - public void writeDatum(ItemStack stack, SpellDatum datum) { + public void writeDatum(ItemStack stack, LegacySpellDatum datum) { if (this.canWrite(stack, datum)) { if (datum == null) { var beTag = NBTHelper.getOrCreateCompound(stack, "BlockEntityTag"); diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java index 5e17cc4e..b162dc05 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; import net.minecraft.ChatFormatting; @@ -124,17 +124,17 @@ public class ItemSpellbook extends Item implements DataHolderItem { } @Override - public @Nullable SpellDatum emptyDatum(ItemStack stack) { - return SpellDatum.make(Widget.NULL); + public @Nullable LegacySpellDatum emptyDatum(ItemStack stack) { + return LegacySpellDatum.make(Widget.NULL); } @Override - public boolean canWrite(ItemStack stack, SpellDatum datum) { + public boolean canWrite(ItemStack stack, LegacySpellDatum datum) { return datum == null || !IsSealed(stack); } @Override - public void writeDatum(ItemStack stack, SpellDatum datum) { + public void writeDatum(ItemStack stack, LegacySpellDatum datum) { if (datum != null && IsSealed(stack)) { return; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java index 3eb06ac1..2a4f76b2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.common.items.magic; import at.petrak.hexcasting.api.item.HexHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.casting.CastingContext; import at.petrak.hexcasting.api.spell.casting.CastingHarness; import at.petrak.hexcasting.api.spell.math.HexPattern; @@ -58,29 +58,29 @@ public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolde } @Override - public @Nullable List> getHex(ItemStack stack, ServerLevel level) { + public @Nullable List> getHex(ItemStack stack, ServerLevel level) { var patsTag = NBTHelper.getList(stack, TAG_PATTERNS, Tag.TAG_COMPOUND); if (patsTag == null) { return null; } - var out = new ArrayList>(); + var out = new ArrayList>(); for (var patTag : patsTag) { CompoundTag tag = NBTHelper.getAsCompound(patTag); if (tag.size() != 1) { - out.add(SpellDatum.make(HexPattern.fromNBT(tag))); + out.add(LegacySpellDatum.make(HexPattern.fromNBT(tag))); } else { - out.add(SpellDatum.fromNBT(tag, level)); + out.add(LegacySpellDatum.fromNBT(tag, level)); } } return out; } @Override - public void writeHex(ItemStack stack, List> patterns, int mana) { + public void writeHex(ItemStack stack, List> patterns, int mana) { ListTag patsTag = new ListTag(); - for (SpellDatum pat : patterns) { + for (LegacySpellDatum pat : patterns) { patsTag.add(pat.serializeToNBT()); } @@ -107,7 +107,7 @@ public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolde return InteractionResultHolder.success(stack); } - List> instrs = getHex(stack, (ServerLevel) world); + List> instrs = getHex(stack, (ServerLevel) world); if (instrs == null) { return InteractionResultHolder.fail(stack); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java index b1faf30c..a726eba1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.network; import at.petrak.hexcasting.api.mod.HexItemTags; import at.petrak.hexcasting.api.mod.HexStatistics; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.casting.ControllerInfo; import at.petrak.hexcasting.api.spell.casting.ResolvedPattern; import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType; @@ -74,7 +74,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern } var currentResolvedPattern = resolvedPatterns.get(resolvedPatterns.size() - 1); var currentSpellPoints = currentResolvedPattern.getPattern() - .positions(currentResolvedPattern.getOrigin()); + .positions(currentResolvedPattern.getOrigin()); if (currentSpellPoints.stream().anyMatch(allPoints::contains)) { autoFail = true; } @@ -87,14 +87,14 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern ControllerInfo clientInfo; if (autoFail) { clientInfo = new ControllerInfo(false, harness.getStack().isEmpty(), ResolvedPatternType.INVALID, - harness.generateDescs()); + harness.generateDescs()); } else { - clientInfo = harness.executeIota(SpellDatum.make(this.pattern), sender.getLevel()); + clientInfo = harness.executeIota(LegacySpellDatum.make(this.pattern), sender.getLevel()); if (clientInfo.getMakesCastSound()) { sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(), - HexSounds.ACTUALLY_CAST, SoundSource.PLAYERS, 1f, - 1f + ((float) Math.random() - 0.5f) * 0.2f); + HexSounds.ACTUALLY_CAST, SoundSource.PLAYERS, 1f, + 1f + ((float) Math.random() - 0.5f) * 0.2f); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java index e9a0d904..2ecd835c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.network; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.items.ItemAbacus; import at.petrak.hexcasting.common.items.ItemSpellbook; @@ -123,7 +123,7 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea var datumTag = HexItems.ABACUS.readDatumTag(stack); if (datumTag != null) { - var popup = SpellDatum.displayFromNBT(datumTag); + var popup = LegacySpellDatum.displayFromNBT(datumTag); sender.displayClientMessage( new TranslatableComponent("hexcasting.tooltip.abacus", popup).withStyle(ChatFormatting.GREEN), true); } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java index 14b07778..59d09523 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.fabric.cc; import at.petrak.hexcasting.api.addldata.DataHolder; import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; @@ -32,7 +32,7 @@ public abstract class CCDataHolder extends ItemComponent implements DataHolder { } @Override - public boolean writeDatum(@Nullable SpellDatum datum, boolean simulate) { + public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { var canWrite = this.dataHolder.canWrite(this.stack, datum); if (!canWrite) { return false; @@ -45,21 +45,21 @@ public abstract class CCDataHolder extends ItemComponent implements DataHolder { } public static class Static extends CCDataHolder { - private final Function> provider; + private final Function> provider; - public Static(ItemStack stack, Function> provider) { + public Static(ItemStack stack, Function> provider) { super(stack); this.provider = provider; } @Override public @Nullable CompoundTag readRawDatum() { - SpellDatum datum = this.provider.apply(this.stack); + LegacySpellDatum datum = this.provider.apply(this.stack); return datum == null ? null : datum.serializeToNBT(); } @Override - public boolean writeDatum(@Nullable SpellDatum datum, boolean simulate) { + public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { return false; } } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java index 9bf0c2cd..5459ec10 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.fabric.cc; import at.petrak.hexcasting.api.addldata.HexHolder; import at.petrak.hexcasting.api.item.HexHolderItem; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; @@ -39,12 +39,12 @@ public abstract class CCHexHolder extends ItemComponent implements HexHolder { } @Override - public @Nullable List> getHex(ServerLevel level) { + public @Nullable List> getHex(ServerLevel level) { return this.hexHolder.getHex(this.stack, level); } @Override - public void writeHex(List> patterns, int mana) { + public void writeHex(List> patterns, int mana) { this.hexHolder.writeHex(this.stack, patterns, mana); } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java index 19c4bcd3..9ca06285 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.item.HexHolderItem; import at.petrak.hexcasting.api.item.ManaHolderItem; import at.petrak.hexcasting.api.mod.HexConfig; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.common.lib.HexItems; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; @@ -63,7 +63,7 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo // oh havoc, you think you're so funny // the worst part is you're /right/ registry.register(Items.PUMPKIN_PIE, DATA_HOLDER, stack -> new CCDataHolder.Static(stack, - s -> SpellDatum.make(Math.PI * s.getCount()))); + s -> LegacySpellDatum.make(Math.PI * s.getCount()))); registry.register(i -> i instanceof ManaHolderItem, MANA_HOLDER, CCManaHolder.ItemBased::new); registry.register(HexItems.AMETHYST_DUST, MANA_HOLDER, s -> new CCManaHolder.Static( diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java index 62b794d0..f76786ee 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java @@ -1,12 +1,7 @@ package at.petrak.hexcasting.fabric.recipe; -import at.petrak.hexcasting.api.addldata.DataHolder; import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; -import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; -import at.petrak.hexcasting.xplat.IXplatAbstractions; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.tropheusj.serialization_hooks.ingredient.BaseCustomIngredient; @@ -26,89 +21,85 @@ import java.util.Objects; import static at.petrak.hexcasting.api.HexAPI.modLoc; public class FabricUnsealedIngredient extends BaseCustomIngredient { - private static final ResourceLocation ID = modLoc("unsealed"); + private static final ResourceLocation ID = modLoc("unsealed"); - private final ItemStack stack; + private final ItemStack stack; - protected FabricUnsealedIngredient(ItemStack stack) { - super(Arrays.stream(DatumType.values()) - .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) - .map((type) -> { - ItemStack newStack = stack.copy(); - NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type)); - return new Ingredient.ItemValue(newStack); - })); - this.stack = stack; - } + protected FabricUnsealedIngredient(ItemStack stack) { + super(Arrays.stream(DatumType.values()) + .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) + .map((type) -> { + ItemStack newStack = stack.copy(); + NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type)); + return new Ingredient.ItemValue(newStack); + })); + this.stack = stack; + } - /** - * Creates a new ingredient matching the given stack - */ - public static FabricUnsealedIngredient of(ItemStack stack) { - return new FabricUnsealedIngredient(stack); - } + /** + * Creates a new ingredient matching the given stack + */ + public static FabricUnsealedIngredient of(ItemStack stack) { + return new FabricUnsealedIngredient(stack); + } - @Override - public boolean test(@Nullable ItemStack input) { - if (input == null) - return false; - if(this.stack.getItem() == input.getItem() && this.stack.getDamageValue() == input.getDamageValue()) { - DataHolder holder = IXplatAbstractions.INSTANCE.findDataHolder(this.stack); - if (holder != null) { - return holder.readRawDatum() != null && holder.writeDatum(SpellDatum.make(Widget.NULL), true); - } - } + @Override + public boolean test(@Nullable ItemStack input) { + if (input == null) { + return false; + } - return false; - } + return false; + } - @Override - public @NotNull JsonElement toJson() { - JsonObject json = new JsonObject(); - json.addProperty("type", Objects.toString(ID)); - json.addProperty("item", Objects.toString(Registry.ITEM.getKey(this.stack.getItem()))); - return json; - } + @Override + public @NotNull JsonElement toJson() { + JsonObject json = new JsonObject(); + json.addProperty("type", Objects.toString(ID)); + json.addProperty("item", Objects.toString(Registry.ITEM.getKey(this.stack.getItem()))); + return json; + } - @Override - public IngredientDeserializer getDeserializer() { - return Deserializer.INSTANCE; - } + @Override + public IngredientDeserializer getDeserializer() { + return Deserializer.INSTANCE; + } - public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { - return new FabricUnsealedIngredient(friendlyByteBuf.readItem()); - } + public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { + return new FabricUnsealedIngredient(friendlyByteBuf.readItem()); + } - public static Ingredient fromJson(JsonElement element) { - if (element == null || element.isJsonNull() || !element.isJsonObject()) - return null; + public static Ingredient fromJson(JsonElement element) { + if (element == null || element.isJsonNull() || !element.isJsonObject()) { + return null; + } - JsonObject object = element.getAsJsonObject(); + JsonObject object = element.getAsJsonObject(); - if (object.has("type") && object.getAsJsonPrimitive("type").getAsString().equals(ID.toString())) { - return new FabricUnsealedIngredient(new ItemStack(ShapedRecipe.itemFromJson(object))); - } + if (object.has("type") && object.getAsJsonPrimitive("type").getAsString().equals(ID.toString())) { + return new FabricUnsealedIngredient(new ItemStack(ShapedRecipe.itemFromJson(object))); + } - return null; - } + return null; + } - @Override - public void toNetwork(FriendlyByteBuf friendlyByteBuf) { - friendlyByteBuf.writeItem(stack); - } + @Override + public void toNetwork(FriendlyByteBuf friendlyByteBuf) { + friendlyByteBuf.writeItem(stack); + } - public static class Deserializer implements IngredientDeserializer { - public static final Deserializer INSTANCE = new Deserializer(); + public static class Deserializer implements IngredientDeserializer { + public static final Deserializer INSTANCE = new Deserializer(); - @Override - public Ingredient fromNetwork(FriendlyByteBuf buffer) { - return FabricUnsealedIngredient.fromNetwork(buffer); - } + @Override + public Ingredient fromNetwork(FriendlyByteBuf buffer) { + return FabricUnsealedIngredient.fromNetwork(buffer); + } - @Nullable - @Override - public Ingredient fromJson(JsonObject object) { - return FabricUnsealedIngredient.fromJson(object); - } - } + @Nullable + @Override + public Ingredient fromJson(JsonObject object) { + return FabricUnsealedIngredient.fromJson(object); + } + } } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java index e6227acd..dca1a0ec 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java @@ -10,7 +10,7 @@ import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.item.HexHolderItem; import at.petrak.hexcasting.api.item.ManaHolderItem; import at.petrak.hexcasting.api.mod.HexConfig; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.common.lib.HexItems; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -73,7 +73,7 @@ public class ForgeCapabilityHandler { () -> new ItemBasedDataHolder(holder, stack))); else if (stack.is(Items.PUMPKIN_PIE)) // haha yes evt.addCapability(DATA_ITEM_CAPABILITY, provide(stack, HexCapabilities.DATUM, - () -> new StaticDatumHolder((s) -> SpellDatum.make(Math.PI * s.getCount()), stack))); + () -> new StaticDatumHolder((s) -> LegacySpellDatum.make(Math.PI * s.getCount()), stack))); if (stack.getItem() instanceof HexHolderItem holder) evt.addCapability(SPELL_HOLDER_CAPABILITY, provide(stack, HexCapabilities.STORED_HEX, @@ -213,24 +213,24 @@ public class ForgeCapabilityHandler { } } - private record StaticDatumHolder(Function> provider, + private record StaticDatumHolder(Function> provider, ItemStack stack) implements DataHolder { @Override public @Nullable CompoundTag readRawDatum() { - SpellDatum datum = provider.apply(stack); + LegacySpellDatum datum = provider.apply(stack); return datum == null ? null : datum.serializeToNBT(); } @Override public @Nullable - SpellDatum readDatum(ServerLevel world) { + LegacySpellDatum readDatum(ServerLevel world) { return provider.apply(stack); } @Override - public boolean writeDatum(@Nullable SpellDatum datum, boolean simulate) { + public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { return false; } } @@ -246,18 +246,18 @@ public class ForgeCapabilityHandler { @Override public @Nullable - SpellDatum readDatum(ServerLevel world) { + LegacySpellDatum readDatum(ServerLevel world) { return holder.readDatum(stack, world); } @Override public @Nullable - SpellDatum emptyDatum() { + LegacySpellDatum emptyDatum() { return holder.emptyDatum(stack); } @Override - public boolean writeDatum(@Nullable SpellDatum datum, boolean simulate) { + public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { if (!holder.canWrite(stack, datum)) { return false; } @@ -282,12 +282,12 @@ public class ForgeCapabilityHandler { } @Override - public @Nullable List> getHex(ServerLevel level) { + public @Nullable List> getHex(ServerLevel level) { return holder.getHex(stack, level); } @Override - public void writeHex(List> patterns, int mana) { + public void writeHex(List> patterns, int mana) { holder.writeHex(stack, patterns, mana); } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java index 17d38831..ced8ded1 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java @@ -3,7 +3,7 @@ package at.petrak.hexcasting.forge.recipe; import at.petrak.hexcasting.api.addldata.DataHolder; import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.spell.DatumType; -import at.petrak.hexcasting.api.spell.SpellDatum; +import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.xplat.IXplatAbstractions; @@ -23,75 +23,76 @@ import java.util.Arrays; import java.util.Objects; public class ForgeUnsealedIngredient extends AbstractIngredient { - private final ItemStack stack; + private final ItemStack stack; - protected ForgeUnsealedIngredient(ItemStack stack) { - super(Arrays.stream(DatumType.values()) - .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) - .map((type) -> { - ItemStack newStack = stack.copy(); - NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type)); - return new Ingredient.ItemValue(newStack); - })); - this.stack = stack; - } + protected ForgeUnsealedIngredient(ItemStack stack) { + super(Arrays.stream(DatumType.values()) + .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) + .map((type) -> { + ItemStack newStack = stack.copy(); + NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, LegacySpellDatum.tagForType(type)); + return new Ingredient.ItemValue(newStack); + })); + this.stack = stack; + } - /** - * Creates a new ingredient matching the given stack - */ - public static ForgeUnsealedIngredient of(ItemStack stack) { - return new ForgeUnsealedIngredient(stack); - } + /** + * Creates a new ingredient matching the given stack + */ + public static ForgeUnsealedIngredient of(ItemStack stack) { + return new ForgeUnsealedIngredient(stack); + } - @Override - public boolean test(@Nullable ItemStack input) { - if (input == null) + @Override + public boolean test(@Nullable ItemStack input) { + if (input == null) { return false; - if(this.stack.getItem() == input.getItem() && this.stack.getDamageValue() == input.getDamageValue()) { - DataHolder holder = IXplatAbstractions.INSTANCE.findDataHolder(this.stack); - if (holder != null) { - return holder.readRawDatum() != null && holder.writeDatum(SpellDatum.make(Widget.NULL), true); - } } + if (this.stack.getItem() == input.getItem() && this.stack.getDamageValue() == input.getDamageValue()) { + DataHolder holder = IXplatAbstractions.INSTANCE.findDataHolder(this.stack); + if (holder != null) { + return holder.readRawDatum() != null && holder.writeDatum(LegacySpellDatum.make(Widget.NULL), true); + } + } - return false; - } + return false; + } - @Override - public boolean isSimple() { - return false; - } + @Override + public boolean isSimple() { + return false; + } - @Override - public @NotNull IIngredientSerializer getSerializer() { - return ForgeUnsealedIngredient.Serializer.INSTANCE; - } + @Override + public @NotNull IIngredientSerializer getSerializer() { + return ForgeUnsealedIngredient.Serializer.INSTANCE; + } - @Override - public @NotNull JsonElement toJson() { - JsonObject json = new JsonObject(); - json.addProperty("type", Objects.toString(CraftingHelper.getID(NBTIngredient.Serializer.INSTANCE))); - json.addProperty("item", Objects.toString(stack.getItem().getRegistryName())); - return json; - } + @Override + public @NotNull JsonElement toJson() { + JsonObject json = new JsonObject(); + json.addProperty("type", Objects.toString(CraftingHelper.getID(NBTIngredient.Serializer.INSTANCE))); + json.addProperty("item", Objects.toString(stack.getItem().getRegistryName())); + return json; + } - public static class Serializer implements IIngredientSerializer { - public static final ForgeUnsealedIngredient.Serializer INSTANCE = new ForgeUnsealedIngredient.Serializer(); + public static class Serializer implements IIngredientSerializer { + public static final ForgeUnsealedIngredient.Serializer INSTANCE = new ForgeUnsealedIngredient.Serializer(); - @Override - public @NotNull ForgeUnsealedIngredient parse(FriendlyByteBuf buffer) { - return new ForgeUnsealedIngredient(buffer.readItem()); - } + @Override + public @NotNull ForgeUnsealedIngredient parse(FriendlyByteBuf buffer) { + return new ForgeUnsealedIngredient(buffer.readItem()); + } - @Override - public @NotNull ForgeUnsealedIngredient parse(@NotNull JsonObject json) { - return new ForgeUnsealedIngredient(CraftingHelper.getItemStack(json, true)); - } + @Override + public @NotNull ForgeUnsealedIngredient parse(@NotNull JsonObject json) { + return new ForgeUnsealedIngredient(CraftingHelper.getItemStack(json, true)); + } - @Override - public void write(FriendlyByteBuf buffer, ForgeUnsealedIngredient ingredient) { - buffer.writeItem(ingredient.stack); - } - } + @Override + public void write(FriendlyByteBuf buffer, ForgeUnsealedIngredient ingredient) { + buffer.writeItem(ingredient.stack); + } + } }