close #382
This commit is contained in:
parent
2c5309da40
commit
08a733fd7d
3 changed files with 15 additions and 9 deletions
|
@ -1,21 +1,27 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.math
|
||||
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.getVec3
|
||||
import at.petrak.hexcasting.api.casting.getNumOrVec
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import kotlin.math.sign
|
||||
|
||||
object OpCoerceToAxial : ConstMediaAction {
|
||||
override val argc: Int
|
||||
get() = 1
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val vec = args.getVec3(0, argc)
|
||||
val value = args.getNumOrVec(0, argc)
|
||||
return value.map({ num ->
|
||||
num.sign.asActionResult
|
||||
}, { vec ->
|
||||
if (vec == Vec3.ZERO)
|
||||
return vec.asActionResult
|
||||
return Vec3.atLowerCornerOf(Direction.getNearest(vec.x, vec.y, vec.z).normal).asActionResult
|
||||
vec.asActionResult
|
||||
else
|
||||
Vec3.atLowerCornerOf(Direction.getNearest(vec.x, vec.y, vec.z).normal).asActionResult
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,7 +904,7 @@
|
|||
"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).",
|
||||
"hexcasting.page.math.deconstruct_vec": "Split a vector into its X, Y, and Z components (top to bottom).",
|
||||
"hexcasting.page.math.modulo": "Takes the modulus of two numbers. This is the amount $(italics)remaining/$ after division - for example, 5 %% 2 is 1, and 5 %% 3 is 2.",
|
||||
"hexcasting.page.math.coerce_axial": "Coerces a vector to its nearest axial direction, a unit vector. The zero vector is unaffected.",
|
||||
"hexcasting.page.math.coerce_axial": "For a vector, coerce it to its nearest axial direction, a unit vector. For a number, return the sign of the number; 1 if positive, -1 if negative. In both cases, zero is unaffected.",
|
||||
"hexcasting.page.math.random": "Creates a random number between 0 and 1.",
|
||||
|
||||
"hexcasting.entry.advanced_math": "Advanced Mathematics",
|
||||
|
|
|
@ -129,8 +129,8 @@
|
|||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:coerce_axial",
|
||||
"anchor": "hexcasting:coerce_axial",
|
||||
"input": "vec",
|
||||
"output": "vec",
|
||||
"input": "vec or num",
|
||||
"output": "vec or num",
|
||||
"text": "hexcasting.page.math.coerce_axial"
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue