nbt dsl, names are no longer wrongcased, ser for con frames

This commit is contained in:
yrsegal@gmail.com 2022-05-24 23:35:36 -04:00
parent 2610e415e0
commit 52b7036b91
80 changed files with 639 additions and 408 deletions

View file

@ -129,7 +129,7 @@ object PatternRegistry {
} }
for ((sig, entry) in this.regularPatternLookup) { for ((sig, entry) in this.regularPatternLookup) {
if (entry.opId == opId) { if (entry.opId == opId) {
val pattern = HexPattern.FromAnglesSig(sig, entry.preferredStart) val pattern = HexPattern.fromAngles(sig, entry.preferredStart)
return PatternEntry(pattern, this.operatorLookup[entry.opId]!!, false) return PatternEntry(pattern, this.operatorLookup[entry.opId]!!, false)
} }
} }

View file

@ -13,7 +13,7 @@ public interface DataHolder {
default SpellDatum<?> readDatum(ServerLevel world) { default SpellDatum<?> readDatum(ServerLevel world) {
var tag = readRawDatum(); var tag = readRawDatum();
if (tag != null) { if (tag != null) {
return SpellDatum.DeserializeFromNBT(tag, world); return SpellDatum.fromNBT(tag, world);
} else { } else {
return null; return null;
} }

View file

@ -132,7 +132,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
if (this.activator != null && this.colorizer != null && this.nextBlock != null && this.trackedBlocks != null) { if (this.activator != null && this.colorizer != null && this.nextBlock != null && this.trackedBlocks != null) {
tag.putUUID(TAG_ACTIVATOR, this.activator); tag.putUUID(TAG_ACTIVATOR, this.activator);
tag.put(TAG_NEXT_BLOCK, NbtUtils.writeBlockPos(this.nextBlock)); tag.put(TAG_NEXT_BLOCK, NbtUtils.writeBlockPos(this.nextBlock));
tag.put(TAG_COLORIZER, this.colorizer.serialize()); tag.put(TAG_COLORIZER, this.colorizer.serializeToNBT());
tag.putBoolean(TAG_FOUND_ALL, this.foundAll); tag.putBoolean(TAG_FOUND_ALL, this.foundAll);
var trackeds = new ListTag(); var trackeds = new ListTag();
@ -155,7 +155,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
tag.contains(TAG_NEXT_BLOCK, Tag.TAG_COMPOUND) && tag.contains(TAG_NEXT_BLOCK, Tag.TAG_COMPOUND) &&
tag.contains(TAG_TRACKED_BLOCKS, Tag.TAG_LIST)) { tag.contains(TAG_TRACKED_BLOCKS, Tag.TAG_LIST)) {
this.activator = tag.getUUID(TAG_ACTIVATOR); this.activator = tag.getUUID(TAG_ACTIVATOR);
this.colorizer = FrozenColorizer.deserialize(tag.getCompound(TAG_COLORIZER)); this.colorizer = FrozenColorizer.fromNBT(tag.getCompound(TAG_COLORIZER));
this.nextBlock = NbtUtils.readBlockPos(tag.getCompound(TAG_NEXT_BLOCK)); this.nextBlock = NbtUtils.readBlockPos(tag.getCompound(TAG_NEXT_BLOCK));
this.foundAll = tag.getBoolean(TAG_FOUND_ALL); this.foundAll = tag.getBoolean(TAG_FOUND_ALL);
var trackeds = tag.getList(TAG_TRACKED_BLOCKS, Tag.TAG_COMPOUND); var trackeds = tag.getList(TAG_TRACKED_BLOCKS, Tag.TAG_COMPOUND);

View file

@ -28,7 +28,7 @@ public interface DataHolderItem {
var tag = dh.readDatumTag(stack); var tag = dh.readDatumTag(stack);
if (tag != null) { if (tag != null) {
return SpellDatum.DeserializeFromNBT(tag, world); return SpellDatum.fromNBT(tag, world);
} else { } else {
return null; return null;
} }
@ -47,7 +47,7 @@ public interface DataHolderItem {
TooltipFlag pIsAdvanced) { TooltipFlag pIsAdvanced) {
var datumTag = self.readDatumTag(pStack); var datumTag = self.readDatumTag(pStack);
if (datumTag != null) { if (datumTag != null) {
var component = SpellDatum.DisplayFromTag(datumTag); var component = SpellDatum.displayFromNBT(datumTag);
pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component)); pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component));
if (pIsAdvanced.isAdvanced()) { if (pIsAdvanced.isAdvanced()) {

View file

@ -29,14 +29,14 @@ public record FrozenColorizer(ItemStack item, UUID owner) {
public static final Supplier<FrozenColorizer> DEFAULT = public static final Supplier<FrozenColorizer> DEFAULT =
() -> new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.WHITE)), Util.NIL_UUID); () -> new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.WHITE)), Util.NIL_UUID);
public CompoundTag serialize() { public CompoundTag serializeToNBT() {
var out = new CompoundTag(); var out = new CompoundTag();
out.put(TAG_STACK, HexUtils.serialize(this.item)); out.put(TAG_STACK, HexUtils.serializeToNBT(this.item));
out.putUUID(TAG_OWNER, this.owner); out.putUUID(TAG_OWNER, this.owner);
return out; return out;
} }
public static FrozenColorizer deserialize(CompoundTag tag) { public static FrozenColorizer fromNBT(CompoundTag tag) {
if (tag.isEmpty()) { if (tag.isEmpty()) {
return FrozenColorizer.DEFAULT.get(); return FrozenColorizer.DEFAULT.get();
} }

View file

@ -12,7 +12,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 GetNumOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> = fun numOrVec(datum: SpellDatum<*>, 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)
@ -23,7 +23,7 @@ fun GetNumOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
) )
} }
fun GetNumOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, SpellList> = fun numOrList(datum: SpellDatum<*>, 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)

View file

