Rebase this onto the 1.0 branch
This commit is contained in:
parent
88218deed6
commit
61926ca299
180 changed files with 995 additions and 676 deletions
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.api.addldata;
|
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.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -10,19 +10,19 @@ public interface DataHolder {
|
||||||
CompoundTag readRawDatum();
|
CompoundTag readRawDatum();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default SpellDatum<?> readDatum(ServerLevel world) {
|
default LegacySpellDatum<?> readDatum(ServerLevel world) {
|
||||||
var tag = readRawDatum();
|
var tag = readRawDatum();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
return SpellDatum.fromNBT(tag, world);
|
return LegacySpellDatum.fromNBT(tag, world);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default SpellDatum<?> emptyDatum() {
|
default LegacySpellDatum<?> emptyDatum() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean writeDatum(@Nullable SpellDatum<?> datum, boolean simulate);
|
boolean writeDatum(@Nullable LegacySpellDatum<?> datum, boolean simulate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.api.addldata;
|
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 net.minecraft.server.level.ServerLevel;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ public interface HexHolder {
|
||||||
boolean hasHex();
|
boolean hasHex();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
List<SpellDatum<?>> getHex(ServerLevel level);
|
List<LegacySpellDatum<?>> getHex(ServerLevel level);
|
||||||
|
|
||||||
void writeHex(List<SpellDatum<?>> patterns, int mana);
|
void writeHex(List<LegacySpellDatum<?>> patterns, int mana);
|
||||||
|
|
||||||
void clearHex();
|
void clearHex();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||||
import at.petrak.hexcasting.api.misc.ManaConstants;
|
import at.petrak.hexcasting.api.misc.ManaConstants;
|
||||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||||
import at.petrak.hexcasting.api.spell.ParticleSpray;
|
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.CastingContext;
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellCircleContext;
|
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) {
|
if (bs.getBlock() instanceof BlockCircleComponent cc) {
|
||||||
var newPattern = cc.getPattern(tracked, bs, this.level);
|
var newPattern = cc.getPattern(tracked, bs, this.level);
|
||||||
if (newPattern != null) {
|
if (newPattern != null) {
|
||||||
var info = harness.executeIota(SpellDatum.make(newPattern), splayer.getLevel());
|
var info = harness.executeIota(LegacySpellDatum.make(newPattern), splayer.getLevel());
|
||||||
if (info.getMakesCastSound()) {
|
if (info.getMakesCastSound()) {
|
||||||
makeSound = true;
|
makeSound = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.api.item;
|
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 at.petrak.hexcasting.api.utils.NBTHelper;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -21,29 +21,34 @@ public interface DataHolderItem {
|
||||||
@Nullable CompoundTag readDatumTag(ItemStack stack);
|
@Nullable CompoundTag readDatumTag(ItemStack stack);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default SpellDatum<?> readDatum(ItemStack stack, ServerLevel world) {
|
default LegacySpellDatum<?> readDatum(ItemStack stack, ServerLevel world) {
|
||||||
var tag = readDatumTag(stack);
|
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) {
|
if (tag != null) {
|
||||||
return SpellDatum.fromNBT(tag, world);
|
return LegacySpellDatum.fromNBT(tag, world);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default SpellDatum<?> emptyDatum(ItemStack stack) {
|
default LegacySpellDatum<?> emptyDatum(ItemStack stack) {
|
||||||
return null;
|
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<Component> pTooltipComponents,
|
static void appendHoverText(DataHolderItem self, ItemStack pStack, List<Component> pTooltipComponents,
|
||||||
TooltipFlag pIsAdvanced) {
|
TooltipFlag pIsAdvanced) {
|
||||||
var datumTag = self.readDatumTag(pStack);
|
var datumTag = self.readDatumTag(pStack);
|
||||||
if (datumTag != null) {
|
if (datumTag != null) {
|
||||||
var component = SpellDatum.displayFromNBT(datumTag);
|
var component = LegacySpellDatum.displayFromNBT(datumTag);
|
||||||
pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component));
|
pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component));
|
||||||
|
|
||||||
if (pIsAdvanced.isAdvanced()) {
|
if (pIsAdvanced.isAdvanced()) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.api.item;
|
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.server.level.ServerLevel;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -14,9 +14,9 @@ public interface HexHolderItem extends ManaHolderItem {
|
||||||
boolean hasHex(ItemStack stack);
|
boolean hasHex(ItemStack stack);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
List<SpellDatum<?>> getHex(ItemStack stack, ServerLevel level);
|
List<LegacySpellDatum<?>> getHex(ItemStack stack, ServerLevel level);
|
||||||
|
|
||||||
void writeHex(ItemStack stack, List<SpellDatum<?>> patterns, int mana);
|
void writeHex(ItemStack stack, List<LegacySpellDatum<?>> patterns, int mana);
|
||||||
|
|
||||||
void clearHex(ItemStack stack);
|
void clearHex(ItemStack stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ interface ConstManaOperator : Operator {
|
||||||
val manaCost: Int
|
val manaCost: Int
|
||||||
get() = 0
|
get() = 0
|
||||||
|
|
||||||
fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>>
|
fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>>
|
||||||
|
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
|
||||||
if (this.argc > stack.size)
|
if (this.argc > stack.size)
|
||||||
throw MishapNotEnoughArgs(this.argc, stack.size)
|
throw MishapNotEnoughArgs(this.argc, stack.size)
|
||||||
val args = stack.takeLast(this.argc)
|
val args = stack.takeLast(this.argc)
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,7 +28,7 @@ import java.util.*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SpellDatum<T : Any> private constructor(val payload: T) {
|
class LegacySpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
val clazz: Class<T> = payload.javaClass
|
val clazz: Class<T> = payload.javaClass
|
||||||
|
|
||||||
fun serializeToNBT(): CompoundTag = this.serializeToNBTWithDepthCheck(0, 0)?.first
|
fun serializeToNBT(): CompoundTag = this.serializeToNBTWithDepthCheck(0, 0)?.first
|
||||||
|
@ -77,12 +77,12 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
override fun toString(): String =
|
override fun toString(): String =
|
||||||
buildString {
|
buildString {
|
||||||
append("SpellDatum[")
|
append("SpellDatum[")
|
||||||
append(this@SpellDatum.payload.toString())
|
append(this@LegacySpellDatum.payload.toString())
|
||||||
append(']')
|
append(']')
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return other is SpellDatum<*> && other.payload == payload
|
return other is LegacySpellDatum<*> && other.payload == payload
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
|
@ -111,18 +111,18 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
fun make(payload: Any): SpellDatum<*> =
|
fun make(payload: Any): LegacySpellDatum<*> =
|
||||||
if (payload is SpellDatum<*>) {
|
if (payload is LegacySpellDatum<*>) {
|
||||||
payload
|
payload
|
||||||
} else if (payload is List<*>) {
|
} else if (payload is List<*>) {
|
||||||
SpellDatum(SpellList.LList(0, payload.map {
|
LegacySpellDatum(SpellList.LList(0, payload.map {
|
||||||
when (it) {
|
when (it) {
|
||||||
null -> make(Widget.NULL)
|
null -> make(Widget.NULL)
|
||||||
else -> make(it)
|
else -> make(it)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
} else if (payload is Vec3) {
|
} else if (payload is Vec3) {
|
||||||
SpellDatum(
|
LegacySpellDatum(
|
||||||
Vec3(
|
Vec3(
|
||||||
fixNAN(payload.x),
|
fixNAN(payload.x),
|
||||||
fixNAN(payload.y),
|
fixNAN(payload.y),
|
||||||
|
@ -130,17 +130,17 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else if (isValidType(payload)) {
|
} else if (isValidType(payload)) {
|
||||||
SpellDatum(payload)
|
LegacySpellDatum(payload)
|
||||||
} else if (payload is java.lang.Double) {
|
} else if (payload is java.lang.Double) {
|
||||||
// Check to see if it's a java *boxed* double, for when we call this from Java
|
// Check to see if it's a java *boxed* double, for when we call this from Java
|
||||||
val num = payload.toDouble()
|
val num = payload.toDouble()
|
||||||
SpellDatum(fixNAN(num))
|
LegacySpellDatum(fixNAN(num))
|
||||||
} else {
|
} else {
|
||||||
throw MishapInvalidSpellDatumType(payload)
|
throw MishapInvalidSpellDatumType(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun fromNBT(nbt: CompoundTag, world: ServerLevel): SpellDatum<*> {
|
fun fromNBT(nbt: CompoundTag, world: ServerLevel): LegacySpellDatum<*> {
|
||||||
val keys = nbt.allKeys
|
val keys = nbt.allKeys
|
||||||
if (keys.size != 1)
|
if (keys.size != 1)
|
||||||
return SpellDatum(Widget.GARBAGE) // Invalid iota format
|
return SpellDatum(Widget.GARBAGE) // Invalid iota format
|
||||||
|
@ -151,18 +151,18 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
val uuid = subtag.getUUID(TAG_ENTITY_UUID) // and throw away name
|
val uuid = subtag.getUUID(TAG_ENTITY_UUID) // and throw away name
|
||||||
val entity = world.getEntity(uuid)
|
val entity = world.getEntity(uuid)
|
||||||
// If the entity died or something return Unit
|
// 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_DOUBLE -> LegacySpellDatum(nbt.getDouble(key))
|
||||||
TAG_VEC3 -> SpellDatum(vecFromNBT(nbt.getLongArray(key)))
|
TAG_VEC3 -> LegacySpellDatum(vecFromNBT(nbt.getLongArray(key)))
|
||||||
TAG_LIST -> {
|
TAG_LIST -> {
|
||||||
SpellDatum(SpellList.fromNBT(nbt.getList(key, Tag.TAG_COMPOUND), world))
|
LegacySpellDatum(SpellList.fromNBT(nbt.getList(key, Tag.TAG_COMPOUND), world))
|
||||||
}
|
}
|
||||||
TAG_WIDGET -> {
|
TAG_WIDGET -> {
|
||||||
SpellDatum(Widget.fromString(nbt.getString(key)))
|
LegacySpellDatum(Widget.fromString(nbt.getString(key)))
|
||||||
}
|
}
|
||||||
TAG_PATTERN -> {
|
TAG_PATTERN -> {
|
||||||
SpellDatum(HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN)))
|
LegacySpellDatum(HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN)))
|
||||||
}
|
}
|
||||||
else -> SpellDatum(Widget.GARBAGE) // Invalid iota type
|
else -> SpellDatum(Widget.GARBAGE) // Invalid iota type
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun fromNBT(nbt: CompoundTag, ctx: CastingContext): SpellDatum<*> =
|
fun fromNBT(nbt: CompoundTag, ctx: CastingContext): LegacySpellDatum<*> =
|
||||||
fromNBT(nbt, ctx.world)
|
fromNBT(nbt, ctx.world)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -282,7 +282,5 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
||||||
DatumType.OTHER, DatumType.EMPTY -> ""
|
DatumType.OTHER, DatumType.EMPTY -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,4 +6,4 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
/**
|
/**
|
||||||
* What happens when an operator is through?
|
* What happens when an operator is through?
|
||||||
*/
|
*/
|
||||||
data class OperationResult(val newContinuation: SpellContinuation, val newStack: List<SpellDatum<*>>, val newLocalIota: SpellDatum<*>, val sideEffects: List<OperatorSideEffect>)
|
data class OperationResult(val newContinuation: SpellContinuation, val newStack: List<LegacySpellDatum<*>>, val newLocalIota: LegacySpellDatum<*>, val sideEffects: List<OperatorSideEffect>)
|
||||||
|
|
|
@ -21,7 +21,7 @@ interface Operator {
|
||||||
*
|
*
|
||||||
* A particle effect at the cast site and various messages and advancements are done automagically.
|
* A particle effect at the cast site and various messages and advancements are done automagically.
|
||||||
*/
|
*/
|
||||||
fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult
|
fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do you need to be enlightened to use this operator? (i.e. is this operator a Great Pattern)
|
* 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))
|
origin.add(look.normalize().scale(MAX_DISTANCE))
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun makeConstantOp(x: SpellDatum<*>): Operator = object : ConstManaOperator {
|
fun makeConstantOp(x: LegacySpellDatum<*>): Operator = object : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 0
|
get() = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> =
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
|
||||||
listOf(x)
|
listOf(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.world.entity.Entity
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
fun numOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
|
fun numOrVec(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
|
||||||
when (datum.payload) {
|
when (datum.payload) {
|
||||||
is Double -> Either.left(datum.payload)
|
is Double -> Either.left(datum.payload)
|
||||||
is Vec3 -> Either.right(datum.payload)
|
is Vec3 -> Either.right(datum.payload)
|
||||||
|
@ -24,7 +24,7 @@ fun numOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun numOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, SpellList> =
|
fun numOrList(datum: LegacySpellDatum<*>, reverseIdx: Int): Either<Double, SpellList> =
|
||||||
when (datum.payload) {
|
when (datum.payload) {
|
||||||
is Double -> Either.left(datum.payload)
|
is Double -> Either.left(datum.payload)
|
||||||
is SpellList -> Either.right(datum.payload)
|
is SpellList -> Either.right(datum.payload)
|
||||||
|
@ -35,15 +35,15 @@ fun numOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, SpellList>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun spellListOf(vararg vs: Any): List<SpellDatum<*>> {
|
fun spellListOf(vararg vs: Any): List<LegacySpellDatum<*>> {
|
||||||
val out = ArrayList<SpellDatum<*>>(vs.size)
|
val out = ArrayList<LegacySpellDatum<*>>(vs.size)
|
||||||
for (v in vs) {
|
for (v in vs) {
|
||||||
out.add(SpellDatum.make(v))
|
out.add(LegacySpellDatum.make(v))
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : Any> List<SpellDatum<*>>.getChecked(idx: Int, argc: Int = 0): T {
|
inline fun <reified T : Any> List<LegacySpellDatum<*>>.getChecked(idx: Int, argc: Int = 0): T {
|
||||||
val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
|
val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
|
||||||
if (x.payload is T)
|
if (x.payload is T)
|
||||||
return x.payload
|
return x.payload
|
||||||
|
@ -57,7 +57,7 @@ inline val Double.asSpellResult get() = spellListOf(this)
|
||||||
inline val Number.asSpellResult get() = spellListOf(this.toDouble())
|
inline val Number.asSpellResult get() = spellListOf(this.toDouble())
|
||||||
|
|
||||||
inline val SpellList.asSpellResult get() = spellListOf(this)
|
inline val SpellList.asSpellResult get() = spellListOf(this)
|
||||||
inline val List<SpellDatum<*>>.asSpellResult get() = spellListOf(this)
|
inline val List<LegacySpellDatum<*>>.asSpellResult get() = spellListOf(this)
|
||||||
|
|
||||||
inline val Widget.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 {
|
private fun Any.tolerantEquals(other: Any, recursionsLeft: Int): Boolean {
|
||||||
return when {
|
return when {
|
||||||
this is SpellDatum<*> && other is SpellDatum<*> -> this.payload.tolerantEquals(other.payload, recursionsLeft)
|
this is LegacySpellDatum<*> && other is LegacySpellDatum<*> -> this.payload.tolerantEquals(other.payload, recursionsLeft)
|
||||||
this is SpellDatum<*> -> this.payload.tolerantEquals(other, recursionsLeft)
|
this is LegacySpellDatum<*> -> this.payload.tolerantEquals(other, recursionsLeft)
|
||||||
other is SpellDatum<*> -> this.tolerantEquals(other.payload, recursionsLeft)
|
other is LegacySpellDatum<*> -> this.tolerantEquals(other.payload, recursionsLeft)
|
||||||
|
|
||||||
this is HexPattern && other is HexPattern -> this.angles == other.angles
|
this is HexPattern && other is HexPattern -> this.angles == other.angles
|
||||||
this is Double && other is Double -> abs(this - other) < TOLERANCE
|
this is Double && other is Double -> abs(this - other) < TOLERANCE
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
package at.petrak.hexcasting.api.spell
|
package at.petrak.hexcasting.api.spell
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag
|
import at.petrak.hexcasting.api.spell.datum.SpellDatum
|
||||||
import net.minecraft.nbt.ListTag
|
|
||||||
import net.minecraft.server.level.ServerLevel
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restricted interface for functional lists.
|
* Restricted interface for functional lists.
|
||||||
*
|
*
|
||||||
* ...Surely this won't have any performance implications.
|
* ...Surely this won't have any performance implications.
|
||||||
*/
|
*/
|
||||||
sealed class SpellList : Iterable<SpellDatum<*>> {
|
sealed class SpellList : Iterable<SpellDatum> {
|
||||||
|
|
||||||
abstract val nonEmpty: Boolean
|
abstract val nonEmpty: Boolean
|
||||||
abstract val car: SpellDatum<*>
|
abstract val car: SpellDatum
|
||||||
abstract val cdr: SpellList
|
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
|
override val nonEmpty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
class LList(val idx: Int, val list: List<SpellDatum<*>>) : SpellList() {
|
class LList(val idx: Int, val list: List<SpellDatum>) : SpellList() {
|
||||||
override val nonEmpty: Boolean
|
override val nonEmpty: Boolean
|
||||||
get() = idx < list.size
|
get() = idx < list.size
|
||||||
override val car: SpellDatum<*>
|
override val car: SpellDatum
|
||||||
get() = list[idx]
|
get() = list[idx]
|
||||||
override val cdr: SpellList
|
override val cdr: SpellList
|
||||||
get() = LList(idx + 1, list)
|
get() = LList(idx + 1, list)
|
||||||
|
|
||||||
|
constructor(list: List<SpellDatum>) : this(0, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun modifyAt(startIdx: Int, modify: (SpellList) -> SpellList): SpellList {
|
fun modifyAt(startIdx: Int, modify: (SpellList) -> SpellList): SpellList {
|
||||||
val stack = mutableListOf<SpellDatum<*>>()
|
val stack = mutableListOf<SpellDatum>()
|
||||||
val ptr = iterator()
|
val ptr = iterator()
|
||||||
var idx = startIdx
|
var idx = startIdx
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -49,7 +49,7 @@ sealed class SpellList : Iterable<SpellDatum<*>> {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAt(startIdx: Int): SpellDatum<*> {
|
fun getAt(startIdx: Int): SpellDatum {
|
||||||
var ptr = this
|
var ptr = this
|
||||||
var idx = startIdx
|
var idx = startIdx
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -69,24 +69,12 @@ sealed class SpellList : Iterable<SpellDatum<*>> {
|
||||||
|
|
||||||
override fun iterator() = SpellListIterator(this)
|
override fun iterator() = SpellListIterator(this)
|
||||||
|
|
||||||
class SpellListIterator(var list: SpellList) : Iterator<SpellDatum<*>> {
|
class SpellListIterator(var list: SpellList) : Iterator<SpellDatum> {
|
||||||
override fun hasNext() = list.nonEmpty
|
override fun hasNext() = list.nonEmpty
|
||||||
override operator fun next(): SpellDatum<*> {
|
override operator fun next(): SpellDatum {
|
||||||
val car = list.car
|
val car = list.car
|
||||||
list = list.cdr
|
list = list.cdr
|
||||||
return car
|
return car
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic
|
|
||||||
fun fromNBT(nbt: ListTag, world: ServerLevel): LList {
|
|
||||||
val out = ArrayList<SpellDatum<*>>(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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ interface SpellOperator : Operator {
|
||||||
fun awardsCastingStat(ctx: CastingContext): Boolean = true
|
fun awardsCastingStat(ctx: CastingContext): Boolean = true
|
||||||
|
|
||||||
fun execute(
|
fun execute(
|
||||||
args: List<SpellDatum<*>>,
|
args: List<LegacySpellDatum<*>>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>?
|
): Triple<RenderedSpell, Int, List<ParticleSpray>>?
|
||||||
|
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
|
||||||
if (this.argc > stack.size)
|
if (this.argc > stack.size)
|
||||||
throw MishapNotEnoughArgs(this.argc, stack.size)
|
throw MishapNotEnoughArgs(this.argc, stack.size)
|
||||||
val args = stack.takeLast(this.argc)
|
val args = stack.takeLast(this.argc)
|
||||||
|
|
|
@ -16,7 +16,7 @@ enum class Widget : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 0
|
get() = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> =
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
|
||||||
this.asSpellResult
|
this.asSpellResult
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import at.petrak.hexcasting.api.mod.HexConfig
|
||||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||||
import at.petrak.hexcasting.api.mod.HexStatistics
|
import at.petrak.hexcasting.api.mod.HexStatistics
|
||||||
import at.petrak.hexcasting.api.spell.*
|
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.HexDir
|
||||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.*
|
import at.petrak.hexcasting.api.spell.mishaps.*
|
||||||
|
@ -27,10 +28,10 @@ import kotlin.math.min
|
||||||
* It's stored as NBT on the wand.
|
* It's stored as NBT on the wand.
|
||||||
*/
|
*/
|
||||||
class CastingHarness private constructor(
|
class CastingHarness private constructor(
|
||||||
var stack: MutableList<SpellDatum<*>>,
|
var stack: MutableList<LegacySpellDatum<*>>,
|
||||||
var localIota: SpellDatum<*>,
|
var localIota: LegacySpellDatum<*>,
|
||||||
var parenCount: Int,
|
var parenCount: Int,
|
||||||
var parenthesized: List<SpellDatum<*>>,
|
var parenthesized: List<LegacySpellDatum<*>>,
|
||||||
var escapeNext: Boolean,
|
var escapeNext: Boolean,
|
||||||
val ctx: CastingContext,
|
val ctx: CastingContext,
|
||||||
val prepackagedColorizer: FrozenColorizer? // for trinkets with colorizers
|
val prepackagedColorizer: FrozenColorizer? // for trinkets with colorizers
|
||||||
|
@ -40,17 +41,17 @@ class CastingHarness private constructor(
|
||||||
constructor(
|
constructor(
|
||||||
ctx: CastingContext,
|
ctx: CastingContext,
|
||||||
prepackagedColorizer: FrozenColorizer? = null
|
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.
|
* 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.
|
* Given a list of iotas, execute them in sequence.
|
||||||
*/
|
*/
|
||||||
fun executeIotas(iotas: List<SpellDatum<*>>, world: ServerLevel): ControllerInfo {
|
fun executeIotas(iotas: List<LegacySpellDatum<*>>, world: ServerLevel): ControllerInfo {
|
||||||
// Initialize the continuation stack to a single top-level eval for all iotas.
|
// Initialize the continuation stack to a single top-level eval for all iotas.
|
||||||
var continuation = SpellContinuation.Done.pushFrame(ContinuationFrame.Evaluate(SpellList.LList(0, iotas)))
|
var continuation = SpellContinuation.Done.pushFrame(ContinuationFrame.Evaluate(SpellList.LList(0, iotas)))
|
||||||
// Begin aggregating info
|
// 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 {
|
try {
|
||||||
this.handleParentheses(iota)?.let { (data, resolutionType) ->
|
this.handleParentheses(iota)?.let { (data, resolutionType) ->
|
||||||
return@getUpdate CastResult(continuation, data, resolutionType, listOf())
|
return@getUpdate CastResult(continuation, data, resolutionType, listOf())
|
||||||
|
@ -150,7 +151,7 @@ class CastingHarness private constructor(
|
||||||
val unenlightened = pattern.isGreat && !ctx.isCasterEnlightened
|
val unenlightened = pattern.isGreat && !ctx.isCasterEnlightened
|
||||||
|
|
||||||
val sideEffects = mutableListOf<OperatorSideEffect>()
|
val sideEffects = mutableListOf<OperatorSideEffect>()
|
||||||
var stack2: List<SpellDatum<*>>? = null
|
var stack2: List<LegacySpellDatum<*>>? = null
|
||||||
var cont2 = continuation
|
var cont2 = continuation
|
||||||
|
|
||||||
if (!unenlightened || pattern.alwaysProcessGreatSpell) {
|
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`)
|
* 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,
|
* 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.
|
* either escaping it onto the stack or changing the parenthese-handling state.
|
||||||
*/
|
*/
|
||||||
private fun handleParentheses(iota: SpellDatum<*>): Pair<FunctionalData, ResolvedPatternType>? {
|
private fun handleParentheses(iota: LegacySpellDatum<*>): Pair<FunctionalData, ResolvedPatternType>? {
|
||||||
val operator = (iota.payload as? HexPattern)?.let {
|
val operator = (iota.payload as? HexPattern)?.let {
|
||||||
try {
|
try {
|
||||||
PatternRegistry.matchPattern(it, this.ctx.world)
|
PatternRegistry.matchPattern(it, this.ctx.world)
|
||||||
|
@ -297,7 +298,7 @@ class CastingHarness private constructor(
|
||||||
val newParenCount = this.parenCount - 1
|
val newParenCount = this.parenCount - 1
|
||||||
if (newParenCount == 0) {
|
if (newParenCount == 0) {
|
||||||
val newStack = this.stack.toMutableList()
|
val newStack = this.stack.toMutableList()
|
||||||
newStack.add(SpellDatum.make(this.parenthesized.toList()))
|
newStack.add(LegacySpellDatum.make(this.parenthesized.toList()))
|
||||||
this.getFunctionalData().copy(
|
this.getFunctionalData().copy(
|
||||||
stack = newStack,
|
stack = newStack,
|
||||||
parenCount = newParenCount,
|
parenCount = newParenCount,
|
||||||
|
@ -457,26 +458,26 @@ class CastingHarness private constructor(
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness {
|
fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness {
|
||||||
return try {
|
return try {
|
||||||
val stack = mutableListOf<SpellDatum<*>>()
|
val stack = mutableListOf<LegacySpellDatum<*>>()
|
||||||
val stackTag = nbt.getList(TAG_STACK, Tag.TAG_COMPOUND)
|
val stackTag = nbt.getList(TAG_STACK, Tag.TAG_COMPOUND)
|
||||||
for (subtag in stackTag) {
|
for (subtag in stackTag) {
|
||||||
val datum = SpellDatum.fromNBT(subtag.asCompound, ctx.world)
|
val datum = LegacySpellDatum.fromNBT(subtag.asCompound, ctx.world)
|
||||||
stack.add(datum)
|
stack.add(datum)
|
||||||
}
|
}
|
||||||
|
|
||||||
val localTag = nbt.getCompound(TAG_LOCAL)
|
val localTag = nbt.getCompound(TAG_LOCAL)
|
||||||
val localIota =
|
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
|
Widget.NULL
|
||||||
)
|
)
|
||||||
|
|
||||||
val parenthesized = mutableListOf<SpellDatum<*>>()
|
val parenthesized = mutableListOf<LegacySpellDatum<*>>()
|
||||||
val parenTag = nbt.getList(TAG_PARENTHESIZED, Tag.TAG_COMPOUND)
|
val parenTag = nbt.getList(TAG_PARENTHESIZED, Tag.TAG_COMPOUND)
|
||||||
for (subtag in parenTag) {
|
for (subtag in parenTag) {
|
||||||
if (subtag.asCompound.size() != 1)
|
if (subtag.asCompound.size() != 1)
|
||||||
parenthesized.add(SpellDatum.make(HexPattern.fromNBT(subtag.asCompound)))
|
parenthesized.add(LegacySpellDatum.make(HexPattern.fromNBT(subtag.asCompound)))
|
||||||
else
|
else
|
||||||
parenthesized.add(SpellDatum.fromNBT(subtag.asCompound, ctx.world))
|
parenthesized.add(LegacySpellDatum.fromNBT(subtag.asCompound, ctx.world))
|
||||||
}
|
}
|
||||||
|
|
||||||
val parenCount = nbt.getInt(TAG_PAREN_COUNT)
|
val parenCount = nbt.getInt(TAG_PAREN_COUNT)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package at.petrak.hexcasting.api.spell.casting
|
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.SpellList
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult
|
import at.petrak.hexcasting.api.spell.casting.CastingHarness.CastResult
|
||||||
import at.petrak.hexcasting.api.utils.NBTBuilder
|
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.
|
* 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)
|
* @return whether the break should stop here, alongside the new stack state (e.g. for finalizing a Thoth)
|
||||||
*/
|
*/
|
||||||
fun breakDownwards(stack: List<SpellDatum<*>>): Pair<Boolean, List<SpellDatum<*>>>
|
fun breakDownwards(stack: List<LegacySpellDatum<*>>): Pair<Boolean, List<LegacySpellDatum<*>>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes this frame. Used for things like delays, where we pause execution.
|
* 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 {
|
data class Evaluate(val list: SpellList) : ContinuationFrame {
|
||||||
// Discard this frame and keep discarding frames.
|
// Discard this frame and keep discarding frames.
|
||||||
override fun breakDownwards(stack: List<SpellDatum<*>>) = false to stack
|
override fun breakDownwards(stack: List<LegacySpellDatum<*>>) = false to stack
|
||||||
|
|
||||||
// Step the list of patterns, evaluating a single one.
|
// Step the list of patterns, evaluating a single one.
|
||||||
override fun evaluate(
|
override fun evaluate(
|
||||||
|
@ -83,7 +83,7 @@ sealed interface ContinuationFrame {
|
||||||
*/
|
*/
|
||||||
object FinishEval : ContinuationFrame {
|
object FinishEval : ContinuationFrame {
|
||||||
// Don't do anything else to the stack, just finish the halt statement.
|
// Don't do anything else to the stack, just finish the halt statement.
|
||||||
override fun breakDownwards(stack: List<SpellDatum<*>>) = true to stack
|
override fun breakDownwards(stack: List<LegacySpellDatum<*>>) = true to stack
|
||||||
|
|
||||||
// Evaluating it does nothing; it's only a boundary condition.
|
// Evaluating it does nothing; it's only a boundary condition.
|
||||||
override fun evaluate(
|
override fun evaluate(
|
||||||
|
@ -116,15 +116,15 @@ sealed interface ContinuationFrame {
|
||||||
data class ForEach(
|
data class ForEach(
|
||||||
val data: SpellList,
|
val data: SpellList,
|
||||||
val code: SpellList,
|
val code: SpellList,
|
||||||
val baseStack: List<SpellDatum<*>>?,
|
val baseStack: List<LegacySpellDatum<*>>?,
|
||||||
val acc: MutableList<SpellDatum<*>>
|
val acc: MutableList<LegacySpellDatum<*>>
|
||||||
) : ContinuationFrame {
|
) : ContinuationFrame {
|
||||||
|
|
||||||
/** When halting, we add the stack state at halt to the stack accumulator, then return the original pre-Thoth stack, plus the accumulator. */
|
/** 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<SpellDatum<*>>): Pair<Boolean, List<SpellDatum<*>>> {
|
override fun breakDownwards(stack: List<LegacySpellDatum<*>>): Pair<Boolean, List<LegacySpellDatum<*>>> {
|
||||||
val newStack = baseStack?.toMutableList() ?: mutableListOf()
|
val newStack = baseStack?.toMutableList() ?: mutableListOf()
|
||||||
acc.addAll(stack)
|
acc.addAll(stack)
|
||||||
newStack.add(SpellDatum.make(acc))
|
newStack.add(LegacySpellDatum.make(acc))
|
||||||
return true to newStack
|
return true to newStack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ sealed interface ContinuationFrame {
|
||||||
.pushFrame(Evaluate(code))
|
.pushFrame(Evaluate(code))
|
||||||
} else {
|
} else {
|
||||||
// Else, dump our final list onto the stack.
|
// Else, dump our final list onto the stack.
|
||||||
SpellDatum.make(acc) to continuation
|
LegacySpellDatum.make(acc) to continuation
|
||||||
}
|
}
|
||||||
val tStack = stack.toMutableList()
|
val tStack = stack.toMutableList()
|
||||||
tStack.add(stackTop)
|
tStack.add(stackTop)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package at.petrak.hexcasting.api.spell.casting
|
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.
|
* A change to the data in a CastHarness after a pattern is drawn.
|
||||||
*/
|
*/
|
||||||
data class FunctionalData(
|
data class FunctionalData(
|
||||||
val stack: List<SpellDatum<*>>,
|
val stack: List<LegacySpellDatum<*>>,
|
||||||
val parenCount: Int,
|
val parenCount: Int,
|
||||||
val parenthesized: List<SpellDatum<*>>,
|
val parenthesized: List<LegacySpellDatum<*>>,
|
||||||
val escapeNext: Boolean,
|
val escapeNext: Boolean,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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<DatumDouble> 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -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<DatumEntity> 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;
|
||||||
|
}
|
||||||
|
};
|
|
@ -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 <i>wrapper</i> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.
|
||||||
|
* <p>
|
||||||
|
* Don't call this directly; use {@link SpellDatums#equalsWithTolerance}.
|
||||||
|
*/
|
||||||
|
abstract public boolean equalsOther(SpellDatum that);
|
||||||
|
|
||||||
|
|
||||||
|
abstract public @NotNull Tag serialize();
|
||||||
|
|
||||||
|
public interface Type<T extends SpellDatum> {
|
||||||
|
/**
|
||||||
|
* Spell datums are stored as such: {@code { "type": "modid:type", "datum": a_tag }}.
|
||||||
|
* <p>
|
||||||
|
* The {@code type} key is given when registering the spell datum type; this method
|
||||||
|
* deserializes the tag associated with {@code "datum"}.
|
||||||
|
* <p>
|
||||||
|
* 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, <i>without</i> the world.
|
||||||
|
* This is for use on the client.
|
||||||
|
*/
|
||||||
|
Component display(Tag tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the color associated with this datum type.
|
||||||
|
*/
|
||||||
|
int color();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<ResourceLocation, SpellDatum.Type<?>> 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<SpellDatum>();
|
||||||
|
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");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.spell.mishaps
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
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.
|
* You can also mess up the stack with this.
|
||||||
*/
|
*/
|
||||||
abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>)
|
abstract fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>)
|
||||||
|
|
||||||
abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component
|
abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
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.ParticleSpray
|
||||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import net.minecraft.world.entity.npc.Villager
|
import net.minecraft.world.entity.npc.Villager
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
@ -12,8 +12,8 @@ class MishapAlreadyBrainswept(val villager: Villager) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.GREEN)
|
dyeColor(DyeColor.GREEN)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun particleSpray(ctx: CastingContext) =
|
override fun particleSpray(ctx: CastingContext) =
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||||
import net.minecraft.core.BlockPos
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.LIME)
|
dyeColor(DyeColor.LIME)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
|
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.spell.mishaps
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
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.CastingContext
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.world.entity.npc.Villager
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.GREEN)
|
dyeColor(DyeColor.GREEN)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||||
import net.minecraft.network.chat.Component
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BROWN)
|
dyeColor(DyeColor.BROWN)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05)
|
item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||||
import net.minecraft.network.chat.Component
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BROWN)
|
dyeColor(DyeColor.BROWN)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
yeetHeldItem(ctx, hand)
|
yeetHeldItem(ctx, hand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||||
import net.minecraft.world.item.DyeColor
|
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 resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
// NO-OP
|
// NO-OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
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.Widget
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.RED)
|
dyeColor(DyeColor.RED)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
|
||||||
trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2)
|
trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun powerOf(datum: Any) = when (datum) {
|
fun powerOf(datum: Any) = when (datum) {
|
||||||
0.0 -> zerothPower
|
0.0 -> zerothPower
|
||||||
else -> powerOf(SpellDatum.make(datum).display())
|
else -> powerOf(LegacySpellDatum.make(datum).display())
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun translate(datum: Any): Component = when (datum) {
|
fun translate(datum: Any): Component = when (datum) {
|
||||||
0.0 -> zero
|
0.0 -> zero
|
||||||
Vec3.ZERO -> zeroVector
|
Vec3.ZERO -> zeroVector
|
||||||
else -> SpellDatum.make(datum).display()
|
else -> LegacySpellDatum.make(datum).display()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
|
@ -10,10 +11,11 @@ class MishapEntityTooFarAway(val entity: Entity) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.PINK)
|
dyeColor(DyeColor.PINK)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
|
// Knock the player's items out of their hands
|
||||||
yeetHeldItemsTowards(ctx, entity.position())
|
yeetHeldItemsTowards(ctx, entity.position())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||||
error("entity_too_far", SpellDatum.make(entity).display(), actionName(errorCtx.action))
|
error("entity_too_far", LegacySpellDatum.make(entity).display(), actionName(errorCtx.action))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class MishapError(val exception: Exception) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BLACK)
|
dyeColor(DyeColor.BLACK)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
// NO-OP
|
// NO-OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class MishapEvalTooDeep : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BLUE)
|
dyeColor(DyeColor.BLUE)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
ctx.caster.airSupply -= 290
|
ctx.caster.airSupply -= 290
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
@ -10,7 +10,7 @@ class MishapImmuneEntity(val entity: Entity) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BLUE)
|
dyeColor(DyeColor.BLUE)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
yeetHeldItemsTowards(ctx, entity.position())
|
yeetHeldItemsTowards(ctx, entity.position())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.SpellList
|
||||||
import at.petrak.hexcasting.api.spell.Widget
|
import at.petrak.hexcasting.api.spell.Widget
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
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.
|
* [MishapInvalidIota.reverseIdx] is the index from the *back* of the stack.
|
||||||
*/
|
*/
|
||||||
class MishapInvalidIota(
|
class MishapInvalidIota(
|
||||||
val perpetrator: SpellDatum<*>,
|
val perpetrator: LegacySpellDatum<*>,
|
||||||
val reverseIdx: Int,
|
val reverseIdx: Int,
|
||||||
val expected: Component
|
val expected: Component
|
||||||
) : Mishap() {
|
) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.GRAY)
|
dyeColor(DyeColor.GRAY)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
stack[stack.size - 1 - reverseIdx] = SpellDatum.make(Widget.GARBAGE)
|
stack[stack.size - 1 - reverseIdx] = LegacySpellDatum.make(Widget.GARBAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
@ -39,7 +39,7 @@ class MishapInvalidIota(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@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 {
|
val key = "hexcasting.mishap.invalid_value.class." + when {
|
||||||
Double::class.java.isAssignableFrom(cls) || Double::class.javaObjectType.isAssignableFrom(cls) -> "double"
|
Double::class.java.isAssignableFrom(cls) || Double::class.javaObjectType.isAssignableFrom(cls) -> "double"
|
||||||
Vec3::class.java.isAssignableFrom(cls) -> "vector"
|
Vec3::class.java.isAssignableFrom(cls) -> "vector"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.Widget
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||||
|
@ -13,8 +13,8 @@ class MishapInvalidPattern : Mishap() {
|
||||||
|
|
||||||
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
|
override fun resolutionType(ctx: CastingContext) = ResolvedPatternType.INVALID
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.Util
|
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,10 +12,8 @@ class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BLACK)
|
dyeColor(DyeColor.BLACK)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
// Send it twice, just to make it clear
|
// NO-OP
|
||||||
val msg = this.errorMessage(ctx, errorCtx)
|
|
||||||
ctx.caster.sendMessage(msg, Util.NIL_UUID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.Widget
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
|
@ -11,11 +12,13 @@ class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mi
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.MAGENTA)
|
dyeColor(DyeColor.MAGENTA)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
stack.add(LegacySpellDatum.make(Widget.GARBAGE))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||||
error("wrong_dimension", actionName(errorCtx.action), properDimension.toString(),
|
error(
|
||||||
ctx.world.dimension().location().toString())
|
"wrong_dimension", actionName(errorCtx.action!!), properDimension.toString(),
|
||||||
|
ctx.world.dimension().location().toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
import net.minecraft.world.phys.Vec3
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.MAGENTA)
|
dyeColor(DyeColor.MAGENTA)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
yeetHeldItemsTowards(ctx, location)
|
yeetHeldItemsTowards(ctx, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||||
error("location_$type", SpellDatum.make(location).display(), actionName(errorCtx.action))
|
error("location_$type", LegacySpellDatum.make(location).display(), actionName(errorCtx.action!!))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
@ -10,7 +10,7 @@ class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.PURPLE)
|
dyeColor(DyeColor.PURPLE)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
ctx.caster.giveExperiencePoints(-100)
|
ctx.caster.giveExperiencePoints(-100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class MishapNoSpellCircle : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.LIGHT_BLUE)
|
dyeColor(DyeColor.LIGHT_BLUE)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
ctx.caster.inventory.dropAll()
|
ctx.caster.inventory.dropAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
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.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.network.chat.Component
|
||||||
import net.minecraft.world.item.DyeColor
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.LIGHT_GRAY)
|
dyeColor(DyeColor.LIGHT_GRAY)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
for (i in got until expected)
|
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) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.SpellList
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
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.MobEffectInstance
|
||||||
import net.minecraft.world.effect.MobEffects
|
import net.minecraft.world.effect.MobEffects
|
||||||
import net.minecraft.world.entity.player.Player
|
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 =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.BLACK)
|
dyeColor(DyeColor.BLACK)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60))
|
ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,14 +22,14 @@ class MishapOthersName(val other: Player) : Mishap() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getTrueNameFromDatum(datum: SpellDatum<*>, caster: Player): Player? {
|
fun getTrueNameFromDatum(datum: LegacySpellDatum<*>, caster: Player): Player? {
|
||||||
if (datum.payload is Player && datum.payload != caster)
|
if (datum.payload is Player && datum.payload != caster)
|
||||||
return datum.payload
|
return datum.payload
|
||||||
else if (datum.payload !is SpellList)
|
else if (datum.payload !is SpellList)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
val poolToSearch: MutableList<SpellDatum<*>> =
|
val poolToSearch: MutableList<LegacySpellDatum<*>> =
|
||||||
datum.payload.filterIsInstance<SpellDatum<*>>().toMutableList()
|
datum.payload.filterIsInstance<LegacySpellDatum<*>>().toMutableList()
|
||||||
|
|
||||||
while (poolToSearch.isNotEmpty()) {
|
while (poolToSearch.isNotEmpty()) {
|
||||||
val datumToCheck = poolToSearch[0]
|
val datumToCheck = poolToSearch[0]
|
||||||
|
@ -39,14 +38,14 @@ class MishapOthersName(val other: Player) : Mishap() {
|
||||||
if (datumToCheck.payload is Player && datumToCheck.payload != caster)
|
if (datumToCheck.payload is Player && datumToCheck.payload != caster)
|
||||||
return datumToCheck.payload
|
return datumToCheck.payload
|
||||||
else if (datumToCheck.payload is SpellList)
|
else if (datumToCheck.payload is SpellList)
|
||||||
poolToSearch.addAll(datumToCheck.payload.filterIsInstance<SpellDatum<*>>())
|
poolToSearch.addAll(datumToCheck.payload.filterIsInstance<LegacySpellDatum<*>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getTrueNameFromArgs(datums: List<SpellDatum<*>>, caster: Player): Player? {
|
fun getTrueNameFromArgs(datums: List<LegacySpellDatum<*>>, caster: Player): Player? {
|
||||||
return datums.firstNotNullOfOrNull { getTrueNameFromDatum(it, caster) }
|
return datums.firstNotNullOfOrNull { getTrueNameFromDatum(it, caster) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
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.CastingContext
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
|
@ -10,8 +10,8 @@ class MishapTooManyCloseParens : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.ORANGE)
|
dyeColor(DyeColor.ORANGE)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
stack.add(SpellDatum.make(errorCtx.pattern))
|
stack.add(LegacySpellDatum.make(errorCtx.pattern))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package at.petrak.hexcasting.api.spell.mishaps
|
package at.petrak.hexcasting.api.spell.mishaps
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||||
import at.petrak.hexcasting.api.spell.DatumType
|
import at.petrak.hexcasting.api.spell.LegacySpellDatum
|
||||||
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.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import net.minecraft.world.item.DyeColor
|
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.
|
* The value was a naked iota without being Considered or Retrospected.
|
||||||
*/
|
*/
|
||||||
class MishapUnescapedValue(
|
class MishapUnescapedValue(
|
||||||
val perpetrator: SpellDatum<*>
|
val perpetrator: LegacySpellDatum<*>
|
||||||
) : Mishap() {
|
) : Mishap() {
|
||||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||||
dyeColor(DyeColor.GRAY)
|
dyeColor(DyeColor.GRAY)
|
||||||
|
|
||||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<LegacySpellDatum<*>>) {
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }
|
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
val list = stack[idx].payload as SpellList
|
val list = stack[idx].payload as SpellList
|
||||||
|
@ -28,6 +27,7 @@ class MishapUnescapedValue(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package at.petrak.hexcasting.api.utils
|
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.SpellList
|
||||||
import at.petrak.hexcasting.api.spell.math.HexCoord
|
import at.petrak.hexcasting.api.spell.math.HexCoord
|
||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
|
@ -88,7 +88,7 @@ fun pxToCoord(px: Vec2, size: Float, offset: Vec2): HexCoord {
|
||||||
else
|
else
|
||||||
HexCoord(q, r + (rf + 0.5 * qf).roundToInt())
|
HexCoord(q, r + (rf + 0.5 * qf).roundToInt())
|
||||||
}
|
}
|
||||||
|
s
|
||||||
fun String.withStyle(op: (Style) -> Style): MutableComponent = asTextComponent.withStyle(op)
|
fun String.withStyle(op: (Style) -> Style): MutableComponent = asTextComponent.withStyle(op)
|
||||||
fun String.withStyle(style: Style): MutableComponent = asTextComponent.withStyle(style)
|
fun String.withStyle(style: Style): MutableComponent = asTextComponent.withStyle(style)
|
||||||
fun String.withStyle(formatting: ChatFormatting): MutableComponent = asTextComponent.withStyle(formatting)
|
fun String.withStyle(formatting: ChatFormatting): MutableComponent = asTextComponent.withStyle(formatting)
|
||||||
|
@ -234,12 +234,12 @@ inline operator fun <T> WeakValue<T>.setValue(thisRef: Any?, property: KProperty
|
||||||
/**
|
/**
|
||||||
* Returns an empty list if it's too complicated.
|
* Returns an empty list if it's too complicated.
|
||||||
*/
|
*/
|
||||||
fun Iterable<SpellDatum<*>>.serializeToNBT(): ListTag {
|
fun Iterable<LegacySpellDatum<*>>.serializeToNBT(): ListTag {
|
||||||
val out = SpellDatum.make(SpellList.LList(0, this.toList())).serializeToNBT()
|
val out = LegacySpellDatum.make(SpellList.LList(0, this.toList())).serializeToNBT()
|
||||||
return if (out.contains(SpellDatum.TAG_WIDGET))
|
return if (out.contains(LegacySpellDatum.TAG_WIDGET))
|
||||||
ListTag()
|
ListTag()
|
||||||
else
|
else
|
||||||
out.getList(SpellDatum.TAG_LIST, Tag.TAG_COMPOUND)
|
out.getList(LegacySpellDatum.TAG_LIST, Tag.TAG_COMPOUND)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the impl from forge
|
// Copy the impl from forge
|
||||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
|
||||||
import at.petrak.hexcasting.api.item.DataHolderItem;
|
import at.petrak.hexcasting.api.item.DataHolderItem;
|
||||||
import at.petrak.hexcasting.api.item.ManaHolderItem;
|
import at.petrak.hexcasting.api.item.ManaHolderItem;
|
||||||
import at.petrak.hexcasting.api.misc.ManaConstants;
|
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.spell.Widget;
|
||||||
import at.petrak.hexcasting.api.utils.NBTHelper;
|
import at.petrak.hexcasting.api.utils.NBTHelper;
|
||||||
import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer;
|
import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer;
|
||||||
|
@ -266,17 +266,17 @@ public class RegisterClientStuff {
|
||||||
}
|
}
|
||||||
|
|
||||||
return typename == null ? 0f : switch (typename) {
|
return typename == null ? 0f : switch (typename) {
|
||||||
case SpellDatum.TAG_ENTITY -> 1f;
|
case LegacySpellDatum.TAG_ENTITY -> 1f;
|
||||||
case SpellDatum.TAG_DOUBLE -> 2f;
|
case LegacySpellDatum.TAG_DOUBLE -> 2f;
|
||||||
case SpellDatum.TAG_VEC3 -> 3f;
|
case LegacySpellDatum.TAG_VEC3 -> 3f;
|
||||||
case SpellDatum.TAG_WIDGET -> 4f;
|
case LegacySpellDatum.TAG_WIDGET -> 4f;
|
||||||
case SpellDatum.TAG_LIST -> 5f;
|
case LegacySpellDatum.TAG_LIST -> 5f;
|
||||||
case SpellDatum.TAG_PATTERN -> 6f;
|
case LegacySpellDatum.TAG_PATTERN -> 6f;
|
||||||
default -> 0f; // uh oh
|
default -> 0f; // uh oh
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.SEALED_PRED,
|
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) {
|
private static void registerPackagedSpellOverrides(ItemPackagedHex item) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic;
|
||||||
|
|
||||||
import at.petrak.hexcasting.annotations.SoftImplement;
|
import at.petrak.hexcasting.annotations.SoftImplement;
|
||||||
import at.petrak.hexcasting.api.spell.DatumType;
|
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.items.ItemScroll;
|
||||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||||
|
@ -59,7 +59,7 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
|
||||||
var stack = pPlayer.getItemInHand(pHand);
|
var stack = pPlayer.getItemInHand(pHand);
|
||||||
if (stack.getItem() instanceof ItemScroll scroll) {
|
if (stack.getItem() instanceof ItemScroll scroll) {
|
||||||
if (!pLevel.isClientSide()) {
|
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);
|
pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE, SoundSource.BLOCKS, 1f, 1f);
|
||||||
return InteractionResult.sidedSuccess(pLevel.isClientSide);
|
return InteractionResult.sidedSuccess(pLevel.isClientSide);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic;
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||||
import at.petrak.hexcasting.api.spell.DatumType;
|
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.HexDir;
|
||||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||||
|
@ -45,7 +45,7 @@ public class BlockEntityAkashicRecord extends HexBlockEntity {
|
||||||
* Will never clobber anything.
|
* Will never clobber anything.
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable
|
||||||
BlockPos addNewDatum(HexPattern key, SpellDatum<?> datum) {
|
BlockPos addNewDatum(HexPattern key, LegacySpellDatum<?> datum) {
|
||||||
String entryKey = getKey(key);
|
String entryKey = getKey(key);
|
||||||
if (this.entries.containsKey(entryKey)) {
|
if (this.entries.containsKey(entryKey)) {
|
||||||
return null; // would clobber
|
return null; // would clobber
|
||||||
|
@ -76,19 +76,19 @@ public class BlockEntityAkashicRecord extends HexBlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
public @Nullable
|
||||||
SpellDatum<?> lookupPattern(HexPattern key, ServerLevel slevel) {
|
LegacySpellDatum<?> lookupPattern(HexPattern key, ServerLevel slevel) {
|
||||||
var entry = this.entries.get(getKey(key));
|
var entry = this.entries.get(getKey(key));
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return SpellDatum.fromNBT(entry.datum, slevel);
|
return LegacySpellDatum.fromNBT(entry.datum, slevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getDisplayAt(HexPattern key) {
|
public Component getDisplayAt(HexPattern key) {
|
||||||
var entry = this.entries.get(getKey(key));
|
var entry = this.entries.get(getKey(key));
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
return SpellDatum.displayFromNBT(entry.datum);
|
return LegacySpellDatum.displayFromNBT(entry.datum);
|
||||||
} else {
|
} else {
|
||||||
return new TranslatableComponent("hexcasting.spelldata.akashic.nopos").withStyle(ChatFormatting.RED);
|
return new TranslatableComponent("hexcasting.spelldata.akashic.nopos").withStyle(ChatFormatting.RED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.circles;
|
||||||
|
|
||||||
import at.petrak.hexcasting.annotations.SoftImplement;
|
import at.petrak.hexcasting.annotations.SoftImplement;
|
||||||
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
|
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.api.spell.math.HexPattern;
|
||||||
import at.petrak.hexcasting.common.lib.HexItems;
|
import at.petrak.hexcasting.common.lib.HexItems;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -102,7 +102,7 @@ public class BlockSlate extends BlockCircleComponent implements EntityBlock, Sim
|
||||||
if (be instanceof BlockEntitySlate slate) {
|
if (be instanceof BlockEntitySlate slate) {
|
||||||
ItemStack stack = new ItemStack(HexItems.SLATE);
|
ItemStack stack = new ItemStack(HexItems.SLATE);
|
||||||
if (slate.pattern != null) {
|
if (slate.pattern != null) {
|
||||||
HexItems.SLATE.writeDatum(stack, SpellDatum.make(slate.pattern));
|
HexItems.SLATE.writeDatum(stack, LegacySpellDatum.make(slate.pattern));
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting;
|
||||||
import at.petrak.hexcasting.api.PatternRegistry;
|
import at.petrak.hexcasting.api.PatternRegistry;
|
||||||
import at.petrak.hexcasting.api.misc.ManaConstants;
|
import at.petrak.hexcasting.api.misc.ManaConstants;
|
||||||
import at.petrak.hexcasting.api.spell.Operator;
|
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.Widget;
|
||||||
import at.petrak.hexcasting.api.spell.math.HexAngle;
|
import at.petrak.hexcasting.api.spell.math.HexAngle;
|
||||||
import at.petrak.hexcasting.api.spell.math.HexDir;
|
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("d", HexDir.EAST), modLoc("const/null"), Widget.NULL);
|
||||||
|
|
||||||
PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqea", HexDir.NORTH_WEST), modLoc("const/vec/px"),
|
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"),
|
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"),
|
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"),
|
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"),
|
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"),
|
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.
|
// Yep, this is what I spend the "plain hexagon" pattern on.
|
||||||
PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqq", HexDir.NORTH_WEST), modLoc("const/vec/0"),
|
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"),
|
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"),
|
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
|
// e
|
||||||
PatternRegistry.mapPattern(HexPattern.fromAngles("aaq", HexDir.EAST), modLoc("const/double/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 ==
|
// == Entities ==
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ public class RegisterPatterns {
|
||||||
if (negate) {
|
if (negate) {
|
||||||
accumulator = -accumulator;
|
accumulator = -accumulator;
|
||||||
}
|
}
|
||||||
return Operator.makeConstantOp(SpellDatum.make(accumulator));
|
return Operator.makeConstantOp(LegacySpellDatum.make(accumulator));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
object OpBlockAxisRaycast : ConstManaOperator {
|
object OpBlockAxisRaycast : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override val manaCost = ManaConstants.DUST_UNIT / 100
|
override val manaCost = ManaConstants.DUST_UNIT / 100
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val origin: Vec3 = args.getChecked(0, argc)
|
val origin: Vec3 = args.getChecked(0, argc)
|
||||||
val look: Vec3 = args.getChecked(1, argc)
|
val look: Vec3 = args.getChecked(1, argc)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
object OpBlockRaycast : ConstManaOperator {
|
object OpBlockRaycast : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override val manaCost = ManaConstants.DUST_UNIT / 100
|
override val manaCost = ManaConstants.DUST_UNIT / 100
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val origin: Vec3 = args.getChecked(0, argc)
|
val origin: Vec3 = args.getChecked(0, argc)
|
||||||
val look: Vec3 = args.getChecked(1, argc)
|
val look: Vec3 = args.getChecked(1, argc)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity
|
||||||
object OpEntityHeight : ConstManaOperator {
|
object OpEntityHeight : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val e: Entity = args.getChecked(0, argc)
|
val e: Entity = args.getChecked(0, argc)
|
||||||
ctx.assertEntityInRange(e)
|
ctx.assertEntityInRange(e)
|
||||||
return e.bbHeight.asSpellResult
|
return e.bbHeight.asSpellResult
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.entity.Entity
|
||||||
object OpEntityLook : ConstManaOperator {
|
object OpEntityLook : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val e: Entity = args.getChecked(0, argc)
|
val e: Entity = args.getChecked(0, argc)
|
||||||
ctx.assertEntityInRange(e)
|
ctx.assertEntityInRange(e)
|
||||||
return e.lookAngle.asSpellResult
|
return e.lookAngle.asSpellResult
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -11,7 +11,7 @@ import net.minecraft.world.entity.player.Player
|
||||||
object OpEntityPos : ConstManaOperator {
|
object OpEntityPos : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val e: Entity = args.getChecked(0, argc)
|
val e: Entity = args.getChecked(0, argc)
|
||||||
ctx.assertEntityInRange(e)
|
ctx.assertEntityInRange(e)
|
||||||
// If this is a player, "expected behavior" is to get the *eye* position so raycasts don't immediately
|
// If this is a player, "expected behavior" is to get the *eye* position so raycasts don't immediately
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
object OpEntityRaycast : ConstManaOperator {
|
object OpEntityRaycast : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override val manaCost = ManaConstants.DUST_UNIT / 100
|
override val manaCost = ManaConstants.DUST_UNIT / 100
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val origin: Vec3 = args.getChecked(0, argc)
|
val origin: Vec3 = args.getChecked(0, argc)
|
||||||
val look: Vec3 = args.getChecked(1, argc)
|
val look: Vec3 = args.getChecked(1, argc)
|
||||||
val endp = Operator.raycastEnd(origin, look)
|
val endp = Operator.raycastEnd(origin, look)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -12,7 +12,7 @@ import net.minecraft.world.entity.Entity
|
||||||
object OpEntityVelocity : ConstManaOperator {
|
object OpEntityVelocity : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val e: Entity = args.getChecked(0, argc)
|
val e: Entity = args.getChecked(0, argc)
|
||||||
ctx.assertEntityInRange(e)
|
ctx.assertEntityInRange(e)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
|
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
|
||||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
|
@ -9,7 +9,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
object OpRead : ConstManaOperator {
|
object OpRead : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val (handStack, hand) = ctx.getHeldItemToOperateOn {
|
val (handStack, hand) = ctx.getHeldItemToOperateOn {
|
||||||
val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
|
val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
|
||||||
dataHolder != null && (dataHolder.readDatum(ctx.world) != null || dataHolder.emptyDatum() != null)
|
dataHolder != null && (dataHolder.readDatum(ctx.world) != null || dataHolder.emptyDatum() != null)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
|
@ -9,7 +9,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
object OpReadable : ConstManaOperator {
|
object OpReadable : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val (handStack) = ctx.getHeldItemToOperateOn {
|
val (handStack) = ctx.getHeldItemToOperateOn {
|
||||||
IXplatAbstractions.INSTANCE.findDataHolder(it) != null
|
IXplatAbstractions.INSTANCE.findDataHolder(it) != null
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
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.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem
|
import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem
|
||||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
|
@ -12,9 +12,9 @@ object OpTheCoolerRead : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(
|
override fun execute(
|
||||||
args: List<SpellDatum<*>>,
|
args: List<LegacySpellDatum<*>>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): List<SpellDatum<*>> {
|
): List<LegacySpellDatum<*>> {
|
||||||
val target = args.getChecked<ItemEntity>(0, argc)
|
val target = args.getChecked<ItemEntity>(0, argc)
|
||||||
|
|
||||||
ctx.assertEntityInRange(target)
|
ctx.assertEntityInRange(target)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -12,9 +12,9 @@ object OpTheCoolerReadable : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(
|
override fun execute(
|
||||||
args: List<SpellDatum<*>>,
|
args: List<LegacySpellDatum<*>>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): List<SpellDatum<*>> {
|
): List<LegacySpellDatum<*>> {
|
||||||
val target = args.getChecked<ItemEntity>(0, argc)
|
val target = args.getChecked<ItemEntity>(0, argc)
|
||||||
ctx.assertEntityInRange(target)
|
ctx.assertEntityInRange(target)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators
|
package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
|
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
|
||||||
|
@ -10,7 +10,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
object OpWritable : ConstManaOperator {
|
object OpWritable : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val datum = args[0]
|
val datum = args[0]
|
||||||
|
|
||||||
val (handStack) = ctx.getHeldItemToOperateOn {
|
val (handStack) = ctx.getHeldItemToOperateOn {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||||
import at.petrak.hexcasting.api.spell.RenderedSpell
|
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.SpellOperator
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
|
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
|
||||||
|
@ -13,7 +13,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
object OpWrite : SpellOperator {
|
object OpWrite : SpellOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(
|
override fun execute(
|
||||||
args: List<SpellDatum<*>>,
|
args: List<LegacySpellDatum<*>>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||||
val datum = args[0]
|
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) {
|
override fun cast(ctx: CastingContext) {
|
||||||
val (handStack) = ctx.getHeldItemToOperateOn {
|
val (handStack) = ctx.getHeldItemToOperateOn {
|
||||||
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
|
val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it)
|
||||||
|
|
|
@ -2,10 +2,10 @@ package at.petrak.hexcasting.common.casting.operators.akashic
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.misc.ManaConstants
|
import at.petrak.hexcasting.api.misc.ManaConstants
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.LegacySpellDatum
|
||||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
|
||||||
import at.petrak.hexcasting.api.spell.Widget
|
import at.petrak.hexcasting.api.spell.Widget
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
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.math.HexPattern
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNoAkashicRecord
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNoAkashicRecord
|
||||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord
|
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord
|
||||||
|
@ -16,7 +16,7 @@ object OpAkashicRead : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override val manaCost = ManaConstants.DUST_UNIT
|
override val manaCost = ManaConstants.DUST_UNIT
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val pos = args.getChecked<Vec3>(0, argc)
|
val pos = args.getChecked<Vec3>(0, argc)
|
||||||
val key = args.getChecked<HexPattern>(1, argc)
|
val key = args.getChecked<HexPattern>(1, argc)
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ object OpAkashicRead : ConstManaOperator {
|
||||||
}
|
}
|
||||||
|
|
||||||
val datum = tile.lookupPattern(key, ctx.world)
|
val datum = tile.lookupPattern(key, ctx.world)
|
||||||
return listOf(datum ?: SpellDatum.make(Widget.NULL))
|
return listOf(datum ?: LegacySpellDatum.make(Widget.NULL))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ object OpAkashicWrite : SpellOperator {
|
||||||
override val causesBlindDiversion = false
|
override val causesBlindDiversion = false
|
||||||
|
|
||||||
override fun execute(
|
override fun execute(
|
||||||
args: List<SpellDatum<*>>,
|
args: List<LegacySpellDatum<*>>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||||
val pos = args.getChecked<Vec3>(0, argc)
|
val pos = args.getChecked<Vec3>(0, argc)
|
||||||
|
@ -46,7 +46,7 @@ object OpAkashicWrite : SpellOperator {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: SpellDatum<*>) :
|
private data class Spell(val record: BlockEntityAkashicRecord, val key: HexPattern, val datum: LegacySpellDatum<*>) :
|
||||||
RenderedSpell {
|
RenderedSpell {
|
||||||
override fun cast(ctx: CastingContext) {
|
override fun cast(ctx: CastingContext) {
|
||||||
record.addNewDatum(key, datum)
|
record.addNewDatum(key, datum)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.circles
|
package at.petrak.hexcasting.common.casting.operators.circles
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
class OpCircleBounds(val max: Boolean) : ConstManaOperator {
|
class OpCircleBounds(val max: Boolean) : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
if (ctx.spellCircle == null)
|
if (ctx.spellCircle == null)
|
||||||
throw MishapNoSpellCircle()
|
throw MishapNoSpellCircle()
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
|
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
||||||
|
@ -10,7 +10,7 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
||||||
object OpImpetusDir : ConstManaOperator {
|
object OpImpetusDir : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
if (ctx.spellCircle == null)
|
if (ctx.spellCircle == null)
|
||||||
throw MishapNoSpellCircle()
|
throw MishapNoSpellCircle()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.circles
|
package at.petrak.hexcasting.common.casting.operators.circles
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
object OpImpetusPos : ConstManaOperator {
|
object OpImpetusPos : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
if (ctx.spellCircle == null)
|
if (ctx.spellCircle == null)
|
||||||
throw MishapNoSpellCircle()
|
throw MishapNoSpellCircle()
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.ContinuationFrame
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
|
|
||||||
object OpEval : Operator {
|
object OpEval : Operator {
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
|
||||||
val instrs: SpellList = stack.getChecked(stack.lastIndex)
|
val instrs: SpellList = stack.getChecked(stack.lastIndex)
|
||||||
stack.removeLastOrNull()
|
stack.removeLastOrNull()
|
||||||
|
|
||||||
|
|
|
@ -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.OperationResult
|
||||||
import at.petrak.hexcasting.api.spell.Operator
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
|
|
||||||
object OpEvalDelay : Operator {
|
object OpEvalDelay : Operator {
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
|
||||||
return OperationResult(continuation, stack, local, listOf())
|
return OperationResult(continuation, stack, local, listOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.eval
|
package at.petrak.hexcasting.common.casting.operators.eval
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.OperationResult
|
import at.petrak.hexcasting.api.spell.*
|
||||||
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.casting.CastingContext
|
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.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.casting.SpellContinuation
|
||||||
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||||
|
|
||||||
object OpForEach : Operator {
|
object OpForEach : Operator {
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(
|
||||||
|
continuation: SpellContinuation,
|
||||||
|
stack: MutableList<LegacySpellDatum<*>>,
|
||||||
|
local: LegacySpellDatum<*>,
|
||||||
|
ctx: CastingContext
|
||||||
|
): OperationResult {
|
||||||
if (stack.size < 2)
|
if (stack.size < 2)
|
||||||
throw MishapNotEnoughArgs(2, stack.size)
|
throw MishapNotEnoughArgs(2, stack.size)
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.eval
|
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.OperationResult
|
||||||
import at.petrak.hexcasting.api.spell.Operator
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
|
|
||||||
object OpHalt : Operator {
|
object OpHalt : Operator {
|
||||||
override fun operate(
|
override fun operate(
|
||||||
continuation: SpellContinuation,
|
continuation: SpellContinuation,
|
||||||
stack: MutableList<SpellDatum<*>>,
|
stack: MutableList<LegacySpellDatum<*>>,
|
||||||
local: SpellDatum<*>,
|
local: LegacySpellDatum<*>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): OperationResult {
|
): OperationResult {
|
||||||
var newStack = stack.toList()
|
var newStack = stack.toList()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpAppend : ConstManaOperator {
|
object OpAppend : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
val datum = args[1]
|
val datum = args[1]
|
||||||
list.add(datum)
|
list.add(datum)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpConcat : ConstManaOperator {
|
object OpConcat : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val lhs = args.getChecked<SpellList>(0, argc).toMutableList()
|
val lhs = args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
val rhs = args.getChecked<SpellList>(1, argc)
|
val rhs = args.getChecked<SpellList>(1, argc)
|
||||||
lhs.addAll(rhs)
|
lhs.addAll(rhs)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpCons : ConstManaOperator {
|
object OpCons : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val bottom = args.getChecked<SpellList>(0, argc)
|
val bottom = args.getChecked<SpellList>(0, argc)
|
||||||
val top = args[1]
|
val top = args[1]
|
||||||
return SpellList.LPair(top, bottom).asSpellResult
|
return SpellList.LPair(top, bottom).asSpellResult
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.lists
|
package at.petrak.hexcasting.common.casting.operators.lists
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpEmptyList : ConstManaOperator {
|
object OpEmptyList : ConstManaOperator {
|
||||||
override val argc = 0
|
override val argc = 0
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
return emptyList<SpellDatum<*>>().asSpellResult // sorry for taking all the easy impls, hudeler
|
return emptyList<LegacySpellDatum<*>>().asSpellResult // sorry for taking all the easy impls, hudeler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.lists
|
package at.petrak.hexcasting.common.casting.operators.lists
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
import at.petrak.hexcasting.api.spell.*
|
||||||
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.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.Widget
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
object OpIndex : ConstManaOperator {
|
object OpIndex : ConstManaOperator {
|
||||||
override val argc = 2
|
override val argc = 2
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
val index = args.getChecked<Double>(1, argc)
|
val index = args.getChecked<Double>(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)
|
return listOf(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ object OpIndexOf : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 2
|
get() = 2
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
val value = args[1]
|
val value = args[1]
|
||||||
return list.indexOfFirst(value::tolerantEquals).asSpellResult
|
return list.indexOfFirst(value::tolerantEquals).asSpellResult
|
||||||
|
|
|
@ -10,7 +10,7 @@ import kotlin.math.abs
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
object OpLastNToList : Operator {
|
object OpLastNToList : Operator {
|
||||||
override fun operate(continuation: SpellContinuation, stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
|
override fun operate(continuation: SpellContinuation, stack: MutableList<LegacySpellDatum<*>>, local: LegacySpellDatum<*>, ctx: CastingContext): OperationResult {
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
throw MishapNotEnoughArgs(1, 0)
|
throw MishapNotEnoughArgs(1, 0)
|
||||||
val arg = stack.takeLast(1).getChecked<Double>(0)
|
val arg = stack.takeLast(1).getChecked<Double>(0)
|
||||||
|
@ -23,7 +23,7 @@ object OpLastNToList : Operator {
|
||||||
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, stack.size)
|
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, stack.size)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val output = mutableListOf<SpellDatum<*>>()
|
val output = mutableListOf<LegacySpellDatum<*>>()
|
||||||
output.addAll(stack.takeLast(arg.toInt()))
|
output.addAll(stack.takeLast(arg.toInt()))
|
||||||
val endSize = stack.size - output.toList().size
|
val endSize = stack.size - output.toList().size
|
||||||
while (stack.size != endSize) {
|
while (stack.size != endSize) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
// it's still called beancounter's distillation in my heart
|
// it's still called beancounter's distillation in my heart
|
||||||
object OpListSize : ConstManaOperator {
|
object OpListSize : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
return args.getChecked<SpellList>(0, argc).toList().size.asSpellResult // mmm one-liner
|
return args.getChecked<SpellList>(0, argc).toList().size.asSpellResult // mmm one-liner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import kotlin.math.roundToInt
|
||||||
|
|
||||||
object OpModifyInPlace : ConstManaOperator {
|
object OpModifyInPlace : ConstManaOperator {
|
||||||
override val argc = 3
|
override val argc = 3
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc)
|
val list = args.getChecked<SpellList>(0, argc)
|
||||||
val index = args.getChecked<Double>(1, argc).roundToInt()
|
val index = args.getChecked<Double>(1, argc).roundToInt()
|
||||||
val iota = args[2]
|
val iota = args[2]
|
||||||
|
|
|
@ -7,7 +7,7 @@ object OpRemove : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 2
|
get() = 2
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
val list = args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
val index = args.getChecked<Double>(1, argc).toInt()
|
val index = args.getChecked<Double>(1, argc).toInt()
|
||||||
if (index < 0 || index >= list.size)
|
if (index < 0 || index >= list.size)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpReverski : ConstManaOperator {
|
object OpReverski : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
return args.getChecked<SpellList>(0, argc).toList().asReversed().asSpellResult // okay kotlin kinda pogged for this
|
return args.getChecked<SpellList>(0, argc).toList().asReversed().asSpellResult // okay kotlin kinda pogged for this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.lists
|
package at.petrak.hexcasting.common.casting.operators.lists
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpSingleton : ConstManaOperator {
|
object OpSingleton : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
return listOf(args[0]).asSpellResult // god i love one-liners
|
return listOf(args[0]).asSpellResult // god i love one-liners
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,13 @@ import kotlin.math.roundToInt
|
||||||
|
|
||||||
object OpSlice : ConstManaOperator {
|
object OpSlice : ConstManaOperator {
|
||||||
override val argc = 3
|
override val argc = 3
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc).toList()
|
val list = args.getChecked<SpellList>(0, argc).toList()
|
||||||
val index1 = Mth.clamp(args.getChecked<Double>(1, argc).roundToInt(), 0, list.size)
|
val index1 = Mth.clamp(args.getChecked<Double>(1, argc).roundToInt(), 0, list.size)
|
||||||
val index2 = Mth.clamp(args.getChecked<Double>(2, argc).roundToInt(), 0, list.size)
|
val index2 = Mth.clamp(args.getChecked<Double>(2, argc).roundToInt(), 0, list.size)
|
||||||
|
|
||||||
if (index1 == index2)
|
if (index1 == index2)
|
||||||
return emptyList<SpellDatum<*>>().asSpellResult
|
return emptyList<LegacySpellDatum<*>>().asSpellResult
|
||||||
|
|
||||||
return list.subList(min(index1, index2), max(index1, index2)).asSpellResult
|
return list.subList(min(index1, index2), max(index1, index2)).asSpellResult
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
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.SpellList
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ object OpSplat : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 1
|
get() = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> =
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> =
|
||||||
args.getChecked<SpellList>(0, argc).toMutableList()
|
args.getChecked<SpellList>(0, argc).toMutableList()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
|
|
||||||
object OpUnCons : ConstManaOperator {
|
object OpUnCons : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val list = args.getChecked<SpellList>(0, argc)
|
val list = args.getChecked<SpellList>(0, argc)
|
||||||
if (list.nonEmpty) {
|
if (list.nonEmpty) {
|
||||||
return spellListOf(list.cdr, list.car)
|
return spellListOf(list.cdr, list.car)
|
||||||
|
|
|
@ -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.OperationResult
|
||||||
import at.petrak.hexcasting.api.spell.Operator
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
|
|
||||||
object OpPeekLocal : Operator {
|
object OpPeekLocal : Operator {
|
||||||
override fun operate(
|
override fun operate(
|
||||||
continuation: SpellContinuation,
|
continuation: SpellContinuation,
|
||||||
stack: MutableList<SpellDatum<*>>,
|
stack: MutableList<LegacySpellDatum<*>>,
|
||||||
local: SpellDatum<*>,
|
local: LegacySpellDatum<*>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): OperationResult {
|
): OperationResult {
|
||||||
stack.add(local)
|
stack.add(local)
|
||||||
|
|
|
@ -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.OperationResult
|
||||||
import at.petrak.hexcasting.api.spell.Operator
|
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.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
|
@ -10,8 +10,8 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||||
object OpPushLocal : Operator {
|
object OpPushLocal : Operator {
|
||||||
override fun operate(
|
override fun operate(
|
||||||
continuation: SpellContinuation,
|
continuation: SpellContinuation,
|
||||||
stack: MutableList<SpellDatum<*>>,
|
stack: MutableList<LegacySpellDatum<*>>,
|
||||||
local: SpellDatum<*>,
|
local: LegacySpellDatum<*>,
|
||||||
ctx: CastingContext
|
ctx: CastingContext
|
||||||
): OperationResult {
|
): OperationResult {
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
|
|
|
@ -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.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.numOrVec
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
@ -11,7 +11,7 @@ object OpAbsLen : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 1
|
get() = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val x = numOrVec(args[0], 0)
|
val x = numOrVec(args[0], 0)
|
||||||
|
|
||||||
return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asSpellResult
|
return x.map({ num -> num.absoluteValue }, { vec -> vec.length() }).asSpellResult
|
||||||
|
|
|
@ -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.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.numOrVec
|
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.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.spellListOf
|
import at.petrak.hexcasting.api.spell.spellListOf
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ object OpAdd : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 2
|
get() = 2
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val lhs = numOrVec(args[0], 1)
|
val lhs = numOrVec(args[0], 1)
|
||||||
val rhs = numOrVec(args[1], 0)
|
val rhs = numOrVec(args[1], 0)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.math
|
package at.petrak.hexcasting.common.casting.operators.math
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -11,7 +11,7 @@ object OpCeil : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 1
|
get() = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val value = args.getChecked<Double>(0, argc)
|
val value = args.getChecked<Double>(0, argc)
|
||||||
return ceil(value).asSpellResult
|
return ceil(value).asSpellResult
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.math
|
package at.petrak.hexcasting.common.casting.operators.math
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -12,7 +12,7 @@ object OpCoerceToAxial : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 1
|
get() = 1
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val vec = args.getChecked<Vec3>(0, argc)
|
val vec = args.getChecked<Vec3>(0, argc)
|
||||||
if (vec == Vec3.ZERO)
|
if (vec == Vec3.ZERO)
|
||||||
return vec.asSpellResult
|
return vec.asSpellResult
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.math
|
package at.petrak.hexcasting.common.casting.operators.math
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.asSpellResult
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
|
@ -9,7 +9,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
|
|
||||||
object OpConstructVec : ConstManaOperator {
|
object OpConstructVec : ConstManaOperator {
|
||||||
override val argc = 3
|
override val argc = 3
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val x = args.getChecked<Double>(0, argc)
|
val x = args.getChecked<Double>(0, argc)
|
||||||
val y = args.getChecked<Double>(1, argc)
|
val y = args.getChecked<Double>(1, argc)
|
||||||
val z = args.getChecked<Double>(2, argc)
|
val z = args.getChecked<Double>(2, argc)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package at.petrak.hexcasting.common.casting.operators.math
|
package at.petrak.hexcasting.common.casting.operators.math
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
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.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getChecked
|
import at.petrak.hexcasting.api.spell.getChecked
|
||||||
import at.petrak.hexcasting.api.spell.spellListOf
|
import at.petrak.hexcasting.api.spell.spellListOf
|
||||||
|
@ -9,7 +9,7 @@ import net.minecraft.world.phys.Vec3
|
||||||
|
|
||||||
object OpDeconstructVec : ConstManaOperator {
|
object OpDeconstructVec : ConstManaOperator {
|
||||||
override val argc = 1
|
override val argc = 1
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val v = args.getChecked<Vec3>(0, argc)
|
val v = args.getChecked<Vec3>(0, argc)
|
||||||
return spellListOf(v.x, v.y, v.z)
|
return spellListOf(v.x, v.y, v.z)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ConstManaOperator
|
||||||
import at.petrak.hexcasting.api.spell.numOrVec
|
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.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
|
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
|
||||||
import at.petrak.hexcasting.api.spell.spellListOf
|
import at.petrak.hexcasting.api.spell.spellListOf
|
||||||
|
@ -12,7 +12,7 @@ object OpDivCross : ConstManaOperator {
|
||||||
override val argc: Int
|
override val argc: Int
|
||||||
get() = 2
|
get() = 2
|
||||||
|
|
||||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
override fun execute(args: List<LegacySpellDatum<*>>, ctx: CastingContext): List<LegacySpellDatum<*>> {
|
||||||
val lhs = numOrVec(args[0], 1)
|
val lhs = numOrVec(args[0], 1)
|
||||||
val rhs = numOrVec(args[1], 0)
|
val rhs = numOrVec(args[1], 0)
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue