diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/factory/ArgumentParserFactories.kt b/src/main/java/de/bixilon/minosoft/commands/parser/factory/ArgumentParserFactories.kt index 0085bce4e..9baa9f4f9 100644 --- a/src/main/java/de/bixilon/minosoft/commands/parser/factory/ArgumentParserFactories.kt +++ b/src/main/java/de/bixilon/minosoft/commands/parser/factory/ArgumentParserFactories.kt @@ -19,6 +19,8 @@ import de.bixilon.minosoft.commands.parser.brigadier._int.IntParser import de.bixilon.minosoft.commands.parser.brigadier._long.LongParser import de.bixilon.minosoft.commands.parser.brigadier.bool.BooleanParser import de.bixilon.minosoft.commands.parser.brigadier.string.StringParser +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec2.Vec2Parser +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec3.Vec3Parser import de.bixilon.minosoft.commands.parser.minecraft.range.RangeParserFactory import de.bixilon.minosoft.commands.parser.minecraft.range._float.FloatRangeParser import de.bixilon.minosoft.commands.parser.minecraft.range._int.IntRangeParser @@ -50,6 +52,9 @@ object ArgumentParserFactories : DefaultFactory>( ResourceLocationParser, TimeParser, + Vec2Parser, + Vec3Parser, + DummyParser, ScoreHolderParser, @@ -60,8 +65,6 @@ object ArgumentParserFactories : DefaultFactory>( minecraft:game_profile minecraft:block_pos minecraft:column_pos -minecraft:vec3 -minecraft:vec2 minecraft:block_state minecraft:block_predicate minecraft:item_stack diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/Coordinate.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/Coordinate.kt new file mode 100644 index 000000000..58bdd01cb --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/Coordinate.kt @@ -0,0 +1,19 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate + +data class Coordinate( + val relatives: CoordinateRelatives, + val offset: Float, +) diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateParserUtil.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateParserUtil.kt new file mode 100644 index 000000000..4f3375ea3 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateParserUtil.kt @@ -0,0 +1,48 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate + +import de.bixilon.minosoft.commands.parser.brigadier._float.FloatParser.Companion.readFloat +import de.bixilon.minosoft.commands.util.CommandReader + +object CoordinateParserUtil { + + fun CommandReader.readCoordinateOrNull(): Coordinate? { + val peek = peek() ?: return null + val type = when (peek) { + '~'.code -> { + read() + CoordinateRelatives.TILDE + } + '^'.code -> { + read() + CoordinateRelatives.CARET + } + else -> CoordinateRelatives.NONE + } + + val offset = if (peekWhitespaces() == 0) readFloat() else null + if (offset == null && type == CoordinateRelatives.NONE) { + return null + } + + + return Coordinate(type, offset ?: 0.0f) + } + + + fun CommandReader.readCoordinate(): Coordinate { + readResult { readCoordinateOrNull() }.let { return it.result ?: throw InvalidCoordinateError(this, it) } + } +} diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateRelatives.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateRelatives.kt new file mode 100644 index 000000000..be705aab5 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/CoordinateRelatives.kt @@ -0,0 +1,21 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate + +enum class CoordinateRelatives { + NONE, + TILDE, + CARET, + ; +} diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/InvalidCoordinateError.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/InvalidCoordinateError.kt new file mode 100644 index 000000000..474c0b3b9 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/InvalidCoordinateError.kt @@ -0,0 +1,23 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate + +import de.bixilon.minosoft.commands.errors.parser.ParserError +import de.bixilon.minosoft.commands.util.CommandReader +import de.bixilon.minosoft.commands.util.ReadResult + +class InvalidCoordinateError( + reader: CommandReader, + result: ReadResult, +) : ParserError(reader, result) diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Coordinate.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Coordinate.kt new file mode 100644 index 000000000..631a9e7f7 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Coordinate.kt @@ -0,0 +1,21 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec2 + +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.Coordinate + +data class Vec2Coordinate( + val x: Coordinate, + val y: Coordinate, +) diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Parser.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Parser.kt new file mode 100644 index 000000000..6fadd3ea6 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2Parser.kt @@ -0,0 +1,42 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec2 + +import de.bixilon.minosoft.commands.parser.ArgumentParser +import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.CoordinateParserUtil.readCoordinate +import de.bixilon.minosoft.commands.util.CommandReader +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.text.ChatComponent +import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer +import de.bixilon.minosoft.util.KUtil.toResourceLocation + +object Vec2Parser : ArgumentParser, ArgumentParserFactory { + override val RESOURCE_LOCATION: ResourceLocation = "minecraft:vec2".toResourceLocation() + override val examples: List = listOf("~ ~ ", "^ ^", "5 5") + override val placeholder = ChatComponent.of("") + + override fun parse(reader: CommandReader): Vec2Coordinate { + return Vec2Coordinate(reader.readCoordinate(), reader.readCoordinate()) + } + + override fun getSuggestions(reader: CommandReader): List { + if (reader.readString()?.isBlank() != false) { + return examples + } + return emptyList() + } + + override fun read(buffer: PlayInByteBuffer) = this +} diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Coordinate.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Coordinate.kt new file mode 100644 index 000000000..78df38e7f --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Coordinate.kt @@ -0,0 +1,22 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec3 + +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.Coordinate + +data class Vec3Coordinate( + val x: Coordinate, + val y: Coordinate, + val z: Coordinate, +) diff --git a/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Parser.kt b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Parser.kt new file mode 100644 index 000000000..7c7ca66ce --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3Parser.kt @@ -0,0 +1,42 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec3 + +import de.bixilon.minosoft.commands.parser.ArgumentParser +import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.CoordinateParserUtil.readCoordinate +import de.bixilon.minosoft.commands.util.CommandReader +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.text.ChatComponent +import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer +import de.bixilon.minosoft.util.KUtil.toResourceLocation + +object Vec3Parser : ArgumentParser, ArgumentParserFactory { + override val RESOURCE_LOCATION: ResourceLocation = "minecraft:vec3".toResourceLocation() + override val examples: List = listOf("~ ~ ~", "^ ^ ^", "5 5 5") + override val placeholder = ChatComponent.of("") + + override fun parse(reader: CommandReader): Vec3Coordinate { + return Vec3Coordinate(reader.readCoordinate(), reader.readCoordinate(), reader.readCoordinate()) + } + + override fun getSuggestions(reader: CommandReader): List { + if (reader.readString()?.isBlank() != false) { + return examples + } + return emptyList() + } + + override fun read(buffer: PlayInByteBuffer) = this +} diff --git a/src/main/java/de/bixilon/minosoft/commands/util/CommandReader.kt b/src/main/java/de/bixilon/minosoft/commands/util/CommandReader.kt index 0c557c802..8a5f4fdcf 100644 --- a/src/main/java/de/bixilon/minosoft/commands/util/CommandReader.kt +++ b/src/main/java/de/bixilon/minosoft/commands/util/CommandReader.kt @@ -240,7 +240,7 @@ open class CommandReader(val string: String) { } val builder = StringBuilder() while (true) { - val peek = peek() ?: break + val peek = peekNext() ?: break if (peek in '0'.code..'9'.code) { builder.appendCodePoint(peek) pointer++ diff --git a/src/main/java/de/bixilon/minosoft/data/world/container/palette/palettes/SingularPalette.kt b/src/main/java/de/bixilon/minosoft/data/world/container/palette/palettes/SingularPalette.kt index 3650c0109..d4b0f49bf 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/container/palette/palettes/SingularPalette.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/container/palette/palettes/SingularPalette.kt @@ -25,7 +25,6 @@ class SingularPalette(private val registry: AbstractRegistry) : Palette. + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate + +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.CoordinateParserUtil.readCoordinate +import de.bixilon.minosoft.commands.util.CommandReader +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import kotlin.test.assertEquals + +internal class CoordinateParserUtilTest { + + @Test + fun readNumericPositive() { + val reader = CommandReader("5") + assertEquals(Coordinate(CoordinateRelatives.NONE, 5.0f), reader.readCoordinate()) + } + + @Test + fun readNumericNegative() { + val reader = CommandReader("-5") + assertEquals(Coordinate(CoordinateRelatives.NONE, -5.0f), reader.readCoordinate()) + } + + @Test + fun readTilde() { + val reader = CommandReader("~") + assertEquals(Coordinate(CoordinateRelatives.TILDE, 0.0f), reader.readCoordinate()) + } + + @Test + fun readTildePositiveOffset() { + val reader = CommandReader("~1") + assertEquals(Coordinate(CoordinateRelatives.TILDE, 1.0f), reader.readCoordinate()) + } + + @Test + fun readTildeNegativeOffset() { + val reader = CommandReader("~-1") + assertEquals(Coordinate(CoordinateRelatives.TILDE, -1.0f), reader.readCoordinate()) + } + + @Test + fun readCaret() { + val reader = CommandReader("^") + assertEquals(Coordinate(CoordinateRelatives.CARET, 0.0f), reader.readCoordinate()) + } + + @Test + fun readCaretPositiveOffset() { + val reader = CommandReader("^1") + assertEquals(Coordinate(CoordinateRelatives.CARET, 1.0f), reader.readCoordinate()) + } + + @Test + fun readCaretNegativeOffset() { + val reader = CommandReader("^-1") + assertEquals(Coordinate(CoordinateRelatives.CARET, -1.0f), reader.readCoordinate()) + } + + @Test + fun readInvalidPrefix() { + val reader = CommandReader("&12") + assertThrows { reader.readCoordinate() } + } + + @Test + fun read2() { + val reader = CommandReader("~ 12") + assertEquals(Coordinate(CoordinateRelatives.TILDE, 0.0f), reader.readCoordinate()) + assertEquals(Coordinate(CoordinateRelatives.NONE, 12.0f), reader.readCoordinate()) + } +} diff --git a/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2ParserTest.kt b/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2ParserTest.kt new file mode 100644 index 000000000..dd0c016ef --- /dev/null +++ b/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec2/Vec2ParserTest.kt @@ -0,0 +1,62 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec2 + +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.Coordinate +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.CoordinateRelatives +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.InvalidCoordinateError +import de.bixilon.minosoft.commands.util.CommandReader +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import kotlin.test.assertEquals + + +internal class Vec2ParserTest { + + @Test + fun readNumeric() { + val reader = CommandReader("5 5") + assertEquals(Vec2Coordinate(Coordinate(CoordinateRelatives.NONE, 5.0f), Coordinate(CoordinateRelatives.NONE, 5.0f)), Vec2Parser.parse(reader)) + } + + @Test + fun readTilde() { + val reader = CommandReader("~ ~") + assertEquals(Vec2Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)), Vec2Parser.parse(reader)) + } + + @Test + fun readCaret() { + val reader = CommandReader("^ ^") + assertEquals(Vec2Coordinate(Coordinate(CoordinateRelatives.CARET, 0.0f), Coordinate(CoordinateRelatives.CARET, 0.0f)), Vec2Parser.parse(reader)) + } + + @Test + fun readNumericTilde() { + val reader = CommandReader("5 ~") + assertEquals(Vec2Coordinate(Coordinate(CoordinateRelatives.NONE, 5.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)), Vec2Parser.parse(reader)) + } + + @Test + fun readTildeCaret() { + val reader = CommandReader("~4 ^-9") + assertEquals(Vec2Coordinate(Coordinate(CoordinateRelatives.TILDE, 4.0f), Coordinate(CoordinateRelatives.CARET, -9.0f)), Vec2Parser.parse(reader)) + } + + @Test + fun readOnlyOne() { + val reader = CommandReader("~4") + assertThrows { Vec2Parser.parse(reader) } + } +} diff --git a/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3ParserTest.kt b/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3ParserTest.kt new file mode 100644 index 000000000..f68d7602b --- /dev/null +++ b/src/test/java/de/bixilon/minosoft/commands/parser/minecraft/coordinate/vec3/Vec3ParserTest.kt @@ -0,0 +1,68 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.commands.parser.minecraft.coordinate.vec3 + +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.Coordinate +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.CoordinateRelatives +import de.bixilon.minosoft.commands.parser.minecraft.coordinate.InvalidCoordinateError +import de.bixilon.minosoft.commands.util.CommandReader +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import kotlin.test.assertEquals + + +internal class Vec3ParserTest { + + @Test + fun readNumeric() { + val reader = CommandReader("5 5 5") + assertEquals(Vec3Coordinate(Coordinate(CoordinateRelatives.NONE, 5.0f), Coordinate(CoordinateRelatives.NONE, 5.0f), Coordinate(CoordinateRelatives.NONE, 5.0f)), Vec3Parser.parse(reader)) + } + + @Test + fun readTilde() { + val reader = CommandReader("~ ~ ~") + assertEquals(Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)), Vec3Parser.parse(reader)) + } + + @Test + fun readCaret() { + val reader = CommandReader("^ ^ ^") + assertEquals(Vec3Coordinate(Coordinate(CoordinateRelatives.CARET, 0.0f), Coordinate(CoordinateRelatives.CARET, 0.0f), Coordinate(CoordinateRelatives.CARET, 0.0f)), Vec3Parser.parse(reader)) + } + + @Test + fun readNumericTilde() { + val reader = CommandReader("5 ~ ~") + assertEquals(Vec3Coordinate(Coordinate(CoordinateRelatives.NONE, 5.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f)), Vec3Parser.parse(reader)) + } + + @Test + fun readTildeCaret() { + val reader = CommandReader("~4 ^-9 7") + assertEquals(Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 4.0f), Coordinate(CoordinateRelatives.CARET, -9.0f), Coordinate(CoordinateRelatives.NONE, 7.0f)), Vec3Parser.parse(reader)) + } + + @Test + fun readOnlyOne() { + val reader = CommandReader("~4") + assertThrows { Vec3Parser.parse(reader) } + } + + @Test + fun readOnlyTwo() { + val reader = CommandReader("~4 9") + assertThrows { Vec3Parser.parse(reader) } + } +}