@ -9,12 +9,12 @@ import net.minecraft.world.phys.Vec3
data class ParticleSpray(val pos: Vec3, val vel: Vec3, val fuzziness: Double, val spread: Double, val count: Int = 20) { data class ParticleSpray(val pos: Vec3, val vel: Vec3, val fuzziness: Double, val spread: Double, val count: Int = 20) {
companion object { companion object {
@JvmStatic @JvmStatic
fun Burst(pos: Vec3, size: Double, count: Int = 20): ParticleSpray { fun burst(pos: Vec3, size: Double, count: Int = 20): ParticleSpray {
return ParticleSpray(pos, Vec3(size, 0.0, 0.0), 0.0, 3.14, count) return ParticleSpray(pos, Vec3(size, 0.0, 0.0), 0.0, 3.14, count)
} }
@JvmStatic @JvmStatic
fun Cloud(pos: Vec3, size: Double, count: Int = 20): ParticleSpray { fun cloud(pos: Vec3, size: Double, count: Int = 20): ParticleSpray {
return ParticleSpray(pos, Vec3(0.0, 0.001, 0.0), size, 0.0, count) return ParticleSpray(pos, Vec3(0.0, 0.001, 0.0), size, 0.0, count)
} }
} }

View file

@ -3,11 +3,12 @@ package at.petrak.hexcasting.api.spell
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.math.HexPattern import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidSpellDatumType import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidSpellDatumType
import at.petrak.hexcasting.api.utils.HexUtils import at.petrak.hexcasting.api.utils.*
import at.petrak.hexcasting.api.utils.HexUtils.serializeToNBT
import at.petrak.hexcasting.api.utils.getList
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.nbt.* import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.DoubleTag
import net.minecraft.nbt.NbtUtils
import net.minecraft.nbt.Tag
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TextComponent import net.minecraft.network.chat.TextComponent
import net.minecraft.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
@ -22,7 +23,7 @@ import java.util.*
* We use the following types: * We use the following types:
* * [Entity] * * [Entity]
* * [Double] * * [Double]
* * [Vec3][net.minecraft.world.phys.Vec3] as both position and (when normalized) direction * * [Vec3] as both position and (when normalized) direction
* * [Widget]; [Widget.NULL] is used as our null value * * [Widget]; [Widget.NULL] is used as our null value
* * [SpellList] * * [SpellList]
* * [HexPattern]! Yes, we have meta-evaluation everyone. * * [HexPattern]! Yes, we have meta-evaluation everyone.
@ -51,10 +52,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
TAG_VEC3, pl.serializeToNBT() TAG_VEC3, pl.serializeToNBT()
) )
is SpellList -> { is SpellList -> {
val subtag = ListTag() out.put(TAG_LIST, pl.serializeToNBT())
for (elt in pl)
subtag.add(elt.serializeToNBT())
out.put(TAG_LIST, subtag)
} }
is Widget -> { is Widget -> {
out.putString(TAG_WIDGET, pl.name) out.putString(TAG_WIDGET, pl.name)
@ -85,7 +83,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
fun display(): Component { fun display(): Component {
val nbt = this.serializeToNBT() val nbt = this.serializeToNBT()
return DisplayFromTag(nbt) return displayFromNBT(nbt)
} }
fun getType(): DatumType = fun getType(): DatumType =
@ -101,6 +99,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
companion object { companion object {
@JvmStatic @JvmStatic
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
fun make(payload: Any): SpellDatum<*> = fun make(payload: Any): SpellDatum<*> =
if (payload is SpellDatum<*>) { if (payload is SpellDatum<*>) {
payload payload
@ -114,23 +113,23 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
} else if (payload is Vec3) { } else if (payload is Vec3) {
SpellDatum( SpellDatum(
Vec3( Vec3(
HexUtils.FixNANs(payload.x), fixNAN(payload.x),
HexUtils.FixNANs(payload.y), fixNAN(payload.y),
HexUtils.FixNANs(payload.z), fixNAN(payload.z),
) )
) )
} else if (IsValidType(payload)) { } else if (isValidType(payload)) {
SpellDatum(payload) SpellDatum(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(HexUtils.FixNANs(num)) SpellDatum(fixNAN(num))
} else { } else {
throw MishapInvalidSpellDatumType(payload) throw MishapInvalidSpellDatumType(payload)
} }
@JvmStatic @JvmStatic
fun DeserializeFromNBT(nbt: CompoundTag, world: ServerLevel): SpellDatum<*> { fun fromNBT(nbt: CompoundTag, world: ServerLevel): SpellDatum<*> {
val keys = nbt.allKeys val keys = nbt.allKeys
if (keys.size != 1) if (keys.size != 1)
throw IllegalArgumentException("Expected exactly one kv pair: $nbt") throw IllegalArgumentException("Expected exactly one kv pair: $nbt")
@ -144,21 +143,15 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
SpellDatum(if (entity == null || !entity.isAlive) Widget.NULL else entity) SpellDatum(if (entity == null || !entity.isAlive) Widget.NULL else entity)
} }
TAG_DOUBLE -> SpellDatum(nbt.getDouble(key)) TAG_DOUBLE -> SpellDatum(nbt.getDouble(key))
TAG_VEC3 -> SpellDatum(HexUtils.DeserializeVec3FromNBT(nbt.getLongArray(key))) TAG_VEC3 -> SpellDatum(vecFromNBT(nbt.getLongArray(key)))
TAG_LIST -> { TAG_LIST -> {
val arr = nbt.getList(key, Tag.TAG_COMPOUND) SpellDatum(SpellList.fromNBT(nbt.getList(key, Tag.TAG_COMPOUND), world))
val out = ArrayList<SpellDatum<*>>(arr.size)
for (subtag in arr) {
// this is safe because otherwise we wouldn't have been able to get the list before
out.add(DeserializeFromNBT(subtag as CompoundTag, world))
}
SpellDatum(SpellList.LList(0, out))
} }
TAG_WIDGET -> { TAG_WIDGET -> {
SpellDatum(Widget.valueOf(nbt.getString(key))) SpellDatum(Widget.valueOf(nbt.getString(key)))
} }
TAG_PATTERN -> { TAG_PATTERN -> {
SpellDatum(HexPattern.DeserializeFromNBT(nbt.getCompound(TAG_PATTERN))) SpellDatum(HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN)))
} }
else -> throw IllegalArgumentException("Unknown key $key: $nbt") else -> throw IllegalArgumentException("Unknown key $key: $nbt")
} }
@ -171,11 +164,11 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
) )
) )
@JvmStatic @JvmStatic
fun DeserializeFromNBT(nbt: CompoundTag, ctx: CastingContext): SpellDatum<*> = fun fromNBT(nbt: CompoundTag, ctx: CastingContext): SpellDatum<*> =
DeserializeFromNBT(nbt, ctx.world) fromNBT(nbt, ctx.world)
@JvmStatic @JvmStatic
fun DisplayFromTag(nbt: CompoundTag): Component { fun displayFromNBT(nbt: CompoundTag): Component {
val keys = nbt.allKeys val keys = nbt.allKeys
if (keys.size != 1) if (keys.size != 1)
throw IllegalArgumentException("Expected exactly one kv pair: $nbt") throw IllegalArgumentException("Expected exactly one kv pair: $nbt")
@ -188,7 +181,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
) )
).withStyle(ChatFormatting.GREEN) ).withStyle(ChatFormatting.GREEN)
TAG_VEC3 -> { TAG_VEC3 -> {
val vec = HexUtils.DeserializeVec3FromNBT(nbt.getLongArray(key)) val vec = vecFromNBT(nbt.getLongArray(key))
// the focus color is really more red, but we don't want to show an error-y color // the focus color is really more red, but we don't want to show an error-y color
TextComponent( TextComponent(
String.format( String.format(
@ -205,7 +198,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
val arr = nbt.getList(key, Tag.TAG_COMPOUND) val arr = nbt.getList(key, Tag.TAG_COMPOUND)
for ((i, subtag) in arr.withIndex()) { for ((i, subtag) in arr.withIndex()) {
// this is safe because otherwise we wouldn't have been able to get the list before // this is safe because otherwise we wouldn't have been able to get the list before
out.append(DisplayFromTag(subtag as CompoundTag)) out.append(displayFromNBT(subtag as CompoundTag))
if (i != arr.lastIndex) { if (i != arr.lastIndex) {
out.append(", ") out.append(", ")
} }
@ -223,7 +216,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
else TextComponent(widget.toString()).withStyle(ChatFormatting.DARK_PURPLE) else TextComponent(widget.toString()).withStyle(ChatFormatting.DARK_PURPLE)
} }
TAG_PATTERN -> { TAG_PATTERN -> {
val pat = HexPattern.DeserializeFromNBT(nbt.getCompound(TAG_PATTERN)) val pat = HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN))
var angleDesc = pat.anglesSignature() var angleDesc = pat.anglesSignature()
if (angleDesc.isNotBlank()) angleDesc = " $angleDesc"; if (angleDesc.isNotBlank()) angleDesc = " $angleDesc";
val out = TextComponent("HexPattern(").withStyle(ChatFormatting.GOLD) val out = TextComponent("HexPattern(").withStyle(ChatFormatting.GOLD)
@ -267,11 +260,11 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
// Also encode the entity's name as a component for the benefit of the client // Also encode the entity's name as a component for the benefit of the client
const val TAG_ENTITY_NAME_CHEATY = "name" const val TAG_ENTITY_NAME_CHEATY = "name"
fun <T : Any> IsValidType(checkee: T): Boolean = fun <T : Any> isValidType(checkee: T): Boolean =
ValidTypes.any { clazz -> clazz.isAssignableFrom(checkee.javaClass) } ValidTypes.any { clazz -> clazz.isAssignableFrom(checkee.javaClass) }
@JvmStatic @JvmStatic
fun GetTagName(datumType: DatumType): String { fun tagForType(datumType: DatumType): String {
return when (datumType) { return when (datumType) {
DatumType.ENTITY -> TAG_ENTITY DatumType.ENTITY -> TAG_ENTITY
DatumType.WIDGET -> TAG_WIDGET DatumType.WIDGET -> TAG_WIDGET

View file

@ -1,5 +1,9 @@
package at.petrak.hexcasting.api.spell package at.petrak.hexcasting.api.spell
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.ListTag
import net.minecraft.server.level.ServerLevel
/** /**
* Restricted interface for functional lists. * Restricted interface for functional lists.
* *
@ -73,4 +77,16 @@ sealed class SpellList: Iterable<SpellDatum<*>> {
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)
}
}
} }

View file

@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.mishaps.MishapEntityTooFarAway import at.petrak.hexcasting.api.spell.mishaps.MishapEntityTooFarAway
import at.petrak.hexcasting.api.spell.mishaps.MishapEvalTooDeep import at.petrak.hexcasting.api.spell.mishaps.MishapEvalTooDeep
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway
import at.petrak.hexcasting.api.utils.HexUtils import at.petrak.hexcasting.api.utils.otherHand
import at.petrak.hexcasting.xplat.IXplatAbstractions import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerLevel
@ -33,7 +33,7 @@ data class CastingContext(
private var depth: Int = 0 private var depth: Int = 0
val world: ServerLevel get() = caster.getLevel() val world: ServerLevel get() = caster.getLevel()
val otherHand: InteractionHand get() = HexUtils.OtherHand(this.castingHand) val otherHand: InteractionHand get() = otherHand(this.castingHand)
val position: Vec3 get() = caster.position() val position: Vec3 get() = caster.position()
private val entitiesGivenMotion = mutableSetOf<Entity>() private val entitiesGivenMotion = mutableSetOf<Entity>()

View file

@ -450,7 +450,7 @@ class CastingHarness private constructor(
out.put(TAG_PARENTHESIZED, parensTag) out.put(TAG_PARENTHESIZED, parensTag)
if (this.prepackagedColorizer != null) { if (this.prepackagedColorizer != null) {
out.put(TAG_PREPACKAGED_COLORIZER, this.prepackagedColorizer.serialize()) out.put(TAG_PREPACKAGED_COLORIZER, this.prepackagedColorizer.serializeToNBT())
} }
return out return out
@ -466,18 +466,18 @@ class CastingHarness private constructor(
const val TAG_PREPACKAGED_COLORIZER = "prepackaged_colorizer" const val TAG_PREPACKAGED_COLORIZER = "prepackaged_colorizer"
@JvmStatic @JvmStatic
fun DeserializeFromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness { fun fromNBT(nbt: CompoundTag, ctx: CastingContext): CastingHarness {
return try { return try {
val stack = mutableListOf<SpellDatum<*>>() val stack = mutableListOf<SpellDatum<*>>()
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.DeserializeFromNBT(subtag.asCompound, ctx.world) val datum = SpellDatum.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.DeserializeFromNBT(localTag, ctx.world) else SpellDatum.make( if (localTag.size() == 1) SpellDatum.fromNBT(localTag, ctx.world) else SpellDatum.make(
Widget.NULL Widget.NULL
) )
@ -485,16 +485,16 @@ class CastingHarness private constructor(
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.DeserializeFromNBT(subtag.asCompound))) parenthesized.add(SpellDatum.make(HexPattern.fromNBT(subtag.asCompound)))
else else
parenthesized.add(SpellDatum.DeserializeFromNBT(subtag.asCompound, ctx.world)) parenthesized.add(SpellDatum.fromNBT(subtag.asCompound, ctx.world))
} }
val parenCount = nbt.getInt(TAG_PAREN_COUNT) val parenCount = nbt.getInt(TAG_PAREN_COUNT)
val escapeNext = nbt.getBoolean(TAG_ESCAPE_NEXT) val escapeNext = nbt.getBoolean(TAG_ESCAPE_NEXT)
val colorizer = if (nbt.contains(TAG_PREPACKAGED_COLORIZER)) { val colorizer = if (nbt.contains(TAG_PREPACKAGED_COLORIZER)) {
FrozenColorizer.deserialize(nbt.getCompound(TAG_PREPACKAGED_COLORIZER)) FrozenColorizer.fromNBT(nbt.getCompound(TAG_PREPACKAGED_COLORIZER))
} else { } else {
null null
} }

View file

@ -3,6 +3,12 @@ package at.petrak.hexcasting.api.spell.casting
import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.SpellDatum
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.getList
import at.petrak.hexcasting.api.utils.hasList
import at.petrak.hexcasting.api.utils.serializeToNBT
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag
import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerLevel
/** /**
@ -32,6 +38,11 @@ sealed interface ContinuationFrame {
*/ */
fun breakDownwards(stack: List<SpellDatum<*>>): Pair<Boolean, List<SpellDatum<*>>> fun breakDownwards(stack: List<SpellDatum<*>>): Pair<Boolean, List<SpellDatum<*>>>
/**
* Serializes this frame. Used for things like delays, where we pause execution.
*/
fun serializeToNBT(): CompoundTag
/** /**
* A list of patterns to be evaluated in sequence. * A list of patterns to be evaluated in sequence.
* @property list the *remaining* list of patterns to be evaluated * @property list the *remaining* list of patterns to be evaluated
@ -60,13 +71,19 @@ sealed interface ContinuationFrame {
} }
} }
override fun serializeToNBT(): CompoundTag {
return NBTBuilder {
"type" %= "evaluate"
"patterns" %= list.serializeToNBT()
}
}
} }
/** /**
* A stack marker representing the end of a Hermes evaluation, * A stack marker representing the end of a Hermes evaluation,
* so that we know when to stop removing frames during a Halt. * so that we know when to stop removing frames during a Halt.
*/ */
class 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<*>>) = Pair(true, stack) override fun breakDownwards(stack: List<SpellDatum<*>>) = Pair(true, stack)
@ -83,6 +100,10 @@ sealed interface ContinuationFrame {
listOf() listOf()
) )
} }
override fun serializeToNBT() = NBTBuilder {
"type" %= "end"
}
} }
/** /**
@ -148,5 +169,31 @@ sealed interface ContinuationFrame {
listOf() listOf()
) )
} }
override fun serializeToNBT() = NBTBuilder {
"type" %= "foreach"
"data" %= data.serializeToNBT()
"code" %= code.serializeToNBT()
if (baseStack != null)
"base" %= baseStack.serializeToNBT()
"accumulator" %= acc.serializeToNBT()
}
}
companion object {
@JvmStatic
fun fromNBT(tag: CompoundTag, world: ServerLevel): ContinuationFrame {
return when (tag.getString("type")) {
"eval" -> Evaluate(SpellList.fromNBT(tag.getList("patterns", Tag.TAG_COMPOUND), world))
"end" -> FinishEval
"foreach" -> ForEach(
SpellList.fromNBT(tag.getList("data", Tag.TAG_COMPOUND), world),
SpellList.fromNBT(tag.getList("code", Tag.TAG_COMPOUND), world),
if (tag.hasList("base", Tag.TAG_COMPOUND)) SpellList.fromNBT(tag.getList("base", Tag.TAG_COMPOUND), world).toList() else null,
SpellList.fromNBT(tag.getList("accumulator", Tag.TAG_COMPOUND), world).toMutableList()
)
else -> Evaluate(SpellList.LList(0, listOf()));
}
}
} }
} }

View file

@ -18,8 +18,8 @@ data class ResolvedPattern(val pattern: HexPattern, val origin: HexCoord, var ty
companion object { companion object {
@JvmStatic @JvmStatic
fun DeserializeFromNBT(tag: CompoundTag): ResolvedPattern { fun fromNBT(tag: CompoundTag): ResolvedPattern {
val pattern = HexPattern.DeserializeFromNBT(tag.getCompound("Pattern")) val pattern = HexPattern.fromNBT(tag.getCompound("Pattern"))
val origin = HexCoord(tag.getInt("OriginQ"), tag.getInt("OriginR")) val origin = HexCoord(tag.getInt("OriginQ"), tag.getInt("OriginR"))
val valid = try { val valid = try {
ResolvedPatternType.valueOf(tag.getString("Valid").uppercase(Locale.ROOT)) ResolvedPatternType.valueOf(tag.getString("Valid").uppercase(Locale.ROOT))

View file

@ -39,7 +39,7 @@ data class SpellCircleContext(val impetusPos: BlockPos, val aabb: AABB, val acti
const val TAG_MAX_Z = "max_z" const val TAG_MAX_Z = "max_z"
const val TAG_PLAYER_ALWAYS_IN_RANGE = "player_always_in_range" const val TAG_PLAYER_ALWAYS_IN_RANGE = "player_always_in_range"
fun DeserializeFromNBT(tag: CompoundTag): SpellCircleContext { fun fromNBT(tag: CompoundTag): SpellCircleContext {
val impX = tag.getInt(TAG_IMPETUS_X) val impX = tag.getInt(TAG_IMPETUS_X)
val impY = tag.getInt(TAG_IMPETUS_Y) val impY = tag.getInt(TAG_IMPETUS_Y)
val impZ = tag.getInt(TAG_IMPETUS_Z) val impZ = tag.getInt(TAG_IMPETUS_Z)

View file

@ -1,6 +1,7 @@
package at.petrak.hexcasting.api.spell.math package at.petrak.hexcasting.api.spell.math
import at.petrak.hexcasting.api.utils.HexUtils import at.petrak.hexcasting.api.utils.findCenter
import at.petrak.hexcasting.api.utils.coordToPx
import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.ByteArrayTag
import net.minecraft.nbt.ByteTag import net.minecraft.nbt.ByteTag
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
@ -103,9 +104,9 @@ data class HexPattern(public val startDir: HexDir, public val angles: MutableLis
*/ */
@JvmOverloads @JvmOverloads
fun getCenter(hexRadius: Float, origin: HexCoord = HexCoord.Origin): Vec2 { fun getCenter(hexRadius: Float, origin: HexCoord = HexCoord.Origin): Vec2 {
val originPx = HexUtils.coordToPx(origin, hexRadius, Vec2.ZERO) val originPx = coordToPx(origin, hexRadius, Vec2.ZERO)
val points = this.toLines(hexRadius, originPx) val points = this.toLines(hexRadius, originPx)
return HexUtils.FindCenter(points) return findCenter(points)
} }
@ -113,7 +114,7 @@ data class HexPattern(public val startDir: HexDir, public val angles: MutableLis
* Convert a hex pattern into a sequence of straight linePoints spanning its points. * Convert a hex pattern into a sequence of straight linePoints spanning its points.
*/ */
fun toLines(hexSize: Float, origin: Vec2): List<Vec2> = fun toLines(hexSize: Float, origin: Vec2): List<Vec2> =
this.positions().map { HexUtils.coordToPx(it, hexSize, origin) } this.positions().map { coordToPx(it, hexSize, origin) }
override fun toString(): String = buildString { override fun toString(): String = buildString {
append("HexPattern[") append("HexPattern[")
@ -128,7 +129,7 @@ data class HexPattern(public val startDir: HexDir, public val angles: MutableLis
const val TAG_ANGLES = "angles" const val TAG_ANGLES = "angles"
@JvmStatic @JvmStatic
fun IsHexPattern(tag: CompoundTag): Boolean { fun isPattern(tag: CompoundTag): Boolean {
return tag.contains(TAG_START_DIR, Tag.TAG_ANY_NUMERIC.toInt()) && tag.contains( return tag.contains(TAG_START_DIR, Tag.TAG_ANY_NUMERIC.toInt()) && tag.contains(
TAG_ANGLES, TAG_ANGLES,
Tag.TAG_BYTE_ARRAY.toInt() Tag.TAG_BYTE_ARRAY.toInt()
@ -136,14 +137,14 @@ data class HexPattern(public val startDir: HexDir, public val angles: MutableLis
} }
@JvmStatic @JvmStatic
fun DeserializeFromNBT(tag: CompoundTag): HexPattern { fun fromNBT(tag: CompoundTag): HexPattern {
val startDir = HexDir.values()[tag.getByte(TAG_START_DIR).toInt()] val startDir = HexDir.values()[tag.getByte(TAG_START_DIR).toInt()]
val angles = tag.getByteArray(TAG_ANGLES).map { HexAngle.values()[it.toInt()] } val angles = tag.getByteArray(TAG_ANGLES).map { HexAngle.values()[it.toInt()] }
return HexPattern(startDir, angles.toMutableList()) return HexPattern(startDir, angles.toMutableList())
} }
@JvmStatic @JvmStatic
fun FromAnglesSig(signature: String, startDir: HexDir): HexPattern { fun fromAngles(signature: String, startDir: HexDir): HexPattern {
val out = HexPattern(startDir) val out = HexPattern(startDir)
var compass = startDir var compass = startDir

View file

@ -18,7 +18,7 @@ class MishapAlreadyBrainswept(val villager: Villager) : Mishap() {
} }
override fun particleSpray(ctx: CastingContext): ParticleSpray { override fun particleSpray(ctx: CastingContext): ParticleSpray {
return ParticleSpray.Burst(villager.eyePosition, 1.0) return ParticleSpray.burst(villager.eyePosition, 1.0)
} }
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component = override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =

View file

@ -20,7 +20,7 @@ class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
} }
override fun particleSpray(ctx: CastingContext): ParticleSpray { override fun particleSpray(ctx: CastingContext): ParticleSpray {
return ParticleSpray.Burst(Vec3.atCenterOf(pos), 1.0) return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
} }
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component { override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {

View file

@ -20,7 +20,7 @@ class MishapBadBrainsweep(val villager: Villager, val pos: BlockPos) : Mishap()
} }
override fun particleSpray(ctx: CastingContext): ParticleSpray { override fun particleSpray(ctx: CastingContext): ParticleSpray {
return ParticleSpray.Burst(Vec3.atCenterOf(pos), 1.0) return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
} }
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component { override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {

View file

@ -1,7 +1,10 @@
@file:JvmName("HexUtils")
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.math.HexCoord import at.petrak.hexcasting.api.spell.math.HexCoord
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.ListTag
import net.minecraft.nbt.LongArrayTag import net.minecraft.nbt.LongArrayTag
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
@ -12,41 +15,34 @@ import kotlin.math.max
import kotlin.math.min import kotlin.math.min
import kotlin.math.roundToInt import kotlin.math.roundToInt
object HexUtils { const val TAU = Math.PI * 2.0
const val SQRT_3 = 1.7320508f const val SQRT_3 = 1.7320508f
@JvmStatic fun Vec3.serializeToNBT(): LongArrayTag =
fun Vec3.serializeToNBT(): LongArrayTag =
LongArrayTag(longArrayOf(this.x.toRawBits(), this.y.toRawBits(), this.z.toRawBits())) LongArrayTag(longArrayOf(this.x.toRawBits(), this.y.toRawBits(), this.z.toRawBits()))
@JvmStatic fun vecFromNBT(tag: LongArray): Vec3 = if (tag.size != 3) Vec3.ZERO else
fun DeserializeVec3FromNBT(tag: LongArray): Vec3 = if (tag.size != 3) Vec3.ZERO else
Vec3( Vec3(
Double.fromBits(tag[0]), Double.fromBits(tag[0]),
Double.fromBits(tag[1]), Double.fromBits(tag[1]),
Double.fromBits(tag[2]) Double.fromBits(tag[2])
) )
@JvmStatic fun Vec2.serializeToNBT(): LongArrayTag =
fun Vec2.serializeToNBT(): LongArrayTag =
LongArrayTag(longArrayOf(this.x.toDouble().toRawBits(), this.y.toDouble().toRawBits())) LongArrayTag(longArrayOf(this.x.toDouble().toRawBits(), this.y.toDouble().toRawBits()))
@JvmStatic fun vec2FromNBT(tag: LongArray): Vec2 = if (tag.size != 2) Vec2.ZERO else
fun DeserializeVec2FromNBT(tag: LongArray): Vec2 = if (tag.size != 2) Vec2.ZERO else
Vec2( Vec2(
Double.fromBits(tag[0]).toFloat(), Double.fromBits(tag[0]).toFloat(),
Double.fromBits(tag[1]).toFloat(), Double.fromBits(tag[1]).toFloat(),
) )
@JvmStatic fun otherHand(hand: InteractionHand) =
fun OtherHand(hand: InteractionHand) =
if (hand == InteractionHand.MAIN_HAND) InteractionHand.OFF_HAND else InteractionHand.MAIN_HAND if (hand == InteractionHand.MAIN_HAND) InteractionHand.OFF_HAND else InteractionHand.MAIN_HAND
@JvmStatic fun fixNAN(x: Double): Double = if (x.isFinite()) x else 0.0
fun FixNANs(x: Double): Double = if (x.isFinite()) x else 0.0
@JvmStatic fun findCenter(points: List<Vec2>): Vec2 {
fun FindCenter(points: List<Vec2>): Vec2 {
var minX = Float.POSITIVE_INFINITY var minX = Float.POSITIVE_INFINITY
var minY = Float.POSITIVE_INFINITY var minY = Float.POSITIVE_INFINITY
var maxX = Float.NEGATIVE_INFINITY var maxX = Float.NEGATIVE_INFINITY
@ -62,17 +58,15 @@ object HexUtils {
(minX + maxX) / 2f, (minX + maxX) / 2f,
(minY + maxY) / 2f (minY + maxY) / 2f
) )
} }
@JvmStatic fun coordToPx(coord: HexCoord, size: Float, offset: Vec2): Vec2 =
fun coordToPx(coord: HexCoord, size: Float, offset: Vec2) =
Vec2( Vec2(
SQRT_3 * coord.q.toFloat() + SQRT_3 / 2.0f * coord.r.toFloat(), SQRT_3 * coord.q.toFloat() + SQRT_3 / 2.0f * coord.r.toFloat(),
1.5f * coord.r.toFloat() 1.5f * coord.r.toFloat()
).scale(size).add(offset) ).scale(size).add(offset)
@JvmStatic fun pxToCoord(px: Vec2, size: Float, offset: Vec2): HexCoord {
fun pxToCoord(px: Vec2, size: Float, offset: Vec2): HexCoord {
val offsetted = px.add(offset.negated()) val offsetted = px.add(offset.negated())
var qf = (SQRT_3 / 3.0f * offsetted.x - 0.33333f * offsetted.y) / size var qf = (SQRT_3 / 3.0f * offsetted.x - 0.33333f * offsetted.y) / size
var rf = (0.66666f * offsetted.y) / size var rf = (0.66666f * offsetted.y) / size
@ -85,15 +79,18 @@ object HexUtils {
HexCoord(q + (qf + 0.5f * rf).roundToInt(), r) HexCoord(q + (qf + 0.5f * rf).roundToInt(), r)
else else
HexCoord(q, r + (rf + 0.5 * qf).roundToInt()) HexCoord(q, r + (rf + 0.5 * qf).roundToInt())
} }
const val TAU = Math.PI * 2.0 fun Iterable<SpellDatum<*>>.serializeToNBT(): ListTag {
val tag = ListTag()
for (elt in this)
tag.add(elt.serializeToNBT())
return tag
}
// Copy the impl from forge // Copy the impl from forge
@JvmStatic fun ItemStack.serializeToNBT(): CompoundTag {
fun ItemStack.serialize(): CompoundTag {
val out = CompoundTag() val out = CompoundTag()
this.save(out) this.save(out)
return out return out
}
} }

View file

@ -0,0 +1,185 @@
@file:Suppress("NOTHING_TO_INLINE")
package at.petrak.hexcasting.api.utils
import net.minecraft.nbt.*
// https://github.com/TeamWizardry/LibrarianLib/blob/9cfb2cf3e35685568942ad41395265a2edc27d30/modules/core/src/main/kotlin/com/teamwizardry/librarianlib/core/util/kotlin/NbtBuilder.kt
@DslMarker
internal annotation class NBTDslMarker
@NBTDslMarker
object NBTBuilder {
inline operator fun invoke(block: NbtCompoundBuilder.() -> Unit) = compound(block)
inline fun use(tag: CompoundTag, block: NbtCompoundBuilder.() -> Unit): CompoundTag =
NbtCompoundBuilder(tag).also(block).tag
inline fun compound(block: NbtCompoundBuilder.() -> Unit): CompoundTag =
NbtCompoundBuilder(CompoundTag()).also(block).tag
inline fun list(block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also(block).tag
inline fun list(vararg elements: Tag, block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also {
it.addAll(elements.toList())
it.block()
}.tag
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())
inline fun long(value: Number): LongTag = LongTag.valueOf(value.toLong())
inline fun int(value: Number): IntTag = IntTag.valueOf(value.toInt())
inline fun short(value: Number): ShortTag = ShortTag.valueOf(value.toShort())
inline fun byte(value: Number): ByteTag = ByteTag.valueOf(value.toByte())
inline fun string(value: String): StringTag = StringTag.valueOf(value)
inline fun byteArray(vararg value: Int): ByteArrayTag = ByteArrayTag(ByteArray(value.size) { value[it].toByte() })
inline fun byteArray(vararg value: Byte): ByteArrayTag = ByteArrayTag(value)
inline fun byteArray(): ByteArrayTag = ByteArrayTag(byteArrayOf()) // avoiding overload ambiguity
inline fun longArray(vararg value: Int): LongArrayTag = LongArrayTag(LongArray(value.size) { value[it].toLong() })
inline fun longArray(vararg value: Long): LongArrayTag = LongArrayTag(value)
inline fun longArray(): LongArrayTag = LongArrayTag(longArrayOf()) // avoiding overload ambiguity
inline fun intArray(vararg value: Int): IntArrayTag = IntArrayTag(value)
}
@JvmInline
@NBTDslMarker
value class NbtCompoundBuilder(val tag: CompoundTag) {
// configuring this tag
inline operator fun String.remAssign(nbt: Tag) {
tag.put(this, nbt)
}
inline operator fun String.remAssign(str: String) {
tag.put(this, string(str))
}
inline operator fun String.remAssign(num: Int) {
tag.put(this, int(num))
}
// creating new tags
inline fun compound(block: NbtCompoundBuilder.() -> Unit): CompoundTag =
NbtCompoundBuilder(CompoundTag()).also { it.block() }.tag
inline fun list(block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also { it.block() }.tag
inline fun list(vararg elements: Tag, block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also {
it.addAll(elements.toList())
it.block()
}.tag
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())
inline fun long(value: Number): LongTag = LongTag.valueOf(value.toLong())
inline fun int(value: Number): IntTag = IntTag.valueOf(value.toInt())
inline fun short(value: Number): ShortTag = ShortTag.valueOf(value.toShort())
inline fun byte(value: Number): ByteTag = ByteTag.valueOf(value.toByte())
inline fun string(value: String): StringTag = StringTag.valueOf(value)
inline fun byteArray(vararg value: Int): ByteArrayTag = ByteArrayTag(ByteArray(value.size) { value[it].toByte() })
inline fun byteArray(vararg value: Byte): ByteArrayTag = ByteArrayTag(value)
inline fun byteArray(): ByteArrayTag = ByteArrayTag(byteArrayOf()) // avoiding overload ambiguity
inline fun longArray(vararg value: Int): LongArrayTag = LongArrayTag(LongArray(value.size) { value[it].toLong() })
inline fun longArray(vararg value: Long): LongArrayTag = LongArrayTag(value)
inline fun longArray(): LongArrayTag = LongArrayTag(longArrayOf()) // avoiding overload ambiguity
inline fun intArray(vararg value: Int): IntArrayTag = IntArrayTag(value)
}
@JvmInline
@NBTDslMarker
value class NbtListBuilder(val tag: ListTag) {
// configuring this tag
/**
* Add the given Tag<* tag to this list
*/
operator fun Tag.unaryPlus() {
tag.add(this)
}
/**
* Add the given Tag<* tags to this list
*/
operator fun Collection<Tag>.unaryPlus() {
tag.addAll(this)
}
/**
* Add the given Tag<* tag to this list. This is explicitly defined for [ListTag] because otherwise there is overload
* ambiguity between the [Tag<*] and [Collection]<[Tag<*]> methods.
*/
operator fun ListTag.unaryPlus() {
tag.add(this)
}
fun addAll(nbt: Collection<Tag>) {
this.tag.addAll(nbt)
}
fun add(nbt: Tag) {
this.tag.add(nbt)
}
// creating new tags
inline fun compound(block: NbtCompoundBuilder.() -> Unit): CompoundTag =
NbtCompoundBuilder(CompoundTag()).also { it.block() }.tag
inline fun list(block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also { it.block() }.tag
inline fun list(vararg elements: Tag, block: NbtListBuilder.() -> Unit): ListTag =
NbtListBuilder(ListTag()).also {
it.addAll(elements.toList())
it.block()
}.tag
inline fun list(vararg elements: Tag): ListTag = ListTag().also { it.addAll(elements) }
inline fun list(elements: Collection<Tag>): ListTag = ListTag().also { it.addAll(elements) }
inline fun double(value: Number): DoubleTag = DoubleTag.valueOf(value.toDouble())
inline fun float(value: Number): FloatTag = FloatTag.valueOf(value.toFloat())
inline fun long(value: Number): LongTag = LongTag.valueOf(value.toLong())
inline fun int(value: Number): IntTag = IntTag.valueOf(value.toInt())
inline fun short(value: Number): ShortTag = ShortTag.valueOf(value.toShort())
inline fun byte(value: Number): ByteTag = ByteTag.valueOf(value.toByte())
inline fun string(value: String): StringTag = StringTag.valueOf(value)
inline fun byteArray(vararg value: Int): ByteArrayTag = ByteArrayTag(ByteArray(value.size) { value[it].toByte() })
inline fun byteArray(vararg value: Byte): ByteArrayTag = ByteArrayTag(value)
inline fun byteArray(): ByteArrayTag = ByteArrayTag(byteArrayOf()) // avoiding overload ambiguity
inline fun longArray(vararg value: Int): LongArrayTag = LongArrayTag(LongArray(value.size) { value[it].toLong() })
inline fun longArray(vararg value: Long): LongArrayTag = LongArrayTag(value)
inline fun longArray(): LongArrayTag = LongArrayTag(longArrayOf()) // avoiding overload ambiguity
inline fun intArray(vararg value: Int): IntArrayTag = IntArrayTag(value)
inline fun doubles(vararg value: Int): List<DoubleTag> = value.map { DoubleTag.valueOf(it.toDouble()) }
inline fun doubles(vararg value: Double): List<DoubleTag> = value.map { DoubleTag.valueOf(it) }
inline fun floats(vararg value: Int): List<FloatTag> = value.map { FloatTag.valueOf(it.toFloat()) }
inline fun floats(vararg value: Float): List<FloatTag> = value.map { FloatTag.valueOf(it) }
inline fun longs(vararg value: Int): List<LongTag> = value.map { LongTag.valueOf(it.toLong()) }
inline fun longs(vararg value: Long): List<LongTag> = value.map { LongTag.valueOf(it) }
inline fun ints(vararg value: Int): List<IntTag> = value.map { IntTag.valueOf(it) }
inline fun shorts(vararg value: Int): List<ShortTag> = value.map { ShortTag.valueOf(it.toShort()) }
inline fun shorts(vararg value: Short): List<ShortTag> = value.map { ShortTag.valueOf(it) }
inline fun bytes(vararg value: Int): List<ByteTag> = value.map { ByteTag.valueOf(it.toByte()) }
inline fun bytes(vararg value: Byte): List<ByteTag> = value.map { ByteTag.valueOf(it) }
fun strings(vararg value: String): List<StringTag> = value.map { StringTag.valueOf(it) }
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.client
import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.spell.math.HexPattern import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.api.utils.HexUtils import at.petrak.hexcasting.api.utils.TAU
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
@ -191,7 +191,7 @@ object RenderLib {
// as well as some random variance... // as well as some random variance...
// (We use i, j (segment #, subsegment #) as seeds for the Perlin noise, // (We use i, j (segment #, subsegment #) as seeds for the Perlin noise,
// and zSeed (i.e. time elapsed) to perturb the shape gradually over time) // and zSeed (i.e. time elapsed) to perturb the shape gradually over time)
val theta = (3 * NOISE.getValue(i.toDouble(), j.toDouble(), zSeed) * HexUtils.TAU).toFloat() val theta = (3 * NOISE.getValue(i.toDouble(), j.toDouble(), zSeed) * TAU).toFloat()
val r = NOISE.getValue(i.inv().toDouble(), j.toDouble(), zSeed).toFloat() * maxVariance val r = NOISE.getValue(i.inv().toDouble(), j.toDouble(), zSeed).toFloat() * maxVariance
val randomHop = Vec2(r * Mth.cos(theta), r * Mth.sin(theta)) val randomHop = Vec2(r * Mth.cos(theta), r * Mth.sin(theta))
position = position.add(hop).add(randomHop) position = position.add(hop).add(randomHop)
@ -223,7 +223,7 @@ object RenderLib {
val fracOfCircle = 6 val fracOfCircle = 6
// run 0 AND last; this way the circle closes // run 0 AND last; this way the circle closes
for (i in 0..fracOfCircle) { for (i in 0..fracOfCircle) {
val theta = i.toFloat() / fracOfCircle * HexUtils.TAU.toFloat() val theta = i.toFloat() / fracOfCircle * TAU.toFloat()
val rx = Mth.cos(theta) * radius + point.x val rx = Mth.cos(theta) * radius + point.x
val ry = Mth.sin(theta) * radius + point.y val ry = Mth.sin(theta) * radius + point.y
buf.vertex(mat, rx, ry, 1f).color(r, g, b, a).endVertex() buf.vertex(mat, rx, ry, 1f).color(r, g, b, a).endVertex()

View file

@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.math.HexAngle
import at.petrak.hexcasting.api.spell.math.HexCoord import at.petrak.hexcasting.api.spell.math.HexCoord
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.utils.HexUtils import at.petrak.hexcasting.api.utils.otherHand
import at.petrak.hexcasting.client.RenderLib import at.petrak.hexcasting.client.RenderLib
import at.petrak.hexcasting.client.sound.GridSoundInstance import at.petrak.hexcasting.client.sound.GridSoundInstance
import at.petrak.hexcasting.common.items.ItemSpellbook import at.petrak.hexcasting.common.items.ItemSpellbook
@ -231,7 +231,7 @@ class GuiSpellcasting(
override fun mouseScrolled(pMouseX: Double, pMouseY: Double, pDelta: Double): Boolean { override fun mouseScrolled(pMouseX: Double, pMouseY: Double, pDelta: Double): Boolean {
super.mouseScrolled(pMouseX, pMouseY, pDelta) super.mouseScrolled(pMouseX, pMouseY, pDelta)
val otherHand = HexUtils.OtherHand(this.handOpenedWith) val otherHand = otherHand(this.handOpenedWith)
if (Minecraft.getInstance().player!!.getItemInHand(otherHand).item is ItemSpellbook) if (Minecraft.getInstance().player!!.getItemInHand(otherHand).item is ItemSpellbook)
IClientXplatAbstractions.INSTANCE.sendPacketToServer( IClientXplatAbstractions.INSTANCE.sendPacketToServer(
MsgShiftScrollSyn( MsgShiftScrollSyn(
@ -338,7 +338,7 @@ class GuiSpellcasting(
/** Distance between adjacent hex centers */ /** Distance between adjacent hex centers */
fun hexSize(): Float { fun hexSize(): Float {
val hasLens = Minecraft.getInstance().player!! val hasLens = Minecraft.getInstance().player!!
.getItemInHand(HexUtils.OtherHand(this.handOpenedWith)).`is`(HexItems.SCRYING_LENS) .getItemInHand(otherHand(this.handOpenedWith)).`is`(HexItems.SCRYING_LENS)
// Originally, we allowed 32 dots across. Assuming a 1920x1080 screen this allowed like 500-odd area. // Originally, we allowed 32 dots across. Assuming a 1920x1080 screen this allowed like 500-odd area.
// Let's be generous and give them 512. // Let's be generous and give them 512.
@ -348,8 +348,9 @@ class GuiSpellcasting(
fun coordsOffset(): Vec2 = Vec2(this.width.toFloat() * 0.5f, this.height.toFloat() * 0.5f) fun coordsOffset(): Vec2 = Vec2(this.width.toFloat() * 0.5f, this.height.toFloat() * 0.5f)
fun coordToPx(coord: HexCoord) = HexUtils.coordToPx(coord, this.hexSize(), this.coordsOffset()) fun coordToPx(coord: HexCoord) =
fun pxToCoord(px: Vec2) = HexUtils.pxToCoord(px, this.hexSize(), this.coordsOffset()) at.petrak.hexcasting.api.utils.coordToPx(coord, this.hexSize(), this.coordsOffset())
fun pxToCoord(px: Vec2) = at.petrak.hexcasting.api.utils.pxToCoord(px, this.hexSize(), this.coordsOffset())
private sealed class PatternDrawState { private sealed class PatternDrawState {

View file

@ -70,8 +70,8 @@ public class BlockEntityAkashicBookshelf extends HexBlockEntity {
} else { } else {
this.recordPos = null; this.recordPos = null;
} }
if (HexPattern.IsHexPattern(pattern)) { if (HexPattern.isPattern(pattern)) {
this.pattern = HexPattern.DeserializeFromNBT(pattern); this.pattern = HexPattern.fromNBT(pattern);
} else { } else {
this.pattern = null; this.pattern = null;
} }

View file

@ -81,14 +81,14 @@ public class BlockEntityAkashicRecord extends HexBlockEntity {
if (entry == null) { if (entry == null) {
return null; return null;
} else { } else {
return SpellDatum.DeserializeFromNBT(entry.datum, slevel); return SpellDatum.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.DisplayFromTag(entry.datum); return SpellDatum.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);
} }

View file

@ -32,8 +32,8 @@ public class BlockEntitySlate extends HexBlockEntity {
protected void loadModData(CompoundTag tag) { protected void loadModData(CompoundTag tag) {
if (tag.contains(TAG_PATTERN, Tag.TAG_COMPOUND)) { if (tag.contains(TAG_PATTERN, Tag.TAG_COMPOUND)) {
CompoundTag patternTag = tag.getCompound(TAG_PATTERN); CompoundTag patternTag = tag.getCompound(TAG_PATTERN);
if (HexPattern.IsHexPattern(patternTag)) { if (HexPattern.isPattern(patternTag)) {
this.pattern = HexPattern.DeserializeFromNBT(patternTag); this.pattern = HexPattern.fromNBT(patternTag);
} else { } else {
this.pattern = null; this.pattern = null;
} }

View file

@ -90,12 +90,12 @@ public class BlockEntityConjured extends HexBlockEntity {
@Override @Override
protected void saveModData(CompoundTag tag) { protected void saveModData(CompoundTag tag) {
tag.put(TAG_COLORIZER, this.colorizer.serialize()); tag.put(TAG_COLORIZER, this.colorizer.serializeToNBT());
} }
@Override @Override
protected void loadModData(CompoundTag tag) { protected void loadModData(CompoundTag tag) {
this.colorizer = FrozenColorizer.deserialize(tag.getCompound(TAG_COLORIZER)); this.colorizer = FrozenColorizer.fromNBT(tag.getCompound(TAG_COLORIZER));
} }
public FrozenColorizer getColorizer() { public FrozenColorizer getColorizer() {

View file

@ -16,7 +16,6 @@ import at.petrak.hexcasting.common.casting.operators.circles.OpCircleBounds;
import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusDir; import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusDir;
import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusPos; import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusPos;
import at.petrak.hexcasting.common.casting.operators.eval.OpEval; import at.petrak.hexcasting.common.casting.operators.eval.OpEval;
import at.petrak.hexcasting.common.casting.operators.eval.OpEvalDelay;
import at.petrak.hexcasting.common.casting.operators.eval.OpForEach; import at.petrak.hexcasting.common.casting.operators.eval.OpForEach;
import at.petrak.hexcasting.common.casting.operators.eval.OpHalt; import at.petrak.hexcasting.common.casting.operators.eval.OpHalt;
import at.petrak.hexcasting.common.casting.operators.lists.*; import at.petrak.hexcasting.common.casting.operators.lists.*;
@ -52,417 +51,417 @@ public class RegisterPatterns {
// - CW is the special or destruction version // - CW is the special or destruction version
// == Getters == // == Getters ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaq", HexDir.NORTH_EAST), modLoc("get_caster"), PatternRegistry.mapPattern(HexPattern.fromAngles("qaq", HexDir.NORTH_EAST), modLoc("get_caster"),
OpGetCaster.INSTANCE); OpGetCaster.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aa", HexDir.EAST), modLoc("get_entity_pos"), PatternRegistry.mapPattern(HexPattern.fromAngles("aa", HexDir.EAST), modLoc("get_entity_pos"),
OpEntityPos.INSTANCE); OpEntityPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wa", HexDir.EAST), modLoc("get_entity_look"), PatternRegistry.mapPattern(HexPattern.fromAngles("wa", HexDir.EAST), modLoc("get_entity_look"),
OpEntityLook.INSTANCE); OpEntityLook.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awq", HexDir.NORTH_EAST), modLoc("get_entity_height"), PatternRegistry.mapPattern(HexPattern.fromAngles("awq", HexDir.NORTH_EAST), modLoc("get_entity_height"),
OpEntityHeight.INSTANCE); OpEntityHeight.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wq", HexDir.EAST), modLoc("get_entity_velocity"), PatternRegistry.mapPattern(HexPattern.fromAngles("wq", HexDir.EAST), modLoc("get_entity_velocity"),
OpEntityVelocity.INSTANCE); OpEntityVelocity.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaawdd", HexDir.EAST), modLoc("raycast"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqaawdd", HexDir.EAST), modLoc("raycast"),
OpBlockRaycast.INSTANCE); OpBlockRaycast.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weddwaa", HexDir.EAST), modLoc("raycast/axis"), PatternRegistry.mapPattern(HexPattern.fromAngles("weddwaa", HexDir.EAST), modLoc("raycast/axis"),
OpBlockAxisRaycast.INSTANCE); OpBlockAxisRaycast.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weaqa", HexDir.EAST), modLoc("raycast/entity"), PatternRegistry.mapPattern(HexPattern.fromAngles("weaqa", HexDir.EAST), modLoc("raycast/entity"),
OpEntityRaycast.INSTANCE); OpEntityRaycast.INSTANCE);
// == spell circle getters == // == spell circle getters ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqae", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("eaqwqae", HexDir.SOUTH_WEST),
modLoc("circle/impetus_pos"), OpImpetusPos.INSTANCE); modLoc("circle/impetus_pos"), OpImpetusPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewede", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("eaqwqaewede", HexDir.SOUTH_WEST),
modLoc("circle/impetus_dir"), OpImpetusDir.INSTANCE); modLoc("circle/impetus_dir"), OpImpetusDir.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewdd", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("eaqwqaewdd", HexDir.SOUTH_WEST),
modLoc("circle/bounds/min"), new OpCircleBounds(false)); modLoc("circle/bounds/min"), new OpCircleBounds(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqwqawaaqa", HexDir.WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("aqwqawaaqa", HexDir.WEST),
modLoc("circle/bounds/max"), new OpCircleBounds(true)); modLoc("circle/bounds/max"), new OpCircleBounds(true));
// == Modify Stack == // == Modify Stack ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaa", HexDir.EAST), modLoc("duplicate"), PatternRegistry.mapPattern(HexPattern.fromAngles("aadaa", HexDir.EAST), modLoc("duplicate"),
OpDuplicate.INSTANCE); OpDuplicate.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaadaa", HexDir.EAST), modLoc("duplicate_n"), PatternRegistry.mapPattern(HexPattern.fromAngles("aadaadaa", HexDir.EAST), modLoc("duplicate_n"),
OpDuplicateN.INSTANCE); OpDuplicateN.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwaeawqaeaqa", HexDir.NORTH_WEST), modLoc("stack_len"), PatternRegistry.mapPattern(HexPattern.fromAngles("qwaeawqaeaqa", HexDir.NORTH_WEST), modLoc("stack_len"),
OpStackSize.INSTANCE); OpStackSize.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawdd", HexDir.EAST), modLoc("swap"), OpSwap.INSTANCE); PatternRegistry.mapPattern(HexPattern.fromAngles("aawdd", HexDir.EAST), modLoc("swap"), OpSwap.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddad", HexDir.WEST), modLoc("fisherman"), PatternRegistry.mapPattern(HexPattern.fromAngles("ddad", HexDir.WEST), modLoc("fisherman"),
OpFisherman.INSTANCE); OpFisherman.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaawdde", HexDir.SOUTH_EAST), modLoc("swizzle"), PatternRegistry.mapPattern(HexPattern.fromAngles("qaawdde", HexDir.SOUTH_EAST), modLoc("swizzle"),
OpAlwinfyHasAscendedToABeingOfPureMath.INSTANCE); OpAlwinfyHasAscendedToABeingOfPureMath.INSTANCE);
// == Math == // == Math ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waaw", HexDir.NORTH_EAST), modLoc("add"), PatternRegistry.mapPattern(HexPattern.fromAngles("waaw", HexDir.NORTH_EAST), modLoc("add"),
OpAdd.INSTANCE); OpAdd.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wddw", HexDir.NORTH_WEST), modLoc("sub"), PatternRegistry.mapPattern(HexPattern.fromAngles("wddw", HexDir.NORTH_WEST), modLoc("sub"),
OpSub.INSTANCE); OpSub.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqaw", HexDir.SOUTH_EAST), modLoc("mul_dot"), PatternRegistry.mapPattern(HexPattern.fromAngles("waqaw", HexDir.SOUTH_EAST), modLoc("mul_dot"),
OpMulDot.INSTANCE); OpMulDot.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdedw", HexDir.NORTH_EAST), modLoc("div_cross"), PatternRegistry.mapPattern(HexPattern.fromAngles("wdedw", HexDir.NORTH_EAST), modLoc("div_cross"),
OpDivCross.INSTANCE); OpDivCross.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqw", HexDir.NORTH_EAST), modLoc("abs_len"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqaqw", HexDir.NORTH_EAST), modLoc("abs_len"),
OpAbsLen.INSTANCE); OpAbsLen.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wedew", HexDir.NORTH_WEST), modLoc("pow_proj"), PatternRegistry.mapPattern(HexPattern.fromAngles("wedew", HexDir.NORTH_WEST), modLoc("pow_proj"),
OpPowProj.INSTANCE); OpPowProj.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewq", HexDir.EAST), modLoc("floor"), PatternRegistry.mapPattern(HexPattern.fromAngles("ewq", HexDir.EAST), modLoc("floor"),
OpFloor.INSTANCE); OpFloor.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwe", HexDir.EAST), modLoc("ceil"), PatternRegistry.mapPattern(HexPattern.fromAngles("qwe", HexDir.EAST), modLoc("ceil"),
OpCeil.INSTANCE); OpCeil.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqqqq", HexDir.EAST), modLoc("construct_vec"), PatternRegistry.mapPattern(HexPattern.fromAngles("eqqqqq", HexDir.EAST), modLoc("construct_vec"),
OpConstructVec.INSTANCE); OpConstructVec.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeeeee", HexDir.EAST), modLoc("deconstruct_vec"), PatternRegistry.mapPattern(HexPattern.fromAngles("qeeeee", HexDir.EAST), modLoc("deconstruct_vec"),
OpDeconstructVec.INSTANCE); OpDeconstructVec.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaww", HexDir.NORTH_WEST), modLoc("coerce_axial"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqaww", HexDir.NORTH_WEST), modLoc("coerce_axial"),
OpCoerceToAxial.INSTANCE); OpCoerceToAxial.INSTANCE);
// == Logic == // == Logic ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdw", HexDir.NORTH_EAST), modLoc("and"), PatternRegistry.mapPattern(HexPattern.fromAngles("wdw", HexDir.NORTH_EAST), modLoc("and"),
OpBoolAnd.INSTANCE); OpBoolAnd.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waw", HexDir.SOUTH_EAST), modLoc("or"), PatternRegistry.mapPattern(HexPattern.fromAngles("waw", HexDir.SOUTH_EAST), modLoc("or"),
OpBoolOr.INSTANCE); OpBoolOr.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dwa", HexDir.NORTH_WEST), modLoc("xor"), PatternRegistry.mapPattern(HexPattern.fromAngles("dwa", HexDir.NORTH_WEST), modLoc("xor"),
OpBoolXor.INSTANCE); OpBoolXor.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("e", HexDir.SOUTH_EAST), modLoc("greater"), PatternRegistry.mapPattern(HexPattern.fromAngles("e", HexDir.SOUTH_EAST), modLoc("greater"),
new OpCompare(false, (a, b) -> a > b)); new OpCompare(false, (a, b) -> a > b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("q", HexDir.SOUTH_WEST), modLoc("less"), PatternRegistry.mapPattern(HexPattern.fromAngles("q", HexDir.SOUTH_WEST), modLoc("less"),
new OpCompare(false, (a, b) -> a < b)); new OpCompare(false, (a, b) -> a < b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ee", HexDir.SOUTH_EAST), modLoc("greater_eq"), PatternRegistry.mapPattern(HexPattern.fromAngles("ee", HexDir.SOUTH_EAST), modLoc("greater_eq"),
new OpCompare(true, (a, b) -> a >= b)); new OpCompare(true, (a, b) -> a >= b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qq", HexDir.SOUTH_WEST), modLoc("less_eq"), PatternRegistry.mapPattern(HexPattern.fromAngles("qq", HexDir.SOUTH_WEST), modLoc("less_eq"),
new OpCompare(true, (a, b) -> a <= b)); new OpCompare(true, (a, b) -> a <= b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ad", HexDir.EAST), modLoc("equals"), PatternRegistry.mapPattern(HexPattern.fromAngles("ad", HexDir.EAST), modLoc("equals"),
new OpEquality(false)); new OpEquality(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("da", HexDir.EAST), modLoc("not_equals"), PatternRegistry.mapPattern(HexPattern.fromAngles("da", HexDir.EAST), modLoc("not_equals"),
new OpEquality(true)); new OpEquality(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dw", HexDir.NORTH_WEST), modLoc("not"), PatternRegistry.mapPattern(HexPattern.fromAngles("dw", HexDir.NORTH_WEST), modLoc("not"),
OpBoolNot.INSTANCE); OpBoolNot.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aw", HexDir.NORTH_EAST), modLoc("identity"), PatternRegistry.mapPattern(HexPattern.fromAngles("aw", HexDir.NORTH_EAST), modLoc("identity"),
OpBoolIdentityKindOf.INSTANCE); OpBoolIdentityKindOf.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqq", HexDir.NORTH_WEST), modLoc("random"), PatternRegistry.mapPattern(HexPattern.fromAngles("eqqq", HexDir.NORTH_WEST), modLoc("random"),
OpRandom.INSTANCE); OpRandom.INSTANCE);
// == Advanced Math == // == Advanced Math ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaa", HexDir.SOUTH_EAST), modLoc("sin"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqaa", HexDir.SOUTH_EAST), modLoc("sin"),
OpSin.INSTANCE); OpSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqad", HexDir.SOUTH_EAST), modLoc("cos"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqad", HexDir.SOUTH_EAST), modLoc("cos"),
OpCos.INSTANCE); OpCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqqqqqadq", HexDir.SOUTH_WEST), modLoc("tan"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqqqqqadq", HexDir.SOUTH_WEST), modLoc("tan"),
OpTan.INSTANCE); OpTan.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddeeeee", HexDir.SOUTH_EAST), modLoc("arcsin"), PatternRegistry.mapPattern(HexPattern.fromAngles("ddeeeee", HexDir.SOUTH_EAST), modLoc("arcsin"),
OpArcSin.INSTANCE); OpArcSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeeee", HexDir.NORTH_EAST), modLoc("arccos"), PatternRegistry.mapPattern(HexPattern.fromAngles("adeeeee", HexDir.NORTH_EAST), modLoc("arccos"),
OpArcCos.INSTANCE); OpArcCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eadeeeeew", HexDir.NORTH_EAST), modLoc("arctan"), PatternRegistry.mapPattern(HexPattern.fromAngles("eadeeeeew", HexDir.NORTH_EAST), modLoc("arctan"),
OpArcTan.INSTANCE); OpArcTan.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqaqe", HexDir.NORTH_WEST), modLoc("logarithm"), PatternRegistry.mapPattern(HexPattern.fromAngles("eqaqe", HexDir.NORTH_WEST), modLoc("logarithm"),
OpLog.INSTANCE); OpLog.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("addwaad", HexDir.NORTH_EAST), modLoc("modulo"), PatternRegistry.mapPattern(HexPattern.fromAngles("addwaad", HexDir.NORTH_EAST), modLoc("modulo"),
OpModulo.INSTANCE); OpModulo.INSTANCE);
// == Sets == // == Sets ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdweaqa", HexDir.NORTH_EAST), modLoc("and_bit"), PatternRegistry.mapPattern(HexPattern.fromAngles("wdweaqa", HexDir.NORTH_EAST), modLoc("and_bit"),
OpAnd.INSTANCE); OpAnd.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waweaqa", HexDir.SOUTH_EAST), modLoc("or_bit"), PatternRegistry.mapPattern(HexPattern.fromAngles("waweaqa", HexDir.SOUTH_EAST), modLoc("or_bit"),
OpOr.INSTANCE); OpOr.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dwaeaqa", HexDir.NORTH_WEST), modLoc("xor_bit"), PatternRegistry.mapPattern(HexPattern.fromAngles("dwaeaqa", HexDir.NORTH_WEST), modLoc("xor_bit"),
OpXor.INSTANCE); OpXor.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dweaqa", HexDir.NORTH_WEST), modLoc("not_bit"), PatternRegistry.mapPattern(HexPattern.fromAngles("dweaqa", HexDir.NORTH_WEST), modLoc("not_bit"),
OpNot.INSTANCE); OpNot.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aweaqa", HexDir.NORTH_EAST), modLoc("to_set"), PatternRegistry.mapPattern(HexPattern.fromAngles("aweaqa", HexDir.NORTH_EAST), modLoc("to_set"),
OpToSet.INSTANCE); OpToSet.INSTANCE);
// == Spells == // == Spells ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("de", HexDir.NORTH_EAST), modLoc("print"), PatternRegistry.mapPattern(HexPattern.fromAngles("de", HexDir.NORTH_EAST), modLoc("print"),
OpPrint.INSTANCE); OpPrint.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawaawaa", HexDir.EAST), modLoc("explode"), PatternRegistry.mapPattern(HexPattern.fromAngles("aawaawaa", HexDir.EAST), modLoc("explode"),
new OpExplode(false)); new OpExplode(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddwddwdd", HexDir.EAST), modLoc("explode/fire"), PatternRegistry.mapPattern(HexPattern.fromAngles("ddwddwdd", HexDir.EAST), modLoc("explode/fire"),
new OpExplode(true)); new OpExplode(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaqw", HexDir.SOUTH_WEST), modLoc("add_motion"), PatternRegistry.mapPattern(HexPattern.fromAngles("awqqqwaqw", HexDir.SOUTH_WEST), modLoc("add_motion"),
OpAddMotion.INSTANCE); OpAddMotion.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaq", HexDir.SOUTH_WEST), modLoc("blink"), PatternRegistry.mapPattern(HexPattern.fromAngles("awqqqwaq", HexDir.SOUTH_WEST), modLoc("blink"),
OpBlink.INSTANCE); OpBlink.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaqqqqq", HexDir.EAST), modLoc("break_block"), PatternRegistry.mapPattern(HexPattern.fromAngles("qaqqqqq", HexDir.EAST), modLoc("break_block"),
OpBreakBlock.INSTANCE); OpBreakBlock.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeede", HexDir.SOUTH_WEST), modLoc("place_block"), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeede", HexDir.SOUTH_WEST), modLoc("place_block"),
OpPlaceBlock.INSTANCE); OpPlaceBlock.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awddwqawqwawq", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("awddwqawqwawq", HexDir.EAST),
modLoc("colorize"), modLoc("colorize"),
OpColorize.INSTANCE); OpColorize.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqawqadaq", HexDir.SOUTH_EAST), modLoc("create_water"), PatternRegistry.mapPattern(HexPattern.fromAngles("aqawqadaq", HexDir.SOUTH_EAST), modLoc("create_water"),
OpCreateWater.INSTANCE); OpCreateWater.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedwedade", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("dedwedade", HexDir.SOUTH_WEST),
modLoc("destroy_water"), modLoc("destroy_water"),
OpDestroyWater.INSTANCE); OpDestroyWater.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaqawawa", HexDir.SOUTH_EAST), modLoc("ignite"), PatternRegistry.mapPattern(HexPattern.fromAngles("aaqawawa", HexDir.SOUTH_EAST), modLoc("ignite"),
OpIgnite.INSTANCE); OpIgnite.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddedwdwd", HexDir.SOUTH_WEST), modLoc("extinguish"), PatternRegistry.mapPattern(HexPattern.fromAngles("ddedwdwd", HexDir.SOUTH_WEST), modLoc("extinguish"),
OpExtinguish.INSTANCE); OpExtinguish.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqa", HexDir.NORTH_EAST), modLoc("conjure_block"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqa", HexDir.NORTH_EAST), modLoc("conjure_block"),
new OpConjure(false)); new OpConjure(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqd", HexDir.NORTH_EAST), modLoc("conjure_light"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqd", HexDir.NORTH_EAST), modLoc("conjure_light"),
new OpConjure(true)); new OpConjure(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwawqaqw", HexDir.NORTH_EAST), modLoc("bonemeal"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqaqwawqaqw", HexDir.NORTH_EAST), modLoc("bonemeal"),
OpTheOnlyReasonAnyoneDownloadedPsi.INSTANCE); OpTheOnlyReasonAnyoneDownloadedPsi.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwaeaeaeaeaea", HexDir.NORTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwaeaeaeaeaea", HexDir.NORTH_WEST),
modLoc("recharge"), modLoc("recharge"),
OpRecharge.INSTANCE); OpRecharge.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdqawwaww", HexDir.EAST), modLoc("erase"), PatternRegistry.mapPattern(HexPattern.fromAngles("qdqawwaww", HexDir.EAST), modLoc("erase"),
new OpErase()); new OpErase());
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwd", HexDir.NORTH_EAST), modLoc("edify"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqaqwd", HexDir.NORTH_EAST), modLoc("edify"),
OpEdifySapling.INSTANCE); OpEdifySapling.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adaa", HexDir.WEST), modLoc("beep"), PatternRegistry.mapPattern(HexPattern.fromAngles("adaa", HexDir.WEST), modLoc("beep"),
OpBeep.INSTANCE); OpBeep.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqqqqq", HexDir.EAST), modLoc("craft/cypher"), PatternRegistry.mapPattern(HexPattern.fromAngles("waqqqqq", HexDir.EAST), modLoc("craft/cypher"),
new OpMakePackagedSpell<>(HexItems.CYPHER, ManaConstants.CRYSTAL_UNIT)); new OpMakePackagedSpell<>(HexItems.CYPHER, ManaConstants.CRYSTAL_UNIT));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwaqqqqqeaqeaeqqqeaeq", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("wwaqqqqqeaqeaeqqqeaeq", HexDir.EAST),
modLoc("craft/trinket"), modLoc("craft/trinket"),
new OpMakePackagedSpell<>(HexItems.TRINKET, 5 * ManaConstants.CRYSTAL_UNIT)); new OpMakePackagedSpell<>(HexItems.TRINKET, 5 * ManaConstants.CRYSTAL_UNIT));
PatternRegistry.mapPattern( PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("wwaqqqqqeawqwqwqwqwqwwqqeadaeqqeqqeadaeqq", HexDir.EAST), HexPattern.fromAngles("wwaqqqqqeawqwqwqwqwqwwqqeadaeqqeqqeadaeqq", HexDir.EAST),
modLoc("craft/artifact"), modLoc("craft/artifact"),
new OpMakePackagedSpell<>(HexItems.ARTIFACT, 10 * ManaConstants.CRYSTAL_UNIT)); new OpMakePackagedSpell<>(HexItems.ARTIFACT, 10 * ManaConstants.CRYSTAL_UNIT));
PatternRegistry.mapPattern( PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("aqqqaqwwaqqqqqeqaqqqawwqwqwqwqwqw", HexDir.SOUTH_WEST), HexPattern.fromAngles("aqqqaqwwaqqqqqeqaqqqawwqwqwqwqwqw", HexDir.SOUTH_WEST),
modLoc("craft/battery"), modLoc("craft/battery"),
OpMakeBattery.INSTANCE, OpMakeBattery.INSTANCE,
true); true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaqwawaw", HexDir.NORTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqaqwawaw", HexDir.NORTH_WEST),
modLoc("potion/weakness"), modLoc("potion/weakness"),
new OpPotionEffect(MobEffects.WEAKNESS, ManaConstants.DUST_UNIT / 10, true, false, false)); new OpPotionEffect(MobEffects.WEAKNESS, ManaConstants.DUST_UNIT / 10, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqawwawawd", HexDir.WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqawwawawd", HexDir.WEST),
modLoc("potion/levitation"), modLoc("potion/levitation"),
new OpPotionEffect(MobEffects.LEVITATION, ManaConstants.DUST_UNIT / 5, false, false, false)); new OpPotionEffect(MobEffects.LEVITATION, ManaConstants.DUST_UNIT / 5, false, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaewawawe", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqaewawawe", HexDir.SOUTH_WEST),
modLoc("potion/wither"), modLoc("potion/wither"),
new OpPotionEffect(MobEffects.WITHER, ManaConstants.DUST_UNIT, true, false, false)); new OpPotionEffect(MobEffects.WITHER, ManaConstants.DUST_UNIT, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqadwawaww", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqadwawaww", HexDir.SOUTH_EAST),
modLoc("potion/poison"), modLoc("potion/poison"),
new OpPotionEffect(MobEffects.POISON, ManaConstants.DUST_UNIT / 3, true, false, false)); new OpPotionEffect(MobEffects.POISON, ManaConstants.DUST_UNIT / 3, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqadwawaw", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqadwawaw", HexDir.SOUTH_EAST),
modLoc("potion/slowness"), modLoc("potion/slowness"),
new OpPotionEffect(MobEffects.MOVEMENT_SLOWDOWN, ManaConstants.DUST_UNIT / 3, true, false, false)); new OpPotionEffect(MobEffects.MOVEMENT_SLOWDOWN, ManaConstants.DUST_UNIT / 3, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqaawawaedd", HexDir.NORTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqaawawaedd", HexDir.NORTH_WEST),
modLoc("potion/regeneration"), modLoc("potion/regeneration"),
new OpPotionEffect(MobEffects.REGENERATION, ManaConstants.DUST_UNIT, true, true, true), true); new OpPotionEffect(MobEffects.REGENERATION, ManaConstants.DUST_UNIT, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaawawaeqdd", HexDir.WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqaawawaeqdd", HexDir.WEST),
modLoc("potion/night_vision"), modLoc("potion/night_vision"),
new OpPotionEffect(MobEffects.NIGHT_VISION, ManaConstants.DUST_UNIT / 5, false, true, true), true); new OpPotionEffect(MobEffects.NIGHT_VISION, ManaConstants.DUST_UNIT / 5, false, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaawawaeqqdd", HexDir.SOUTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqaawawaeqqdd", HexDir.SOUTH_WEST),
modLoc("potion/absorption"), modLoc("potion/absorption"),
new OpPotionEffect(MobEffects.ABSORPTION, ManaConstants.DUST_UNIT, true, true, true), true); new OpPotionEffect(MobEffects.ABSORPTION, ManaConstants.DUST_UNIT, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaawawaeqqqdd", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qaawawaeqqqdd", HexDir.SOUTH_EAST),
modLoc("potion/haste"), modLoc("potion/haste"),
new OpPotionEffect(MobEffects.DIG_SPEED, ManaConstants.DUST_UNIT / 3, true, true, true), true); new OpPotionEffect(MobEffects.DIG_SPEED, ManaConstants.DUST_UNIT / 3, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawawaeqqqqdd", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("aawawaeqqqqdd", HexDir.EAST),
modLoc("potion/strength"), modLoc("potion/strength"),
new OpPotionEffect(MobEffects.DAMAGE_BOOST, ManaConstants.DUST_UNIT / 3, true, true, true), true); new OpPotionEffect(MobEffects.DAMAGE_BOOST, ManaConstants.DUST_UNIT / 3, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawae", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("waeawae", HexDir.EAST),
modLoc("sentinel/create"), modLoc("sentinel/create"),
new OpCreateSentinel(false)); new OpCreateSentinel(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdwdqdw", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qdwdqdw", HexDir.NORTH_EAST),
modLoc("sentinel/destroy"), modLoc("sentinel/destroy"),
OpDestroySentinel.INSTANCE); OpDestroySentinel.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaede", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("waeawaede", HexDir.EAST),
modLoc("sentinel/get_pos"), modLoc("sentinel/get_pos"),
OpGetSentinelPos.INSTANCE); OpGetSentinelPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaedwa", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("waeawaedwa", HexDir.EAST),
modLoc("sentinel/wayfind"), modLoc("sentinel/wayfind"),
OpGetSentinelWayfind.INSTANCE); OpGetSentinelWayfind.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waadwawdaaweewq", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("waadwawdaaweewq", HexDir.EAST),
modLoc("lightning"), OpLightning.INSTANCE, true); modLoc("lightning"), OpLightning.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eawwaeawawaa", HexDir.NORTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("eawwaeawawaa", HexDir.NORTH_WEST),
modLoc("flight"), OpFlight.INSTANCE, true); modLoc("flight"), OpFlight.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqawqadaqd", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eaqawqadaqd", HexDir.EAST),
modLoc("create_lava"), OpCreateLava.INSTANCE, true); modLoc("create_lava"), OpCreateLava.INSTANCE, true);
PatternRegistry.mapPattern( PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("wwwqqqwwwqqeqqwwwqqwqqdqqqqqdqq", HexDir.EAST), HexPattern.fromAngles("wwwqqqwwwqqeqqwwwqqwqqdqqqqqdqq", HexDir.EAST),
modLoc("teleport"), OpTeleport.INSTANCE, true); modLoc("teleport"), OpTeleport.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaeqqqwqwqqwq", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("waeawaeqqqwqwqqwq", HexDir.EAST),
modLoc("sentinel/create/great"), modLoc("sentinel/create/great"),
new OpCreateSentinel(true), true); new OpCreateSentinel(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeewwweeewwaqqddqdqd", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeewwweeewwaqqddqdqd", HexDir.EAST),
modLoc("dispel_rain"), modLoc("dispel_rain"),
new OpWeather(false), true); new OpWeather(false), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwweeewwweewdawdwad", HexDir.WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("wwweeewwweewdawdwad", HexDir.WEST),
modLoc("summon_rain"), modLoc("summon_rain"),
new OpWeather(true), true); new OpWeather(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeqwqwqwqwqeqaeqeaqeqaeqaqded", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qeqwqwqwqwqeqaeqeaqeqaeqaqded", HexDir.NORTH_EAST),
modLoc("brainsweep"), modLoc("brainsweep"),
OpBrainsweep.INSTANCE, true); OpBrainsweep.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqwqqqqqaq", HexDir.WEST), modLoc("akashic/read"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqwqqqqqaq", HexDir.WEST), modLoc("akashic/read"),
OpAkashicRead.INSTANCE); OpAkashicRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeweeeeede", HexDir.EAST), modLoc("akashic/write"), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeweeeeede", HexDir.EAST), modLoc("akashic/write"),
OpAkashicWrite.INSTANCE); OpAkashicWrite.INSTANCE);
// == Meta stuff == // == Meta stuff ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqq", HexDir.WEST), modLoc("open_paren"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqq", HexDir.WEST), modLoc("open_paren"),
Widget.OPEN_PAREN); Widget.OPEN_PAREN);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eee", HexDir.EAST), modLoc("close_paren"), PatternRegistry.mapPattern(HexPattern.fromAngles("eee", HexDir.EAST), modLoc("close_paren"),
Widget.CLOSE_PAREN); Widget.CLOSE_PAREN);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaw", HexDir.WEST), modLoc("escape"), Widget.ESCAPE); PatternRegistry.mapPattern(HexPattern.fromAngles("qqqaw", HexDir.WEST), modLoc("escape"), Widget.ESCAPE);
// http://www.toroidalsnark.net/mkss3-pix/CalderheadJMM2014.pdf // http://www.toroidalsnark.net/mkss3-pix/CalderheadJMM2014.pdf
// eval being a space filling curve feels apt doesn't it // eval being a space filling curve feels apt doesn't it
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deaqq", HexDir.SOUTH_EAST), modLoc("eval"), PatternRegistry.mapPattern(HexPattern.fromAngles("deaqq", HexDir.SOUTH_EAST), modLoc("eval"),
OpEval.INSTANCE); OpEval.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqdee", HexDir.SOUTH_WEST), modLoc("halt"), PatternRegistry.mapPattern(HexPattern.fromAngles("aqdee", HexDir.SOUTH_WEST), modLoc("halt"),
OpHalt.INSTANCE); OpHalt.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqqqqq", HexDir.EAST), modLoc("read"), PatternRegistry.mapPattern(HexPattern.fromAngles("aqqqqq", HexDir.EAST), modLoc("read"),
OpRead.INSTANCE); OpRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeeee", HexDir.EAST), modLoc("write"), PatternRegistry.mapPattern(HexPattern.fromAngles("deeeee", HexDir.EAST), modLoc("write"),
OpWrite.INSTANCE); OpWrite.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqqqqqe", HexDir.EAST), modLoc("readable"), PatternRegistry.mapPattern(HexPattern.fromAngles("aqqqqqe", HexDir.EAST), modLoc("readable"),
OpReadable.INSTANCE); OpReadable.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeeeeq", HexDir.EAST), modLoc("writable"), PatternRegistry.mapPattern(HexPattern.fromAngles("deeeeeq", HexDir.EAST), modLoc("writable"),
OpWritable.INSTANCE); OpWritable.INSTANCE);
// lorge boyes // lorge boyes
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wawqwqwqwqwqw", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("wawqwqwqwqwqw", HexDir.EAST),
modLoc("read/entity"), OpTheCoolerRead.INSTANCE); modLoc("read/entity"), OpTheCoolerRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wawqwqwqwqwqwew", HexDir.EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("wawqwqwqwqwqwew", HexDir.EAST),
modLoc("readable/entity"), OpTheCoolerReadable.INSTANCE); modLoc("readable/entity"), OpTheCoolerReadable.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeewdweddw", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qeewdweddw", HexDir.NORTH_EAST),
modLoc("read/local"), OpPeekLocal.INSTANCE); modLoc("read/local"), OpPeekLocal.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqwawqaaw", HexDir.NORTH_WEST), PatternRegistry.mapPattern(HexPattern.fromAngles("eqqwawqaaw", HexDir.NORTH_WEST),
modLoc("write/local"), OpPushLocal.INSTANCE); modLoc("write/local"), OpPushLocal.INSTANCE);
// == Consts == // == Consts ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("d", HexDir.EAST), modLoc("const/null"), Widget.NULL); PatternRegistry.mapPattern(HexPattern.fromAngles("d", HexDir.EAST), modLoc("const/null"), Widget.NULL);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(new Vec3(1.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(new Vec3(0.0, 1.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(new Vec3(0.0, 0.0, 1.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(new Vec3(-1.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(new Vec3(0.0, -1.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.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.FromAnglesSig("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(SpellDatum.make(new Vec3(0.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(Math.PI)));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(HexUtils.TAU)));
// e // e
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("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(SpellDatum.make(Math.E)));
// == Entities == // == Entities ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqa", HexDir.SOUTH_EAST), modLoc("get_entity"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqa", HexDir.SOUTH_EAST), modLoc("get_entity"),
new OpGetEntityAt(e -> true)); new OpGetEntityAt(e -> true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawa", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqaawa", HexDir.SOUTH_EAST),
modLoc("get_entity/animal"), modLoc("get_entity/animal"),
new OpGetEntityAt(OpGetEntitiesBy::isAnimal)); new OpGetEntityAt(OpGetEntitiesBy::isAnimal));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawq", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqaawq", HexDir.SOUTH_EAST),
modLoc("get_entity/monster"), modLoc("get_entity/monster"),
new OpGetEntityAt(OpGetEntitiesBy::isMonster)); new OpGetEntityAt(OpGetEntitiesBy::isMonster));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaaww", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqaaww", HexDir.SOUTH_EAST),
modLoc("get_entity/item"), modLoc("get_entity/item"),
new OpGetEntityAt(OpGetEntitiesBy::isItem)); new OpGetEntityAt(OpGetEntitiesBy::isItem));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawe", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqaawe", HexDir.SOUTH_EAST),
modLoc("get_entity/player"), modLoc("get_entity/player"),
new OpGetEntityAt(OpGetEntitiesBy::isPlayer)); new OpGetEntityAt(OpGetEntitiesBy::isPlayer));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawd", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqdaqaawd", HexDir.SOUTH_EAST),
modLoc("get_entity/living"), modLoc("get_entity/living"),
new OpGetEntityAt(OpGetEntitiesBy::isLiving)); new OpGetEntityAt(OpGetEntitiesBy::isLiving));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwded", HexDir.SOUTH_EAST), modLoc("zone_entity"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwded", HexDir.SOUTH_EAST), modLoc("zone_entity"),
new OpGetEntitiesBy(e -> true, false)); new OpGetEntitiesBy(e -> true, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwa", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwdeddwa", HexDir.SOUTH_EAST),
modLoc("zone_entity/animal"), modLoc("zone_entity/animal"),
new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, false)); new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawa", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeewaqaawa", HexDir.NORTH_EAST),
modLoc("zone_entity/not_animal"), modLoc("zone_entity/not_animal"),
new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, true)); new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwq", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwdeddwq", HexDir.SOUTH_EAST),
modLoc("zone_entity/monster"), modLoc("zone_entity/monster"),
new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, false)); new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawq", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeewaqaawq", HexDir.NORTH_EAST),
modLoc("zone_entity/not_monster"), modLoc("zone_entity/not_monster"),
new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, true)); new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddww", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwdeddww", HexDir.SOUTH_EAST),
modLoc("zone_entity/item"), modLoc("zone_entity/item"),
new OpGetEntitiesBy(OpGetEntitiesBy::isItem, false)); new OpGetEntitiesBy(OpGetEntitiesBy::isItem, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaaww", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeewaqaaww", HexDir.NORTH_EAST),
modLoc("zone_entity/not_item"), modLoc("zone_entity/not_item"),
new OpGetEntitiesBy(OpGetEntitiesBy::isItem, true)); new OpGetEntitiesBy(OpGetEntitiesBy::isItem, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwe", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwdeddwe", HexDir.SOUTH_EAST),
modLoc("zone_entity/player"), modLoc("zone_entity/player"),
new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, false)); new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawe", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeewaqaawe", HexDir.NORTH_EAST),
modLoc("zone_entity/not_player"), modLoc("zone_entity/not_player"),
new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, true)); new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwd", HexDir.SOUTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqqqwdeddwd", HexDir.SOUTH_EAST),
modLoc("zone_entity/living"), modLoc("zone_entity/living"),
new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, false)); new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawd", HexDir.NORTH_EAST), PatternRegistry.mapPattern(HexPattern.fromAngles("eeeeewaqaawd", HexDir.NORTH_EAST),
modLoc("zone_entity/not_living"), modLoc("zone_entity/not_living"),
new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, true)); new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, true));
// == Lists == // == Lists ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqde", HexDir.SOUTH_WEST), modLoc("append"), PatternRegistry.mapPattern(HexPattern.fromAngles("edqde", HexDir.SOUTH_WEST), modLoc("append"),
OpAppend.INSTANCE); OpAppend.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaeaq", HexDir.NORTH_WEST), modLoc("concat"), PatternRegistry.mapPattern(HexPattern.fromAngles("qaeaq", HexDir.NORTH_WEST), modLoc("concat"),
OpConcat.INSTANCE); OpConcat.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeed", HexDir.NORTH_WEST), modLoc("index"), PatternRegistry.mapPattern(HexPattern.fromAngles("deeed", HexDir.NORTH_WEST), modLoc("index"),
OpIndex.INSTANCE); OpIndex.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dadad", HexDir.NORTH_EAST), modLoc("for_each"), PatternRegistry.mapPattern(HexPattern.fromAngles("dadad", HexDir.NORTH_EAST), modLoc("for_each"),
OpForEach.INSTANCE); OpForEach.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqaeaq", HexDir.EAST), modLoc("list_size"), PatternRegistry.mapPattern(HexPattern.fromAngles("aqaeaq", HexDir.EAST), modLoc("list_size"),
OpListSize.INSTANCE); OpListSize.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeed", HexDir.EAST), modLoc("singleton"), PatternRegistry.mapPattern(HexPattern.fromAngles("adeeed", HexDir.EAST), modLoc("singleton"),
OpSingleton.INSTANCE); OpSingleton.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaeaae", HexDir.NORTH_EAST), modLoc("empty_list"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqaeaae", HexDir.NORTH_EAST), modLoc("empty_list"),
OpEmptyList.INSTANCE); OpEmptyList.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaede", HexDir.EAST), modLoc("reverse_list"), PatternRegistry.mapPattern(HexPattern.fromAngles("qqqaede", HexDir.EAST), modLoc("reverse_list"),
OpReverski.INSTANCE); OpReverski.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewdqdwe", HexDir.SOUTH_WEST), modLoc("last_n_list"), PatternRegistry.mapPattern(HexPattern.fromAngles("ewdqdwe", HexDir.SOUTH_WEST), modLoc("last_n_list"),
OpLastNToList.INSTANCE); OpLastNToList.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwaeawq", HexDir.NORTH_WEST), modLoc("splat"), PatternRegistry.mapPattern(HexPattern.fromAngles("qwaeawq", HexDir.NORTH_WEST), modLoc("splat"),
OpSplat.INSTANCE); OpSplat.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedqde", HexDir.EAST), modLoc("index_of"), PatternRegistry.mapPattern(HexPattern.fromAngles("dedqde", HexDir.EAST), modLoc("index_of"),
OpIndexOf.INSTANCE); OpIndexOf.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqdewaqa", HexDir.SOUTH_WEST), modLoc("list_remove"), PatternRegistry.mapPattern(HexPattern.fromAngles("edqdewaqa", HexDir.SOUTH_WEST), modLoc("list_remove"),
OpRemove.INSTANCE); OpRemove.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaeaqwded", HexDir.NORTH_WEST), modLoc("slice"), PatternRegistry.mapPattern(HexPattern.fromAngles("qaeaqwded", HexDir.NORTH_WEST), modLoc("slice"),
OpSlice.INSTANCE); OpSlice.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaeaqw", HexDir.NORTH_WEST), modLoc("modify_in_place"), PatternRegistry.mapPattern(HexPattern.fromAngles("wqaeaqw", HexDir.NORTH_WEST), modLoc("modify_in_place"),
OpModifyInPlace.INSTANCE); OpModifyInPlace.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddewedd", HexDir.SOUTH_EAST), modLoc("construct"), PatternRegistry.mapPattern(HexPattern.fromAngles("ddewedd", HexDir.SOUTH_EAST), modLoc("construct"),
OpCons.INSTANCE); OpCons.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaqwqaa", HexDir.SOUTH_WEST), modLoc("deconstruct"), PatternRegistry.mapPattern(HexPattern.fromAngles("aaqwqaa", HexDir.SOUTH_WEST), modLoc("deconstruct"),
OpUnCons.INSTANCE); OpUnCons.INSTANCE);
} catch (PatternRegistry.RegisterPatternException exn) { } catch (PatternRegistry.RegisterPatternException exn) {

View file

@ -1,14 +1,8 @@
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.casting.SpellContinuation import at.petrak.hexcasting.api.spell.casting.SpellContinuation
object OpEval : Operator { object OpEval : Operator {
@ -22,7 +16,7 @@ object OpEval : Operator {
val newCont = if (continuation is SpellContinuation.NotDone && continuation.frame is ContinuationFrame.FinishEval) { val newCont = if (continuation is SpellContinuation.NotDone && continuation.frame is ContinuationFrame.FinishEval) {
continuation continuation
} else { } else {
continuation.pushFrame(ContinuationFrame.FinishEval()) // install a break-boundary after eval continuation.pushFrame(ContinuationFrame.FinishEval) // install a break-boundary after eval
} }
val frame = ContinuationFrame.Evaluate(instrs) val frame = ContinuationFrame.Evaluate(instrs)

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.SpellDatum
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
@ -12,7 +12,7 @@ object OpAbsLen : ConstManaOperator {
get() = 1 get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val x = GetNumOrVec(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
} }

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.SpellDatum 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.spellListOf import at.petrak.hexcasting.api.spell.spellListOf
@ -11,8 +11,8 @@ object OpAdd : ConstManaOperator {
get() = 2 get() = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val lhs = GetNumOrVec(args[0], 1) val lhs = numOrVec(args[0], 1)
val rhs = GetNumOrVec(args[1], 0) val rhs = numOrVec(args[1], 0)
return spellListOf( return spellListOf(
lhs.map({ lnum -> lhs.map({ lnum ->

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.SpellDatum 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.mishaps.MishapDivideByZero import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
@ -13,8 +13,8 @@ object OpDivCross : ConstManaOperator {
get() = 2 get() = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val lhs = GetNumOrVec(args[0], 1) val lhs = numOrVec(args[0], 1)
val rhs = GetNumOrVec(args[1], 0) val rhs = numOrVec(args[1], 0)
return spellListOf( return spellListOf(
lhs.map({ lnum -> lhs.map({ lnum ->

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.spellListOf import at.petrak.hexcasting.api.spell.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
@ -11,8 +11,8 @@ object OpMulDot : ConstManaOperator {
get() = 2 get() = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val lhs = GetNumOrVec(args[0], 1) val lhs = numOrVec(args[0], 1)
val rhs = GetNumOrVec(args[1], 0) val rhs = numOrVec(args[1], 0)
return spellListOf( return spellListOf(
lhs.map({ lnum -> lhs.map({ lnum ->

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.SpellDatum 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.mishaps.MishapDivideByZero import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
@ -14,8 +14,8 @@ object OpPowProj : ConstManaOperator {
get() = 2 get() = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val lhs = GetNumOrVec(args[0], 1) val lhs = numOrVec(args[0], 1)
val rhs = GetNumOrVec(args[1], 0) val rhs = numOrVec(args[1], 0)
return spellListOf( return spellListOf(
lhs.map({ lnum -> lhs.map({ lnum ->

View file

@ -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.GetNumOrVec import at.petrak.hexcasting.api.spell.numOrVec
import at.petrak.hexcasting.api.spell.SpellDatum 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.spellListOf import at.petrak.hexcasting.api.spell.spellListOf
@ -12,8 +12,8 @@ object OpSub : ConstManaOperator {
get() = 2 get() = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val lhs = GetNumOrVec(args[0], 1) val lhs = numOrVec(args[0], 1)
val rhs = GetNumOrVec(args[1], 0) val rhs = numOrVec(args[1], 0)
return spellListOf( return spellListOf(
lhs.map({ lnum -> lhs.map({ lnum ->

View file

@ -8,7 +8,7 @@ object OpAnd : ConstManaOperator {
override val argc = 2 override val argc = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val firstParam = GetNumOrList(args[0], 0) val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) { if (firstParam.right().isPresent) {
val list1 = firstParam.right().get() val list1 = firstParam.right().get()

View file

@ -8,7 +8,7 @@ object OpOr : ConstManaOperator {
override val argc = 2 override val argc = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val firstParam = GetNumOrList(args[0], 0) val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) { if (firstParam.right().isPresent) {
val list1 = firstParam.right().get() val list1 = firstParam.right().get()

View file

@ -8,7 +8,7 @@ object OpXor : ConstManaOperator {
override val argc = 2 override val argc = 2
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> { override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val firstParam = GetNumOrList(args[0], 0) val firstParam = numOrList(args[0], 0)
if (firstParam.right().isPresent) { if (firstParam.right().isPresent) {
val list1 = firstParam.right().get() val list1 = firstParam.right().get()

View file

@ -27,7 +27,7 @@ object OpBeep : SpellOperator {
return Triple( return Triple(
Spell(target, note, NoteBlockInstrument.values()[instrument]), Spell(target, note, NoteBlockInstrument.values()[instrument]),
ManaConstants.DUST_UNIT / 10, ManaConstants.DUST_UNIT / 10,
listOf(ParticleSpray.Cloud(target, 1.0)) listOf(ParticleSpray.cloud(target, 1.0))
) )
} }

View file

@ -39,8 +39,8 @@ object OpBlink : SpellOperator {
Spell(target, delta), Spell(target, delta),
ManaConstants.SHARD_UNIT * delta.roundToInt(), ManaConstants.SHARD_UNIT * delta.roundToInt(),
listOf( listOf(
ParticleSpray.Cloud(targetMiddlePos, 2.0, 50), ParticleSpray.cloud(targetMiddlePos, 2.0, 50),
ParticleSpray.Burst(targetMiddlePos.add(dvec), 2.0, 100) ParticleSpray.burst(targetMiddlePos.add(dvec), 2.0, 100)
) )
) )
} }

View file

@ -27,7 +27,7 @@ object OpBreakBlock : SpellOperator {
return Triple( return Triple(
Spell(pos), Spell(pos),
ManaConstants.DUST_UNIT * 2, ManaConstants.DUST_UNIT * 2,
listOf(ParticleSpray.Burst(centered, 1.0)) listOf(ParticleSpray.burst(centered, 1.0))
) )
} }

View file

@ -36,7 +36,7 @@ class OpConjure(val light: Boolean) : SpellOperator {
return Triple( return Triple(
Spell(target, light), Spell(target, light),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(pos), 1.0)) listOf(ParticleSpray.cloud(Vec3.atCenterOf(pos), 1.0))
) )
} }

View file

@ -31,7 +31,7 @@ object OpCreateWater : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Burst(Vec3.atCenterOf(BlockPos(target)), 1.0)) listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(target)), 1.0))
) )
} }

View file

@ -29,7 +29,7 @@ object OpDestroyWater : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
2 * ManaConstants.CRYSTAL_UNIT, 2 * ManaConstants.CRYSTAL_UNIT,
listOf(ParticleSpray.Burst(target, 3.0)) listOf(ParticleSpray.burst(target, 3.0))
) )
} }

View file

@ -22,7 +22,7 @@ class OpExplode(val fire: Boolean) : SpellOperator {
return Triple( return Triple(
Spell(pos, strength, this.fire), Spell(pos, strength, this.fire),
((1 + Mth.clamp(strength.toFloat(), 0f, 10f) + if (this.fire) 2 else 0) * ManaConstants.SHARD_UNIT).toInt(), ((1 + Mth.clamp(strength.toFloat(), 0f, 10f) + if (this.fire) 2 else 0) * ManaConstants.SHARD_UNIT).toInt(),
listOf(ParticleSpray.Burst(pos, strength, 50)) listOf(ParticleSpray.burst(pos, strength, 50))
) )
} }

View file

@ -28,7 +28,7 @@ object OpExtinguish : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.CRYSTAL_UNIT, ManaConstants.CRYSTAL_UNIT,
listOf(ParticleSpray.Burst(target, 1.0)) listOf(ParticleSpray.burst(target, 1.0))
) )
} }

View file

@ -31,7 +31,7 @@ object OpIgnite : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Burst(Vec3.atCenterOf(BlockPos(target)), 1.0)) listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(target)), 1.0))
) )
} }

View file

@ -59,7 +59,7 @@ object OpMakeBattery : SpellOperator {
} }
return Triple(Spell(entity), return Triple(Spell(entity),
ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.Burst(entity.position(), 0.5))) ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.burst(entity.position(), 0.5)))
} }
private data class Spell(val itemEntity: ItemEntity) : RenderedSpell { private data class Spell(val itemEntity: ItemEntity) : RenderedSpell {

View file

@ -52,7 +52,7 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
if (trueName != null) if (trueName != null)
throw MishapOthersName(trueName) throw MishapOthersName(trueName)
return Triple(Spell(entity, patterns), cost, listOf(ParticleSpray.Burst(entity.position(), 0.5))) return Triple(Spell(entity, patterns), cost, listOf(ParticleSpray.burst(entity.position(), 0.5)))
} }
private inner class Spell(val itemEntity: ItemEntity, val patterns: List<SpellDatum<*>>) : RenderedSpell { private inner class Spell(val itemEntity: ItemEntity, val patterns: List<SpellDatum<*>>) : RenderedSpell {

View file

@ -45,7 +45,7 @@ object OpPlaceBlock : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(pos), 1.0)) listOf(ParticleSpray.cloud(Vec3.atCenterOf(pos), 1.0))
) )
} }

View file

@ -44,7 +44,7 @@ class OpPotionEffect(
return Triple( return Triple(
Spell(effect, target, duration, potency), Spell(effect, target, duration, potency),
cost.toInt(), cost.toInt(),
listOf(ParticleSpray.Cloud(target.position().add(0.0, target.eyeHeight / 2.0, 0.0), 1.0)) listOf(ParticleSpray.cloud(target.position().add(0.0, target.eyeHeight / 2.0, 0.0), 1.0))
) )
} }

View file

@ -48,7 +48,7 @@ object OpRecharge : SpellOperator {
return null return null
return Triple(Spell(entity), return Triple(Spell(entity),
ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.Burst(entity.position(), 0.5))) ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.burst(entity.position(), 0.5)))
} }
private data class Spell(val itemEntity: ItemEntity) : RenderedSpell { private data class Spell(val itemEntity: ItemEntity) : RenderedSpell {

View file

@ -29,7 +29,7 @@ object OpTheOnlyReasonAnyoneDownloadedPsi : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Burst(Vec3.atCenterOf(BlockPos(target)), 1.0)) listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(target)), 1.0))
) )
} }

