feat: block coordinates

This commit is contained in:
Keisuke Hirata 2025-12-09 05:58:45 +09:00
parent 3835c9b9e2
commit 66e1f74b5c
2 changed files with 15 additions and 0 deletions

View File

@ -84,3 +84,12 @@ class EntityArgument : KommandArgument<List<Entity>> {
class CoordinatesArgument : KommandArgument<io.papermc.paper.math.Position> { class CoordinatesArgument : KommandArgument<io.papermc.paper.math.Position> {
override fun build(): ArgumentType<*> = ArgumentTypes.finePosition() override fun build(): ArgumentType<*> = ArgumentTypes.finePosition()
} }
/**
* Block position argument for integer coordinates.
* Supports relative coordinates like ~ ~1 ~-2.
* Returns a Position (io.papermc.paper.math.Position) after resolving (aligned to block).
*/
class BlockPositionArgument : KommandArgument<io.papermc.paper.math.Position> {
override fun build(): ArgumentType<*> = ArgumentTypes.blockPosition()
}

View File

@ -173,6 +173,12 @@ abstract class BranchScope internal constructor(
allowRelative: Boolean = true, allowRelative: Boolean = true,
block: ValueBuilder<io.papermc.paper.math.Position>.() -> Unit = {} block: ValueBuilder<io.papermc.paper.math.Position>.() -> Unit = {}
) = argument(name, CoordinatesArgument(), block) ) = argument(name, CoordinatesArgument(), block)
fun blockCoordinates(
name: String,
allowRelative: Boolean = true,
block: ValueBuilder<io.papermc.paper.math.Position>.() -> Unit = {}
) = argument(name, BlockPositionArgument(), block)
} }
@KommandDsl @KommandDsl