separate foot/eye pos

This commit is contained in:
gamma-delta 2022-11-05 23:01:52 +01:00
parent 8ce90a5c1d
commit 0ea05ab030
4 changed files with 40 additions and 31 deletions

View file

@ -55,8 +55,10 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.fromAngles("qaq", HexDir.NORTH_EAST), modLoc("get_caster"),
OpGetCaster.INSTANCE);
PatternRegistry.mapPattern(HexPattern.fromAngles("aa", HexDir.EAST), modLoc("get_entity_pos"),
OpEntityPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.fromAngles("aa", HexDir.EAST), modLoc("entity_pos/eye"),
new OpEntityPos(false));
PatternRegistry.mapPattern(HexPattern.fromAngles("dd", HexDir.NORTH_WEST), modLoc("entity_pos/foot"),
new OpEntityPos(true));
PatternRegistry.mapPattern(HexPattern.fromAngles("wa", HexDir.EAST), modLoc("get_entity_look"),
OpEntityLook.INSTANCE);
PatternRegistry.mapPattern(HexPattern.fromAngles("awq", HexDir.NORTH_EAST), modLoc("get_entity_height"),

View file

@ -5,16 +5,13 @@ import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
import net.minecraft.world.entity.player.Player
object OpEntityPos : ConstManaAction {
class OpEntityPos(val feet: Boolean) : ConstManaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val e = args.getEntity(0, argc)
ctx.assertEntityInRange(e)
// If this is a player, "expected behavior" is to get the *eye* position so raycasts don't immediately
// hit the ground.
return (if (e is Player) e.eyePosition else e.position()).asActionResult
return (if (this.feet) e.position() else e.eyePosition).asActionResult
}
}

View file

@ -217,7 +217,8 @@
"hexcasting.subtitles.lore_fragment.read": "Read lore fragment",
"hexcasting.spell.hexcasting:get_caster": "Mind's Reflection",
"hexcasting.spell.hexcasting:get_entity_pos": "Compass' Purification",
"hexcasting.spell.hexcasting:entity_pos/eye": "Compass' Purification",
"hexcasting.spell.hexcasting:entity_pos/foot": "Compass' Purification II",
"hexcasting.spell.hexcasting:get_entity_look": "Alidade's Purification",
"hexcasting.spell.hexcasting:get_entity_height": "Stadiometer's Prfn.",
"hexcasting.spell.hexcasting:get_entity_velocity": "Pace Purification",
@ -748,16 +749,17 @@
"hexcasting.entry.basics_pattern": "Basic Patterns",
"hexcasting.page.basics_pattern.get_caster": "Adds me, the caster, to the stack.",
"hexcasting.page.basics_pattern.get_entity_pos": "Transforms an entity on the stack into its position.",
"hexcasting.page.basics_pattern.entity_pos/eye": "Transforms an entity on the stack into the position of its eyes. I should probably use this on myself.",
"hexcasting.page.basics_pattern.entity_pos/feet": "Transforms an entity on the stack into the position it is standing. I should probably use this on other entities.",
"hexcasting.page.basics_pattern.get_entity_look": "Transforms an entity on the stack into the direction it's looking in, as a unit vector.",
"hexcasting.page.basics_pattern.get_entity_height": "Transforms an entity on the stack into its height.",
"hexcasting.page.basics_pattern.get_entity_velocity": "Transforms an entity on the stack into the direction in which it's moving, with the speed of that movement as that direction's magnitude.",
"hexcasting.page.basics_pattern.print": "Displays the top iota of the stack to me.",
"hexcasting.page.basics_pattern.raycast.1": "Combines two vectors (a position and a direction) into the answer to the question: If I stood at the position and looked in the direction, what block would I be looking at? Costs a negligible amount of _media.",
"hexcasting.page.basics_pattern.raycast.2": "For example, casting this with my own position and look vectors will return the coordinates of the block I am looking at.$(br2)If it doesn't hit anything, the vectors will combine into $(l:casting/influences)$(thing)Null/$.",
"hexcasting.page.basics_pattern.raycast.2": "If it doesn't hit anything, the vectors will combine into $(l:casting/influences)$(thing)Null/$.$(br2)A common sequence of patterns, the so-called \"raycast mantra,\" is $(action)Mind's Reflection/$, $(action)Compass Purification/$, $(action)Mind's Reflection/$, $(action)Alidade Purification/$, $(action)Archer's Distillation/$. Together, they return the vector position of the block I am looking at.",
"hexcasting.page.basics_pattern.raycast/axis.1": "Like $(l:patterns/basics#hexcasting:raycast)$(action)Archer's Distillation/$, but instead returns a vector representing the answer to the question: Which $(italic)side/$ of the block am I looking at? Costs a negligible amount of _media.",
"hexcasting.page.basics_pattern.raycast/axis.2": "More specifically, it returns the $(italic)normal vector/$ of the face hit, or a unit vector pointing perpendicular to the face.$(li)If I am looking at a floor, it will return (0, 1, 0).$(li)If I am looking at the south face of a block, it will return (0, 0, 1).",
"hexcasting.page.basics_pattern.raycast/entity": "Like $(l:patterns/basics#hexcasting:raycast)$(action)Archer's Distillation/$, but instead returns the $(italic)entity/$ I am looking at. Costs a negligible amount of _media.",
"hexcasting.page.basics_pattern.get_entity_height": "Transforms an entity on the stack into its height.",
"hexcasting.page.basics_pattern.get_entity_velocity": "Transforms an entity on the stack into the direction in which it's moving, with the speed of that movement as that direction's magnitude.",
"hexcasting.entry.numbers": "Number Literals",
"hexcasting.page.numbers.1.header": "Numerical Reflection",

View file

@ -16,11 +16,19 @@
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:get_entity_pos",
"anchor": "hexcasting:get_entity_pos",
"op_id": "hexcasting:entity_pos/eye",
"anchor": "hexcasting:entity_pos/eye",
"input": "entity",
"output": "vector",
"text": "hexcasting.page.basics_pattern.get_entity_pos"
"text": "hexcasting.page.basics_pattern.entity_pos/eye"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:entity_pos/foot",
"anchor": "hexcasting:entity_pos/foot",
"input": "entity",
"output": "vector",
"text": "hexcasting.page.basics_pattern.entity_pos/foot"
},
{
"type": "hexcasting:pattern",
@ -30,22 +38,6 @@
"output": "vector",
"text": "hexcasting.page.basics_pattern.get_entity_look"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:get_entity_height",
"anchor": "hexcasting:get_entity_height",
"input": "entity",
"output": "num",
"text": "hexcasting.page.basics_pattern.get_entity_height"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:get_entity_velocity",
"anchor": "hexcasting:get_entity_velocity",
"input": "entity",
"output": "vector",
"text": "hexcasting.page.basics_pattern.get_entity_velocity"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:print",
@ -85,6 +77,22 @@
"input": "vector, vector",
"output": "entity",
"text": "hexcasting.page.basics_pattern.raycast/entity"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:get_entity_height",
"anchor": "hexcasting:get_entity_height",
"input": "entity",
"output": "num",
"text": "hexcasting.page.basics_pattern.get_entity_height"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:get_entity_velocity",
"anchor": "hexcasting:get_entity_velocity",
"input": "entity",
"output": "vector",
"text": "hexcasting.page.basics_pattern.get_entity_velocity"
}
]
}