View file

@ -47,7 +47,7 @@ object OpBrainsweep : SpellOperator {
return Triple( return Triple(
Spell(bpos, state, sacrifice, recipe), Spell(bpos, state, sacrifice, recipe),
10 * ManaConstants.CRYSTAL_UNIT, 10 * ManaConstants.CRYSTAL_UNIT,
listOf(ParticleSpray.Cloud(sacrifice.position(), 1.0), ParticleSpray.Burst(Vec3.atCenterOf(bpos), 0.3, 100)) listOf(ParticleSpray.cloud(sacrifice.position(), 1.0), ParticleSpray.burst(Vec3.atCenterOf(bpos), 0.3, 100))
) )
} }

View file

@ -31,7 +31,7 @@ object OpCreateLava : SpellOperator {
return Triple( return Triple(
Spell(target), Spell(target),
ManaConstants.CRYSTAL_UNIT, ManaConstants.CRYSTAL_UNIT,
listOf(ParticleSpray.Burst(Vec3.atCenterOf(BlockPos(target)), 1.0)), listOf(ParticleSpray.burst(Vec3.atCenterOf(BlockPos(target)), 1.0)),
) )
} }

View file

@ -36,7 +36,7 @@ object OpTeleport : SpellOperator {
return Triple( return Triple(
Spell(teleportee, delta), Spell(teleportee, delta),
10 * ManaConstants.CRYSTAL_UNIT, 10 * ManaConstants.CRYSTAL_UNIT,
listOf(ParticleSpray.Cloud(targetMiddlePos, 2.0), ParticleSpray.Burst(targetMiddlePos.add(delta), 2.0)) listOf(ParticleSpray.cloud(targetMiddlePos, 2.0), ParticleSpray.burst(targetMiddlePos.add(delta), 2.0))
) )
} }

