package net.minecraft.commands.arguments.coordinates; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import java.util.Arrays; import java.util.Collection; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; public class RotationArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("0 0", "~ ~", "~-5 ~5"); public static final SimpleCommandExceptionType ERROR_NOT_COMPLETE = new SimpleCommandExceptionType(Component.translatable("argument.rotation.incomplete")); public static RotationArgument rotation() { return new RotationArgument(); } public static Coordinates getRotation(CommandContext context, String name) { return context.getArgument(name, Coordinates.class); } public Coordinates parse(StringReader reader) throws CommandSyntaxException { int i = reader.getCursor(); if (!reader.canRead()) { throw ERROR_NOT_COMPLETE.createWithContext(reader); } else { WorldCoordinate worldCoordinate = WorldCoordinate.parseDouble(reader, false); if (reader.canRead() && reader.peek() == ' ') { reader.skip(); WorldCoordinate worldCoordinate2 = WorldCoordinate.parseDouble(reader, false); return new WorldCoordinates(worldCoordinate2, worldCoordinate, new WorldCoordinate(true, 0.0)); } else { reader.setCursor(i); throw ERROR_NOT_COMPLETE.createWithContext(reader); } } } @Override public Collection getExamples() { return EXAMPLES; } }