names and descriptions subject to change
This commit is contained in:
yrsegal@gmail.com 2022-04-10 20:22:32 -04:00
parent 8eaab9a572
commit 2f9a223a66
11 changed files with 245 additions and 6 deletions

View file

@ -15,6 +15,7 @@ import at.petrak.hexcasting.common.casting.operators.eval.OpForEach;
import at.petrak.hexcasting.common.casting.operators.lists.*;
import at.petrak.hexcasting.common.casting.operators.math.*;
import at.petrak.hexcasting.common.casting.operators.math.logic.*;
import at.petrak.hexcasting.common.casting.operators.math.trig.*;
import at.petrak.hexcasting.common.casting.operators.selectors.OpGetCaster;
import at.petrak.hexcasting.common.casting.operators.selectors.OpGetEntitiesBy;
import at.petrak.hexcasting.common.casting.operators.selectors.OpGetEntityAt;
@ -127,10 +128,18 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aw", HexDir.NORTH_EAST), prefix("identity"),
OpIdentityKindOf.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqwqqqqqaq", HexDir.WEST), prefix("akashic/read"),
OpAkashicRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeweeeeede", HexDir.EAST), prefix("akashic/write"),
OpAkashicWrite.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaa", HexDir.SOUTH_EAST), prefix("sin"),
OpSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqad", HexDir.SOUTH_EAST), prefix("cos"),
OpCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqqqqqadq", HexDir.SOUTH_WEST), prefix("tan"),
OpTan.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddeeeee", HexDir.SOUTH_EAST), prefix("arcsin"),
OpArcSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeeee", HexDir.NORTH_EAST), prefix("arccos"),
OpArcCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eadeeeeew", HexDir.NORTH_EAST), prefix("arctan"),
OpArcTan.INSTANCE);
// == Spells ==
@ -257,6 +266,10 @@ public class RegisterPatterns {
prefix("brainsweep"),
OpBrainsweep.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqwqqqqqaq", HexDir.WEST), prefix("akashic/read"),
OpAkashicRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeweeeeede", HexDir.EAST), prefix("akashic/write"),
OpAkashicWrite.INSTANCE);
// == Meta stuff ==
@ -297,6 +310,11 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqq", HexDir.NORTH_WEST), prefix("const/vec/0"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdwdq", HexDir.NORTH_EAST), prefix("const/double/pi"),
Operator.makeConstantOp(SpellDatum.make(Math.PI)));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eawae", HexDir.NORTH_WEST), prefix("const/double/tau"),
Operator.makeConstantOp(SpellDatum.make(Math.PI * 2)));
// == Entities ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqa", HexDir.SOUTH_EAST), prefix("get_entity"),

View file

@ -34,6 +34,12 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s
return MishapDivideByZero(translate(operand1), translate(operand2), suffix)
}
@JvmStatic
fun tan(angle: Double): MishapDivideByZero {
val translatedAngle = translate(angle)
return MishapDivideByZero(TranslatableComponent("$PREFIX.sin", translatedAngle), TranslatableComponent("$PREFIX.cos", translatedAngle))
}
@JvmStatic
val zero get() = TranslatableComponent("$PREFIX.zero")
@JvmStatic

View file

@ -0,0 +1,26 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.casting.mishaps.MishapInvalidIota
import net.minecraft.network.chat.TranslatableComponent
import kotlin.math.acos
object OpArcCos : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val value = args.getChecked<Double>(0)
if (value < -1 || value > 1)
throw MishapInvalidIota(
SpellDatum.make(value),
0,
TranslatableComponent("hexcasting.mishap.invalid_value.double.between", -1, 1)
)
return spellListOf(acos(value))
}
}

View file

@ -0,0 +1,27 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.casting.mishaps.MishapInvalidIota
import net.minecraft.network.chat.TranslatableComponent
import kotlin.math.acos
import kotlin.math.asin
object OpArcSin : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val value = args.getChecked<Double>(0)
if (value < -1 || value > 1)
throw MishapInvalidIota(
SpellDatum.make(value),
0,
TranslatableComponent("hexcasting.mishap.invalid_value.double.between", -1, 1)
)
return spellListOf(asin(value))
}
}

