From b6e90994c98b6afdb8276d5d5006bff4a0d956c4 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sun, 10 Apr 2022 22:50:26 -0400 Subject: [PATCH] random! --- .../client/RegisterClientStuff.java | 4 ++-- ... BlockEntityAkashicBookshelfRenderer.java} | 4 ++-- .../common/casting/RegisterPatterns.java | 5 ++++- .../common/casting/operators/math/OpRandom.kt | 21 +++++++++++++++++++ .../assets/hexcasting/lang/en_us.json | 18 +++++++++------- .../en_us/entries/patterns/basics.json | 16 +++++++------- .../en_us/entries/patterns/math.json | 8 +++++++ .../en_us/entries/patterns/stackmanip.json | 8 +++---- 8 files changed, 59 insertions(+), 25 deletions(-) rename src/main/java/at/petrak/hexcasting/client/be/{BlockEntityAkashicRecordRenderer.java => BlockEntityAkashicBookshelfRenderer.java} (93%) create mode 100644 src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt diff --git a/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java b/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java index 1c2cec72..ee59bc3a 100644 --- a/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java +++ b/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java @@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.circle.BlockAbstractImpetus; import at.petrak.hexcasting.api.circle.BlockEntityAbstractImpetus; import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry; import at.petrak.hexcasting.api.spell.SpellDatum; -import at.petrak.hexcasting.client.be.BlockEntityAkashicRecordRenderer; +import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer; import at.petrak.hexcasting.client.be.BlockEntitySlateRenderer; import at.petrak.hexcasting.client.entity.WallScrollRenderer; import at.petrak.hexcasting.client.particles.ConjureParticle; @@ -216,6 +216,6 @@ public class RegisterClientStuff { public static void registerRenderers(EntityRenderersEvent.RegisterRenderers evt) { evt.registerBlockEntityRenderer(HexBlockEntities.SLATE_TILE.get(), BlockEntitySlateRenderer::new); evt.registerBlockEntityRenderer(HexBlockEntities.AKASHIC_BOOKSHELF_TILE.get(), - BlockEntityAkashicRecordRenderer::new); + BlockEntityAkashicBookshelfRenderer::new); } } diff --git a/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicRecordRenderer.java b/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java similarity index 93% rename from src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicRecordRenderer.java rename to src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java index 3cda0334..bb3471c1 100644 --- a/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicRecordRenderer.java +++ b/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java @@ -18,9 +18,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class BlockEntityAkashicRecordRenderer implements BlockEntityRenderer { +public class BlockEntityAkashicBookshelfRenderer implements BlockEntityRenderer { - public BlockEntityAkashicRecordRenderer(BlockEntityRendererProvider.Context ctx) { + public BlockEntityAkashicBookshelfRenderer(BlockEntityRendererProvider.Context ctx) { // NO-OP } diff --git a/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java b/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java index 21193919..2fb2ae42 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java +++ b/src/main/java/at/petrak/hexcasting/common/casting/RegisterPatterns.java @@ -54,7 +54,7 @@ public class RegisterPatterns { OpEntityPos.INSTANCE); PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wa", HexDir.EAST), prefix("get_entity_look"), OpEntityLook.INSTANCE); - PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awq", HexDir.NORTH_EAST), prefix("get_entity_look"), + PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awq", HexDir.NORTH_EAST), prefix("get_entity_height"), OpEntityHeight.INSTANCE); PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wq", HexDir.EAST), prefix("get_entity_velocity"), OpEntityVelocity.INSTANCE); @@ -152,6 +152,9 @@ public class RegisterPatterns { PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eadeeeeew", HexDir.NORTH_EAST), prefix("arctan"), OpArcTan.INSTANCE); + PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqq", HexDir.NORTH_WEST), prefix("random"), + OpRandom.INSTANCE); + // == Spells == PatternRegistry.mapPattern(HexPattern.FromAnglesSig("de", HexDir.NORTH_EAST), prefix("print"), diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt new file mode 100644 index 00000000..9659d8ad --- /dev/null +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/math/OpRandom.kt @@ -0,0 +1,21 @@ +package at.petrak.hexcasting.common.casting.operators.math + +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 +import kotlin.math.floor + +object OpRandom : ConstManaOperator { + override val argc: Int + get() = 0 + + override fun execute(args: List>, ctx: CastingContext): List> { + return spellListOf(ctx.world.random.nextDouble()) + } +} diff --git a/src/main/resources/assets/hexcasting/lang/en_us.json b/src/main/resources/assets/hexcasting/lang/en_us.json index 778da009..cb219b23 100644 --- a/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/src/main/resources/assets/hexcasting/lang/en_us.json @@ -160,7 +160,7 @@ "hexcasting.spell.hexcasting:get_caster": "Mind's Reflection", "hexcasting.spell.hexcasting:get_entity_pos": "Compass' Purification", "hexcasting.spell.hexcasting:get_entity_look": "Alidade's Purification", - "hexcasting.spell.hexcasting:get_entity_height": "Stadiometer's Purification", + "hexcasting.spell.hexcasting:get_entity_height": "Stadiometer's Prfn.", "hexcasting.spell.hexcasting:get_entity_velocity": "Pace Purification", "hexcasting.spell.hexcasting:raycast": "Archer's Distillation", "hexcasting.spell.hexcasting:raycast/axis": "Architect's Distillation", @@ -232,6 +232,7 @@ "hexcasting.spell.hexcasting:arcsin": "Inverse Sine Prfn.", "hexcasting.spell.hexcasting:arccos": "Inverse Cosine Prfn.", "hexcasting.spell.hexcasting:arctan": "Inverse Tangent Prfn.", + "hexcasting.spell.hexcasting:random": "Entropy Reflection", "hexcasting.spell.hexcasting:coerce_axial": "Axial Purification", "hexcasting.spell.hexcasting:print": "Reveal", "hexcasting.spell.hexcasting:explode": "Explosion", @@ -284,8 +285,8 @@ "hexcasting.spell.hexcasting:eval/delay": "Secret Gambit!", "hexcasting.spell.hexcasting:read": "Scribe's Reflection", "hexcasting.spell.hexcasting:write": "Scribe's Gambit", - "hexcasting.spell.hexcasting:read/akashic": "Akasha's Distillation", - "hexcasting.spell.hexcasting:write/akashic": "Akasha's Gambit", + "hexcasting.spell.hexcasting:akashic/read": "Akasha's Distillation", + "hexcasting.spell.hexcasting:akashic/write": "Akasha's Gambit", "hexcasting.spell.hexcasting:read/entity": "Scribe's Purification", "hexcasting.spell.hexcasting:const/vec/px": "Vector Reflection +X", "hexcasting.spell.hexcasting:const/vec/py": "Vector Reflection +Y", @@ -293,9 +294,9 @@ "hexcasting.spell.hexcasting:const/vec/nx": "Vector Reflection -X", "hexcasting.spell.hexcasting:const/vec/ny": "Vector Reflection -Y", "hexcasting.spell.hexcasting:const/vec/nz": "Vector Reflection -Z", - "hexcasting.spell.hexcasting:const/vec/x": "Vector Reflection +X/-X", - "hexcasting.spell.hexcasting:const/vec/y": "Vector Reflection +Y/-Y", - "hexcasting.spell.hexcasting:const/vec/z": "Vector Reflection +Z/-Z", + "hexcasting.spell.hexcasting:const/vec/x": "Vector Rfln. +X/-X", + "hexcasting.spell.hexcasting:const/vec/y": "Vector Rfln. +Y/-Y", + "hexcasting.spell.hexcasting:const/vec/z": "Vector Rfln. +Z/-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", @@ -627,7 +628,7 @@ "hexcasting.page.math.abs_len.1": "Compute the absolute value or length.", "hexcasting.page.math.abs_len.2": "Replaces a number with its absolute value, or a vector with its length.", "hexcasting.page.math.pow_proj.1": "Perform exponentiation or vector projection.", - "hexcasting.page.math.pow_proj.2": "$(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.pow_proj.2": "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.floor": "\"Floors\" a number, cutting off the fractional component and leaving an integer value.", "hexcasting.page.math.ceil": "\"Ceilings\" a number, raising it to the next integer value if it has a fractional component.", "hexcasting.page.math.construct_vec": "Combine three numbers at the top of the stack into a vector's X, Y, and Z components (top to bottom).", @@ -639,6 +640,7 @@ "hexcasting.page.math.arcsin": "Take the inverse sine of a value with absolute value 1 or less, yielding the angle whose sine is that value.", "hexcasting.page.math.arccos": "Take the inverse cosine of a value with absolute value 1 or less, yielding the angle whose sine is that value.", "hexcasting.page.math.arctan": "Take the inverse tangent of a value, yielding the angle whose tangent is that value.", + "hexcasting.page.math.random": "Creates a random number between 0 and 1.", "hexcasting.entry.consts": "Constants", "hexcasting.page.consts.const/vec/x": "The left-hand counter-clockwise pattern adds [1, 0, 0] to the stack; the right-hand clockwise pattern adds [-1, 0, 0].", @@ -647,7 +649,7 @@ "hexcasting.page.consts.const/vec/0": "Adds [0, 0, 0] to the stack.", "hexcasting.page.consts.const/double/tau": "Adds τ, the radial representation of a complete circle, to the stack.", "hexcasting.page.consts.const/double/pi": "Adds π, the radial representation of half a circle, to the stack.", - "hexcasting.page.consts.const/double/e": "Adds 𝑒, the base of natural logarithms, to the stack.", + "hexcasting.page.consts.const/double/e": "Adds $(italic)e/$, the base of natural logarithms, to the stack.", "hexcasting.page.consts.const/null": "Adds the Null influence to the top of the stack.", "hexcasting.entry.stackmanip": "Stack Manipulation", diff --git a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/basics.json b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/basics.json index ff086547..3a959a2e 100644 --- a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/basics.json +++ b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/basics.json @@ -46,6 +46,14 @@ "output": "num", "text": "hexcasting.page.basics_pattern.get_entity_velocity" }, + { + "type": "hexcasting:pattern", + "op_id": "hexcasting:print", + "anchor": "hexcasting:print", + "input": "any", + "output": "any", + "text": "hexcasting.page.basics_pattern.print" + }, { "type": "hexcasting:pattern", "op_id": "hexcasting:raycast", @@ -77,14 +85,6 @@ "input": "vector, vector", "output": "entity", "text": "hexcasting.page.basics_pattern.raycast/entity" - }, - { - "type": "hexcasting:pattern", - "op_id": "hexcasting:print", - "anchor": "hexcasting:print", - "input": "any", - "output": "any", - "text": "hexcasting.page.basics_pattern.print" } ] } diff --git a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/math.json b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/math.json index 21a0c77f..932775ae 100644 --- a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/math.json +++ b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/math.json @@ -125,6 +125,14 @@ "output": "vec", "text": "hexcasting.page.math.coerce_axial" }, + { + "type": "hexcasting:pattern", + "op_id": "hexcasting:random", + "anchor": "hexcasting:random", + "input": "vec", + "output": "vec", + "text": "hexcasting.page.math.random" + }, { "type": "hexcasting:pattern", "op_id": "hexcasting:sin", diff --git a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/stackmanip.json b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/stackmanip.json index ee7b28f6..73b23691 100644 --- a/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/stackmanip.json +++ b/src/main/resources/data/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/stackmanip.json @@ -12,7 +12,7 @@ "anchor": "hexcasting:swap", "input": "any, any", "output": "any, any", - "text": "hexcasting.page.stackmanip.1" + "text": "hexcasting.page.stackmanip.swap" }, { "type": "hexcasting:pattern", @@ -20,7 +20,7 @@ "anchor": "hexcasting:fisherman", "input": "num", "output": "any", - "text": "hexcasting.page.stackmanip.2" + "text": "hexcasting.page.stackmanip.fisherman" }, { "type": "hexcasting:pattern", @@ -28,7 +28,7 @@ "anchor": "hexcasting:duplicate", "input": "any", "output": "any, any", - "text": "hexcasting.page.stackmanip.3" + "text": "hexcasting.page.stackmanip.duplicate" }, { "type": "hexcasting:pattern", @@ -36,7 +36,7 @@ "anchor": "hexcasting:duplicate_n", "input": "number, any", "output": "many", - "text": "hexcasting.page.stackmanip.4" + "text": "hexcasting.page.stackmanip.duplicate_n" }, { "type": "hexcasting:manual_pattern",