Skip to content

Commit

Permalink
qmake & qunmake fixed, changed base Q pattern, added book stuff for CNs
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticneticat committed Jun 7, 2024
1 parent 8c50e8d commit ee333cd
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.common.lib.hex.HexActions;
import dev.kineticcat.complexhex.Complexhex;
import dev.kineticcat.complexhex.casting.spells.OpCongrats;
import dev.kineticcat.complexhex.stuff.ComplexNumber;
import dev.kineticcat.complexhex.stuff.Quaternion;
import net.minecraft.core.Registry;
Expand All @@ -25,38 +24,37 @@ public class ComplexhexPatternRegistry {
public static final Logger LOGGER = LogManager.getLogger(Complexhex.MOD_ID);
private static final Map<ResourceLocation, ActionRegistryEntry> PATTERNS = new LinkedHashMap<>();

public static final HexPattern CONGRATS = make("eed", HexDir.WEST, "congrats", new OpCongrats());
//Complex Arithmetic
public static final HexPattern CONST$COMPLEX$1$ = make("wqqa", HexDir.SOUTH_WEST, "const/complex/1",
Action.makeConstantOp(new ComplexNumber(1, 0).asIota()));
public static final HexPattern CONST$COMPLEX$I$ = make("wqq", HexDir.SOUTH_WEST, "const/complex/i",
Action.makeConstantOp(new ComplexNumber(0, 1).asIota()));
public static final HexPattern COMPLEXMUL = make("wqqewaqaw", HexDir.SOUTH_WEST, "complexmul");
public static final HexPattern COMPLEXMUL = make("wqqewaqaw", HexDir.SOUTH_WEST, "cmul");
public static final HexPattern REAL = make("wqqq", HexDir.SOUTH_WEST, "real");
public static final HexPattern IMAGINARY = make("wqqe", HexDir.SOUTH_WEST, "imaginary");
public static final HexPattern CONJUGATE = make("wqqd", HexDir.SOUTH_WEST, "conjugate");

// Quaternion Arithmetic
public static final HexPattern CONST$QUAT$1$ = make("deeeeeqa", HexDir.SOUTH_EAST, "const/quaternion/1",
public static final HexPattern CONST$QUAT$1$ = make("waqqqqqea", HexDir.SOUTH_EAST, "const/quaternion/1",
Action.makeConstantOp(new Quaternion(1, 0, 0, 0).asIota()));
public static final HexPattern CONST$QUAT$I$ = make("deeeeeqq", HexDir.SOUTH_EAST, "const/quaternion/i",
public static final HexPattern CONST$QUAT$I$ = make("waqqqqqeq", HexDir.SOUTH_EAST, "const/quaternion/i",
Action.makeConstantOp(new Quaternion(0, 1, 0, 0).asIota()));
public static final HexPattern CONST$QUAT$J$ = make("deeeeeqe", HexDir.SOUTH_EAST, "const/quaternion/j",
public static final HexPattern CONST$QUAT$J$ = make("waqqqqqee", HexDir.SOUTH_EAST, "const/quaternion/j",
Action.makeConstantOp(new Quaternion(0, 0, 1, 0).asIota()));
public static final HexPattern CONST$QUAT$K$ = make("deeeeeqd", HexDir.SOUTH_EAST, "const/quaternion/k",
public static final HexPattern CONST$QUAT$K$ = make("waqqqqqed", HexDir.SOUTH_EAST, "const/quaternion/k",
Action.makeConstantOp(new Quaternion(0, 0, 0, 1).asIota()));
public static final HexPattern QMUL = make("deeeeeqwaqaw", HexDir.SOUTH_EAST, "qmul");
public static final HexPattern QINVERT = make("deeeeeqw", HexDir.SOUTH_EAST, "qinvert");
public static final HexPattern QA = make("deeeeeqaw", HexDir.SOUTH_EAST, "qa");
public static final HexPattern QB = make("deeeeeqqw", HexDir.SOUTH_EAST, "qb");
public static final HexPattern QC = make("deeeeeqew", HexDir.SOUTH_EAST, "qc");
public static final HexPattern QD = make("deeeeeqdw", HexDir.SOUTH_EAST, "qd");
public static final HexPattern QMAKE = make("deeeeeq", HexDir.SOUTH_EAST, "qmake");
public static final HexPattern QUNMAKE = make("aqqqqqe", HexDir.SOUTH_EAST, "qunmake");
public static final HexPattern QMUL = make("waqqqqqewaqaw", HexDir.SOUTH_EAST, "qmul");
public static final HexPattern QINVERT = make("waqqqqqew", HexDir.SOUTH_EAST, "qinvert");
public static final HexPattern QA = make("waqqqqqeaw", HexDir.SOUTH_EAST, "qa");
public static final HexPattern QB = make("waqqqqqeqw", HexDir.SOUTH_EAST, "qb");
public static final HexPattern QC = make("waqqqqqeew", HexDir.SOUTH_EAST, "qc");
public static final HexPattern QD = make("waqqqqqedw", HexDir.SOUTH_EAST, "qd");
public static final HexPattern QMAKE = make("waqqqqqe", HexDir.SOUTH_EAST, "qmake");
public static final HexPattern QUNMAKE = make("wdeeeeeq", HexDir.SOUTH_EAST, "qunmake");

public static void init() {
for (Map.Entry<ResourceLocation, ActionRegistryEntry> entry : PATTERNS.entrySet()) {
LOGGER.info(entry);
// LOGGER.info(entry);
Registry.register(HexActions.REGISTRY, entry.getKey(), entry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
package dev.kineticcat.complexhex.casting.arithmetic.quaternion

import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorBasic
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getDouble
import at.petrak.hexcasting.api.casting.iota.DoubleIota
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.iota.Vec3Iota
import dev.kineticcat.complexhex.api.casting.iota.ComplexHexIotaTypes
import dev.kineticcat.complexhex.api.casting.iota.QuaternionIota
import dev.kineticcat.complexhex.stuff.Quaternion
import net.minecraft.world.phys.Vec3
import kotlin.math.sign

object OpQunmake : OperatorBasic(1, QuaternionArithmetic.ACCEPTS_Q) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator()
val Q = Operator.downcast(it.next(), ComplexHexIotaTypes.QUATERNION).quaternion
val Q = (iotas.iterator().next() as QuaternionIota).quaternion
return listOf(DoubleIota(Q.a), Vec3Iota(Vec3(Q.b, Q.c, Q.d)))
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.kineticcat.complexhex.casting.spells
package dev.kineticcat.complexhex.casting.spell

import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.casting.ParticleSpray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

public class ComplexNumber {
Expand Down
20 changes: 16 additions & 4 deletions common/src/main/resources/assets/complexhex/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"complexhex.entry.complexities": "Complexities",
"hexcasting.action.book.complexhex:const/complex/i": "Constant Imagination",
"complexhex.entry.complex_actions": "Complexities",
"complexhex.page.complex_actions.const.i": "Pushes 0 + 1i to the stack",


"complexhex.page.complexities.const.i": "Pushes 0 + 1i to the stack.",
"hexcasting.action.book.complexhex:const/complex/1": "Constant Realisation",
"complexhex.page.complexities.add": "Preforms Addition, num will be treated as num + 0i.",
"complexhex.page.complexities.sub": "Preforms Subtraction, num will be treated as num + 0i.",
"complexhex.page.complexities.mul": "Preforms Scalar Multiplication.",
"complexhex.page.complexities.div": "Preforms Scalar Division.",
"complexhex.page.complexities.abs": "Pushes the Argument (the length).",
"hexcasting.action.book.complexhex:cmul": "Complex Multiplication",
"complexhex.page.complexities.cmul": "Preforms Complex Multiplication.",
"hexcasting.action.book.complexhex:real": "Realising Complexities",
"complexhex.page.complexities.real": "Pushes the real coefficient.",
"hexcasting.action.book.complexhex:imaginary": "Imagining Complexities",
"complexhex.page.complexities.imaginary": "Pushes the imaginary coefficient.",
"hexcasting.action.book.complexhex:conjugate": "Conjugation Purification",
"complexhex.page.complexities.conjugate": "Negates the imaginary coefficient of the topmost iota"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"name": "complexhex.entry.complexities",
"category": "hexcasting:patterns",
"icon": "minecraft:phantom_membrane",
"sortnum": 0,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "complexhex:const/complex/i",
"anchor": "complexhex:const/complex/i",
"input": "",
"output": "complex",
"text": "complexhex.page.complexities.const.i"
},
{
"type": "hexcasting:pattern",
"op_id": "complexhex:const/complex/1",
"anchor": "complexhex:const/complex/1",
"input": "",
"output": "complex",
"text": "complexhex.page.complexities.const.1"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:add",
"anchor": "hexcasting:add",
"input": "complex, complex/num",
"output": "complex",
"text": "complexhex.page.complexities.add"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:sub",
"anchor": "hexcasting:sub",
"input": "complex, complex/num",
"output": "complex",
"text": "complexhex.page.complexities.sub"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:mul",
"anchor": "hexcasting:mul",
"input": "complex, num",
"output": "complex",
"text": "complexhex.page.complexities.mul"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:div",
"anchor": "hexcasting:div",
"input": "complex, num",
"output": "complex",
"text": "complexhex.page.complexities.div"
},
{
"type": "hexcasting:pattern",
"op_id": "complexhex:cmul",
"anchor": "complexhex:cmul",
"input": "complex, complex",
"output": "complex",
"text": "complexhex.page.complexities.cmul"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:abs",
"anchor": "hexcasting:abs",
"input": "complex",
"output": "num",
"text": "complexhex.page.complexities.abs"
},
{
"type": "hexcasting:pattern",
"op_id": "complexhex:real",
"anchor": "complexhex:real",
"input": "complex",
"output": "num",
"text": "complexhex.page.complexities.real"
},
{
"type": "hexcasting:pattern",
"op_id": "complexhex:imaginary",
"anchor": "complexhex:imaginary",
"input": "complex",
"output": "num",
"text": "complexhex.page.complexities.imaginary"
},
{
"type": "hexcasting:pattern",
"op_id": "complexhex:conjugate",
"anchor": "complexhex:conjugate",
"input": "complex",
"output": "num",
"text": "complexhex.page.complexities.conjugate"
}
]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "complexhex:congrats",
"anchor": "hexcasting:congrats",
"op_id": "complexhex:qa",
"anchor": "complexhex:qa",
"input": "",
"output": "bool",
"text": "complexhex.page.dummy_spells.congrats"
Expand Down

0 comments on commit ee333cd

Please sign in to comment.