View file

@ -0,0 +1,21 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.casting.mishaps.MishapInvalidIota
import net.minecraft.network.chat.TranslatableComponent
import kotlin.math.acos
import kotlin.math.atan
object OpArcTan : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val value = args.getChecked<Double>(0)
return spellListOf(atan(value))
}
}

View file

@ -0,0 +1,19 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import kotlin.math.cos
import kotlin.math.sin
object OpCos : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val angle = args.getChecked<Double>(0)
return spellListOf(cos(angle))
}
}

View file

@ -0,0 +1,18 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import kotlin.math.sin
object OpSin : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val angle = args.getChecked<Double>(0)
return spellListOf(sin(angle))
}
}

View file

@ -0,0 +1,23 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaOperator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.casting.mishaps.MishapDivideByZero
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.tan
object OpTan : ConstManaOperator {
override val argc: Int
get() = 1
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
val angle = args.getChecked<Double>(0)
if (cos(angle) == 0.0)
throw MishapDivideByZero.tan(angle)
return spellListOf(tan(angle))
}
}

View file

@ -218,6 +218,12 @@
"hexcasting.spell.hexcasting:not_equals": "Inequality Distillation",
"hexcasting.spell.hexcasting:not": "Negation Purification",
"hexcasting.spell.hexcasting:identity": "Identity Purification",
"hexcasting.spell.hexcasting:sin": "Sine Purification",
"hexcasting.spell.hexcasting:cos": "Cosine Purification",
"hexcasting.spell.hexcasting:tan": "Tangent Purification",
"hexcasting.spell.hexcasting:arcsin": "Inverse Sine Prfn.",
"hexcasting.spell.hexcasting:arccos": "Inverse Cosine Prfn.",
"hexcasting.spell.hexcasting:arctan": "Inverse Tangent Prfn.",
"hexcasting.spell.hexcasting:print": "Reveal",
"hexcasting.spell.hexcasting:explode": "Explosion",
"hexcasting.spell.hexcasting:explode/fire": "Fireball",
@ -276,6 +282,8 @@
"hexcasting.spell.hexcasting:const/vec/ny": "Vector Reflection -Y",
"hexcasting.spell.hexcasting:const/vec/nz": "Vector Reflection -Z",
"hexcasting.spell.hexcasting:const/vec/0": "Vector Reflection Zero",
"hexcasting.spell.hexcasting:const/double/pi": "Arc's Reflection",
"hexcasting.spell.hexcasting:const/double/tau": "Circle's Reflection",
"hexcasting.spell.hexcasting:number": "Numerical Reflection",
"hexcasting.spell.hexcasting:mask": "Bookkeeper's Gambit",
"hexcasting.spell.unknown": "Special Handler",
@ -297,6 +305,7 @@
"hexcasting.mishap.invalid_value.numvec": "a number or vector",
"hexcasting.mishap.invalid_value.list.pattern": "a list of patterns",
"hexcasting.mishap.invalid_value.int": "an integer",
"hexcasting.mishap.invalid_value.double.between": "a number between %d and %d",
"hexcasting.mishap.invalid_value.int.between": "an integer between %d and %d",
"hexcasting.mishap.not_enough_args": "%s expected %s or more arguments but the stack was only %s tall",
"hexcasting.mishap.too_many_close_parens": "Used Retrospection without first using Introspection",
@ -330,6 +339,8 @@
"hexcasting.mishap.divide_by_zero.zero.power": "zeroth power",
"hexcasting.mishap.divide_by_zero.zero.vec": "the zero vector",
"hexcasting.mishap.divide_by_zero.power": "power of %s",
"hexcasting.mishap.divide_by_zero.sin": "the sine of %s",
"hexcasting.mishap.divide_by_zero.cos": "the cosine of %s",
"hexcasting.mishap.no_akashic_record": "No akashic record at %s",
"hexcasting.landing": "I seem to have discovered a new method of magical arts, in which one draws patterns strange and wild onto a hexagonal grid. It fascinates me. I've decided to start a journal of my thoughts and findings.$(br2)$(l:https://discord.gg/4xxHGYteWk)Discord Server Link/$",
@ -590,13 +601,21 @@
"hexcasting.page.math.13": "$(li)With two numbers, combines them by raising the first to the power of the second.$(li)With a number and a vector, removes the number and raises each component of the vector to the number's power.$(li)With two vectors, combines them into the $(l:https://en.wikipedia.org/wiki/Vector_projection)vector projection/$ of the top of the stack onto the second-from-the-top.$(br2)In the first and second cases, the first argument or its components are the base, and the second argument or its components are the exponent.",
"hexcasting.page.math.14": "Combine three numbers at the top of the stack into a vector's X, Y, and Z components (top to bottom).",
"hexcasting.page.math.15": "Split a vector into its X, Y, and Z components (top to bottom).",
"hexcasting.page.math.16": "Take the sine of an angle in radians, the vertical component of that angle drawn on a circle of radius 1.",
"hexcasting.page.math.17": "Take the cosine of an angle in radians, the horizontal component of that angle drawn on a circle of radius 1.",
"hexcasting.page.math.18": "Take the tangent of an angle in radians, the slope of that angle drawn on a circle.",
"hexcasting.page.math.19": "Take the inverse sine of a value with absolute value 1 or less, the angle whose sine is that value.",
"hexcasting.page.math.20": "Take the inverse cosine of a value with absolute value 1 or less, the angle whose sine is that value.",
"hexcasting.page.math.21": "Take the inverse tangent of a value, the angle whose tangent is that value.",
"hexcasting.entry.consts": "Constants",
"hexcasting.page.consts.1": "The left-hand counter-clockwise pattern adds [1, 0, 0] to the stack; the right-hand clockwise pattern adds [-1, 0, 0].",
"hexcasting.page.consts.2": "The left-hand counter-clockwise pattern adds [0, 1, 0] to the stack; the right-hand clockwise pattern adds [0, -1, 0].",
"hexcasting.page.consts.3": "The left-hand counter-clockwise pattern adds [0, 0, 1]; the right-hand clockwise pattern adds [0, 0, -1].",
"hexcasting.page.consts.4": "Adds [0, 0, 0] to the stack.",
"hexcasting.page.consts.5": "Adds the Null influence to the top of the stack.",
"hexcasting.page.consts.5": "Adds τ, the radial representation of a complete circle, to the stack.",
"hexcasting.page.consts.6": "Adds π, the radial representation of half a circle, to the stack.",
"hexcasting.page.consts.7": "Adds the Null influence to the top of the stack.",
"hexcasting.entry.stackmanip": "Stack Manipulation",
"hexcasting.page.stackmanip.1": "Swaps the top two iotas of the stack.",

View file

@ -70,12 +70,26 @@
"output": "vector",
"text": "hexcasting.page.consts.4"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:const/double/tau",
"input": "",
"output": "num",
"text": "hexcasting.page.consts.5"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:const/double/pi",
"input": "",
"output": "num",
"text": "hexcasting.page.consts.6"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:const/null",
"input": "",
"output": "influence",
"text": "hexcasting.page.consts.5"
"text": "hexcasting.page.consts.7"
}
]
}

View file

@ -100,6 +100,54 @@
"input": "vector",
"output": "num, num, num",
"text": "hexcasting.page.math.15"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:sin",
"anchor": "hexcasting:sin",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.16"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:cos",
"anchor": "hexcasting:cos",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.17"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:tan",
"anchor": "hexcasting:tan",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.18"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:arcsin",
"anchor": "hexcasting:arcsin",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.19"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:arccos",
"anchor": "hexcasting:arccos",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.20"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:arctan",
"anchor": "hexcasting:arctan",
"input": "num",
"output": "num",
"text": "hexcasting.page.math.21"
}
]
}