View file

@ -26,7 +26,7 @@ class OpCreateSentinel(val extendsRange: Boolean) : SpellOperator {
return Triple( return Triple(
Spell(target, this.extendsRange), Spell(target, this.extendsRange),
ManaConstants.DUST_UNIT, ManaConstants.DUST_UNIT,
listOf(ParticleSpray.Burst(target, 2.0)) listOf(ParticleSpray.burst(target, 2.0))
) )
} }

View file

@ -22,7 +22,7 @@ object OpDestroySentinel : SpellOperator {
// TODO why can't you remove things from other dimensions? // TODO why can't you remove things from other dimensions?
if (sentinel.dimension != ctx.world.dimension()) if (sentinel.dimension != ctx.world.dimension())
throw MishapLocationInWrongDimension(sentinel.dimension.location()) throw MishapLocationInWrongDimension(sentinel.dimension.location())
particles.add(ParticleSpray.Cloud(sentinel.position, 2.0)) particles.add(ParticleSpray.cloud(sentinel.position, 2.0))
return Triple( return Triple(
Spell, Spell,

View file

@ -32,7 +32,7 @@ public class ListPatternsCommand {
for (var pair : listing) { for (var pair : listing) {
ctx.getSource().sendSuccess(new TextComponent(pair.getValue().getFirst().toString()) ctx.getSource().sendSuccess(new TextComponent(pair.getValue().getFirst().toString())
.append(": ") .append(": ")
.append(SpellDatum.make(HexPattern.FromAnglesSig(pair.getKey(), pair.getValue().getSecond())) .append(SpellDatum.make(HexPattern.fromAngles(pair.getKey(), pair.getValue().getSecond()))
.display()), false); .display()), false);
} }
@ -86,7 +86,7 @@ public class ListPatternsCommand {
var tag = new CompoundTag(); var tag = new CompoundTag();
tag.putString(ItemScroll.TAG_OP_ID, opId.toString()); tag.putString(ItemScroll.TAG_OP_ID, opId.toString());
tag.put(ItemScroll.TAG_PATTERN, tag.put(ItemScroll.TAG_PATTERN,
HexPattern.FromAnglesSig(pattern, startDir).serializeToNBT()); HexPattern.fromAngles(pattern, startDir).serializeToNBT());
var stack = new ItemStack(HexItems.SCROLL); var stack = new ItemStack(HexItems.SCROLL);
stack.setTag(tag); stack.setTag(tag);

View file

@ -38,7 +38,7 @@ public class PatternResLocArgument extends ResourceLocationArgument {
for (var key : lookup.keySet()) { for (var key : lookup.keySet()) {
var rhs = lookup.get(key); var rhs = lookup.get(key);
if (rhs.getFirst().equals(targetId)) { if (rhs.getFirst().equals(targetId)) {
foundPat = HexPattern.FromAnglesSig(key, rhs.getSecond()); foundPat = HexPattern.fromAngles(key, rhs.getSecond());
break; break;
} }
} }

View file

@ -1,6 +1,5 @@
package at.petrak.hexcasting.common.entities; package at.petrak.hexcasting.common.entities;
import at.petrak.hexcasting.annotations.SoftImplement;
import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
@ -27,7 +26,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -60,7 +58,7 @@ public class EntityWallScroll extends HangingEntity {
CompoundTag patternTag = NBTHelper.getCompound(scroll, ItemScroll.TAG_PATTERN); CompoundTag patternTag = NBTHelper.getCompound(scroll, ItemScroll.TAG_PATTERN);
if (patternTag != null) { if (patternTag != null) {
this.pattern = HexPattern.DeserializeFromNBT(patternTag); this.pattern = HexPattern.fromNBT(patternTag);
if (this.level.isClientSide) { if (this.level.isClientSide) {
var pair = RenderLib.getCenteredPattern(pattern, 128, 128, 16f); var pair = RenderLib.getCenteredPattern(pattern, 128, 128, 16f);
var dots = pair.getSecond(); var dots = pair.getSecond();
@ -160,7 +158,7 @@ public class EntityWallScroll extends HangingEntity {
@Override @Override
public void addAdditionalSaveData(CompoundTag tag) { public void addAdditionalSaveData(CompoundTag tag) {
tag.putByte("direction", (byte) this.direction.ordinal()); tag.putByte("direction", (byte) this.direction.ordinal());
tag.put("scroll", HexUtils.serialize(this.scroll)); tag.put("scroll", HexUtils.serializeToNBT(this.scroll));
tag.putBoolean("showsStrokeOrder", this.getShowsStrokeOrder()); tag.putBoolean("showsStrokeOrder", this.getShowsStrokeOrder());
super.addAdditionalSaveData(tag); super.addAdditionalSaveData(tag);
} }

View file

@ -125,7 +125,7 @@ public class ItemScroll extends Item implements DataHolderItem {
public Optional<TooltipComponent> getTooltipImage(ItemStack stack) { public Optional<TooltipComponent> getTooltipImage(ItemStack stack) {
var compound = NBTHelper.getCompound(stack, ItemScroll.TAG_PATTERN); var compound = NBTHelper.getCompound(stack, ItemScroll.TAG_PATTERN);
if (compound != null) { if (compound != null) {
var pattern = HexPattern.DeserializeFromNBT(compound); var pattern = HexPattern.fromNBT(compound);
return Optional.of(new PatternTooltipGreeble( return Optional.of(new PatternTooltipGreeble(
pattern, pattern,
NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? PatternTooltipGreeble.ANCIENT_BG : PatternTooltipGreeble.PRISTINE_BG)); NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? PatternTooltipGreeble.ANCIENT_BG : PatternTooltipGreeble.PRISTINE_BG));

View file

@ -106,7 +106,7 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
if (bet != null && bet.contains(BlockEntitySlate.TAG_PATTERN, Tag.TAG_COMPOUND)) { if (bet != null && bet.contains(BlockEntitySlate.TAG_PATTERN, Tag.TAG_COMPOUND)) {
var patTag = bet.getCompound(BlockEntitySlate.TAG_PATTERN); var patTag = bet.getCompound(BlockEntitySlate.TAG_PATTERN);
if (!patTag.isEmpty()) { if (!patTag.isEmpty()) {
var pattern = HexPattern.DeserializeFromNBT(patTag); var pattern = HexPattern.fromNBT(patTag);
return Optional.of(new PatternTooltipGreeble( return Optional.of(new PatternTooltipGreeble(
pattern, pattern,
PatternTooltipGreeble.SLATE_BG)); PatternTooltipGreeble.SLATE_BG));

View file

@ -68,9 +68,9 @@ public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolde
for (var patTag : patsTag) { for (var patTag : patsTag) {
CompoundTag tag = NBTHelper.getAsCompound(patTag); CompoundTag tag = NBTHelper.getAsCompound(patTag);
if (tag.size() != 1) if (tag.size() != 1)
out.add(SpellDatum.make(HexPattern.DeserializeFromNBT(tag))); out.add(SpellDatum.make(HexPattern.fromNBT(tag)));
else else
out.add(SpellDatum.DeserializeFromNBT(tag, level)); out.add(SpellDatum.fromNBT(tag, level));
} }
return out; return out;
} }

View file

@ -32,7 +32,7 @@ public class PatternScrollFunc extends LootItemConditionalFunction {
var startDir = entry.component2(); var startDir = entry.component2();
var tag = new CompoundTag(); var tag = new CompoundTag();
tag.putString(ItemScroll.TAG_OP_ID, opId.toString()); tag.putString(ItemScroll.TAG_OP_ID, opId.toString());
tag.put(ItemScroll.TAG_PATTERN, HexPattern.FromAnglesSig(sig, startDir).serializeToNBT()); tag.put(ItemScroll.TAG_PATTERN, HexPattern.fromAngles(sig, startDir).serializeToNBT());
stack.getOrCreateTag().merge(tag); stack.getOrCreateTag().merge(tag);

View file

@ -37,7 +37,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer)
var spread = buf.readDouble(); var spread = buf.readDouble();
var count = buf.readInt(); var count = buf.readInt();
var tag = buf.readAnySizeNbt(); var tag = buf.readAnySizeNbt();
var colorizer = FrozenColorizer.deserialize(tag); var colorizer = FrozenColorizer.fromNBT(tag);
return new MsgCastParticleAck( return new MsgCastParticleAck(
new ParticleSpray(new Vec3(posX, posY, posZ), new Vec3(velX, velY, velZ), fuzziness, spread, count), new ParticleSpray(new Vec3(posX, posY, posZ), new Vec3(velX, velY, velZ), fuzziness, spread, count),
colorizer); colorizer);
@ -54,7 +54,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer)
buf.writeDouble(this.spray.getFuzziness()); buf.writeDouble(this.spray.getFuzziness());
buf.writeDouble(this.spray.getSpread()); buf.writeDouble(this.spray.getSpread());
buf.writeInt(this.spray.getCount()); buf.writeInt(this.spray.getCount());
buf.writeNbt(this.colorizer.serialize()); buf.writeNbt(this.colorizer.serializeToNBT());
} }

View file

@ -39,12 +39,12 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
public static MsgNewSpellPatternSyn deserialize(ByteBuf buffer) { public static MsgNewSpellPatternSyn deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer); var buf = new FriendlyByteBuf(buffer);
var hand = buf.readEnum(InteractionHand.class); var hand = buf.readEnum(InteractionHand.class);
var pattern = HexPattern.DeserializeFromNBT(buf.readAnySizeNbt()); var pattern = HexPattern.fromNBT(buf.readAnySizeNbt());
var resolvedPatternsLen = buf.readInt(); var resolvedPatternsLen = buf.readInt();
var resolvedPatterns = new ArrayList<ResolvedPattern>(resolvedPatternsLen); var resolvedPatterns = new ArrayList<ResolvedPattern>(resolvedPatternsLen);
for (int i = 0; i < resolvedPatternsLen; i++) { for (int i = 0; i < resolvedPatternsLen; i++) {
resolvedPatterns.add(ResolvedPattern.DeserializeFromNBT(buf.readAnySizeNbt())); resolvedPatterns.add(ResolvedPattern.fromNBT(buf.readAnySizeNbt()));
} }
return new MsgNewSpellPatternSyn(hand, pattern, resolvedPatterns); return new MsgNewSpellPatternSyn(hand, pattern, resolvedPatterns);
} }

View file

@ -34,7 +34,7 @@ public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> pat
var patternsLen = buf.readInt(); var patternsLen = buf.readInt();
var patterns = new ArrayList<ResolvedPattern>(patternsLen); var patterns = new ArrayList<ResolvedPattern>(patternsLen);
for (int i = 0; i < patternsLen; i++) { for (int i = 0; i < patternsLen; i++) {
patterns.add(ResolvedPattern.DeserializeFromNBT(buf.readAnySizeNbt())); patterns.add(ResolvedPattern.fromNBT(buf.readAnySizeNbt()));
} }
var descsLen = buf.readInt(); var descsLen = buf.readInt();

View file

@ -121,7 +121,7 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea
var datumTag = HexItems.ABACUS.readDatumTag(stack); var datumTag = HexItems.ABACUS.readDatumTag(stack);
if (datumTag != null) { if (datumTag != null) {
var popup = SpellDatum.DisplayFromTag(datumTag); var popup = SpellDatum.displayFromNBT(datumTag);
sender.displayClientMessage( sender.displayClientMessage(
new TranslatableComponent("hexcasting.tooltip.abacus", popup).withStyle(ChatFormatting.GREEN), true); new TranslatableComponent("hexcasting.tooltip.abacus", popup).withStyle(ChatFormatting.GREEN), true);
} }

View file

@ -35,7 +35,7 @@ public class ManualPatternComponent extends AbstractPatternComponent {
RawPattern raw = new Gson().fromJson(json, RawPattern.class); RawPattern raw = new Gson().fromJson(json, RawPattern.class);
var dir = HexDir.valueOf(raw.startdir); var dir = HexDir.valueOf(raw.startdir);
var pat = HexPattern.FromAnglesSig(raw.signature, dir); var pat = HexPattern.fromAngles(raw.signature, dir);
var origin = new HexCoord(raw.q, raw.r); var origin = new HexCoord(raw.q, raw.r);
out.add(new Pair<>(pat, origin)); out.add(new Pair<>(pat, origin));
} }

View file

@ -77,7 +77,7 @@ public final class PatternDrawingUtil {
patternEntries.add(new PatternEntry(pattern, origin, new ArrayList<>())); patternEntries.add(new PatternEntry(pattern, origin, new ArrayList<>()));
seenCoords.addAll(pattern.positions(origin)); seenCoords.addAll(pattern.positions(origin));
} }
var fakeCom = HexUtils.FindCenter(seenFakePoints); var fakeCom = HexUtils.findCenter(seenFakePoints);
var maxDx = -1f; var maxDx = -1f;
var maxDy = -1f; var maxDy = -1f;
@ -100,7 +100,7 @@ public final class PatternDrawingUtil {
seenRealPoints.add(px); seenRealPoints.add(px);
} }
} }
var realCom = HexUtils.FindCenter(seenRealPoints); var realCom = HexUtils.findCenter(seenRealPoints);
// and NOW for real! // and NOW for real!
for (var pat : patternEntries) { for (var pat : patternEntries) {

View file

@ -1,13 +1,13 @@
import at.petrak.hexcasting.api.spell.math.EulerPathFinder.findAltDrawing import at.petrak.hexcasting.api.spell.math.EulerPathFinder.findAltDrawing
import at.petrak.hexcasting.api.spell.math.HexDir import at.petrak.hexcasting.api.spell.math.HexDir
import at.petrak.hexcasting.api.spell.math.HexPattern.Companion.FromAnglesSig import at.petrak.hexcasting.api.spell.math.HexPattern.Companion.fromAngles
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
internal class EulerPathFinderTest { internal class EulerPathFinderTest {
@Test @Test
fun findAltDrawing() { fun findAltDrawing() {
val sig = "dadaddwwaadada" val sig = "dadaddwwaadada"
val pat = FromAnglesSig(sig, HexDir.NORTH_EAST) val pat = fromAngles(sig, HexDir.NORTH_EAST)
for (i in 0 until 8) { for (i in 0 until 8) {
val scrungled = findAltDrawing(pat, i.toLong()) val scrungled = findAltDrawing(pat, i.toLong())
println(scrungled) println(scrungled)

View file

@ -31,11 +31,11 @@ public class CCFavoredColorizer implements Component, AutoSyncedComponent {
@Override @Override
public void readFromNbt(CompoundTag tag) { public void readFromNbt(CompoundTag tag) {
this.colorizer = FrozenColorizer.deserialize(tag.getCompound(TAG_COLORIZER)); this.colorizer = FrozenColorizer.fromNBT(tag.getCompound(TAG_COLORIZER));
} }
@Override @Override
public void writeToNbt(CompoundTag tag) { public void writeToNbt(CompoundTag tag) {
tag.put(TAG_COLORIZER, this.colorizer.serialize()); tag.put(TAG_COLORIZER, this.colorizer.serializeToNBT());
} }
} }

View file

@ -42,7 +42,7 @@ public class CCFlight implements Component {
var timeLeft = tag.getInt(TAG_TIME_LEFT); var timeLeft = tag.getInt(TAG_TIME_LEFT);
var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY, var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY,
new ResourceLocation(tag.getString(TAG_DIMENSION))); new ResourceLocation(tag.getString(TAG_DIMENSION)));
var origin = HexUtils.DeserializeVec3FromNBT(tag.getLongArray(TAG_ORIGIN)); var origin = HexUtils.vecFromNBT(tag.getLongArray(TAG_ORIGIN));
var radius = tag.getDouble(TAG_RADIUS); var radius = tag.getDouble(TAG_RADIUS);
this.flight = new FlightAbility(true, timeLeft, dim, origin, radius); this.flight = new FlightAbility(true, timeLeft, dim, origin, radius);
} }

View file

@ -23,7 +23,7 @@ public class CCHarness implements Component {
if (this.lazyLoadedTag.isEmpty()) { if (this.lazyLoadedTag.isEmpty()) {
return new CastingHarness(ctx); return new CastingHarness(ctx);
} else { } else {
return CastingHarness.DeserializeFromNBT(this.lazyLoadedTag, ctx); return CastingHarness.fromNBT(this.lazyLoadedTag, ctx);
} }
} }

View file

@ -39,7 +39,7 @@ public class CCPatterns implements Component {
List<ResolvedPattern> patterns = new ArrayList<>(patternsTag.size()); List<ResolvedPattern> patterns = new ArrayList<>(patternsTag.size());
for (int i = 0; i < patternsTag.size(); i++) { for (int i = 0; i < patternsTag.size(); i++) {
patterns.add(ResolvedPattern.DeserializeFromNBT(patternsTag.getCompound(i))); patterns.add(ResolvedPattern.fromNBT(patternsTag.getCompound(i)));
} }
this.patterns = patterns; this.patterns = patterns;
} }

View file

@ -38,7 +38,7 @@ public class CCSentinel implements Component, AutoSyncedComponent {
var hasSentinel = tag.getBoolean(TAG_HAS_SENTINEL); var hasSentinel = tag.getBoolean(TAG_HAS_SENTINEL);
if (hasSentinel) { if (hasSentinel) {
var extendsRange = tag.getBoolean(TAG_EXTENDS_RANGE); var extendsRange = tag.getBoolean(TAG_EXTENDS_RANGE);
var position = HexUtils.DeserializeVec3FromNBT(tag.getLongArray(TAG_POSITION)); var position = HexUtils.vecFromNBT(tag.getLongArray(TAG_POSITION));
var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY, var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY,
new ResourceLocation(tag.getString(TAG_DIMENSION))); new ResourceLocation(tag.getString(TAG_DIMENSION)));
this.sentinel = new Sentinel(true, extendsRange, position, dim); this.sentinel = new Sentinel(true, extendsRange, position, dim);

View file

@ -33,7 +33,7 @@ public class FabricUnsealedIngredient extends Ingredient {
.filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER)
.map((type) -> { .map((type) -> {
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.GetTagName(type)); NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type));
return new Ingredient.ItemValue(newStack); return new Ingredient.ItemValue(newStack);
})); }));
this.stack = stack; this.stack = stack;

View file

@ -25,13 +25,13 @@ public record MsgColorizerUpdateAck(FrozenColorizer update) implements IMessage
var buf = new FriendlyByteBuf(buffer); var buf = new FriendlyByteBuf(buffer);
var tag = buf.readAnySizeNbt(); var tag = buf.readAnySizeNbt();
var colorizer = FrozenColorizer.deserialize(tag); var colorizer = FrozenColorizer.fromNBT(tag);
return new MsgColorizerUpdateAck(colorizer); return new MsgColorizerUpdateAck(colorizer);
} }
@Override @Override
public void serialize(FriendlyByteBuf buf) { public void serialize(FriendlyByteBuf buf) {
buf.writeNbt(this.update.serialize()); buf.writeNbt(this.update.serializeToNBT());
} }
public static void handle(MsgColorizerUpdateAck self) { public static void handle(MsgColorizerUpdateAck self) {

View file

@ -30,7 +30,7 @@ public class ForgeUnsealedIngredient extends AbstractIngredient {
.filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER)
.map((type) -> { .map((type) -> {
ItemStack newStack = stack.copy(); ItemStack newStack = stack.copy();
NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.GetTagName(type)); NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type));
return new Ingredient.ItemValue(newStack); return new Ingredient.ItemValue(newStack);
})); }));
this.stack = stack; this.stack = stack;

View file

@ -124,7 +124,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
@Override @Override
public void setColorizer(Player player, FrozenColorizer colorizer) { public void setColorizer(Player player, FrozenColorizer colorizer) {
CompoundTag tag = player.getPersistentData(); CompoundTag tag = player.getPersistentData();
tag.put(TAG_COLOR, colorizer.serialize()); tag.put(TAG_COLOR, colorizer.serializeToNBT());
if (player instanceof ServerPlayer serverPlayer) { if (player instanceof ServerPlayer serverPlayer) {
CapSyncers.syncColorizer(serverPlayer); CapSyncers.syncColorizer(serverPlayer);
@ -175,7 +175,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
boolean allowed = tag.getBoolean(TAG_FLIGHT_ALLOWED); boolean allowed = tag.getBoolean(TAG_FLIGHT_ALLOWED);
if (allowed) { if (allowed) {
var timeLeft = tag.getInt(TAG_FLIGHT_TIME); var timeLeft = tag.getInt(TAG_FLIGHT_TIME);
var origin = HexUtils.DeserializeVec3FromNBT(tag.getLongArray(TAG_FLIGHT_ORIGIN)); var origin = HexUtils.vecFromNBT(tag.getLongArray(TAG_FLIGHT_ORIGIN));
var radius = tag.getDouble(TAG_FLIGHT_RADIUS); var radius = tag.getDouble(TAG_FLIGHT_RADIUS);
var dimension = ResourceKey.create(Registry.DIMENSION_REGISTRY, var dimension = ResourceKey.create(Registry.DIMENSION_REGISTRY,
new ResourceLocation(tag.getString(TAG_FLIGHT_DIMENSION))); new ResourceLocation(tag.getString(TAG_FLIGHT_DIMENSION)));
@ -186,7 +186,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
@Override @Override
public FrozenColorizer getColorizer(Player player) { public FrozenColorizer getColorizer(Player player) {
return FrozenColorizer.deserialize(player.getPersistentData().getCompound(TAG_COLOR)); return FrozenColorizer.fromNBT(player.getPersistentData().getCompound(TAG_COLOR));
} }
@Override @Override
@ -197,7 +197,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
return Sentinel.none(); return Sentinel.none();
} }
var extendsRange = tag.getBoolean(TAG_SENTINEL_GREATER); var extendsRange = tag.getBoolean(TAG_SENTINEL_GREATER);
var position = HexUtils.DeserializeVec3FromNBT(tag.getLongArray(TAG_SENTINEL_POSITION)); var position = HexUtils.vecFromNBT(tag.getLongArray(TAG_SENTINEL_POSITION));
var dimension = ResourceKey.create(Registry.DIMENSION_REGISTRY, var dimension = ResourceKey.create(Registry.DIMENSION_REGISTRY,
new ResourceLocation(tag.getString(TAG_SENTINEL_DIMENSION))); new ResourceLocation(tag.getString(TAG_SENTINEL_DIMENSION)));
@ -207,7 +207,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
@Override @Override
public CastingHarness getHarness(ServerPlayer player, InteractionHand hand) { public CastingHarness getHarness(ServerPlayer player, InteractionHand hand) {
var ctx = new CastingContext(player, hand); var ctx = new CastingContext(player, hand);
return CastingHarness.DeserializeFromNBT(player.getPersistentData().getCompound(TAG_HARNESS), ctx); return CastingHarness.fromNBT(player.getPersistentData().getCompound(TAG_HARNESS), ctx);
} }
@Override @Override
@ -217,7 +217,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
List<ResolvedPattern> patterns = new ArrayList<>(patternsTag.size()); List<ResolvedPattern> patterns = new ArrayList<>(patternsTag.size());
for (int i = 0; i < patternsTag.size(); i++) { for (int i = 0; i < patternsTag.size(); i++) {
patterns.add(ResolvedPattern.DeserializeFromNBT(patternsTag.getCompound(i))); patterns.add(ResolvedPattern.fromNBT(patternsTag.getCompound(i)));
} }
return patterns; return patterns;
} }