/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.brigadier.ImmutableStringReader * com.mojang.brigadier.Message * com.mojang.brigadier.StringReader * com.mojang.brigadier.arguments.ArgumentType * com.mojang.brigadier.context.CommandContext * com.mojang.brigadier.exceptions.CommandSyntaxException * com.mojang.brigadier.exceptions.SimpleCommandExceptionType */ package net.minecraft.commands.arguments.coordinates; import com.mojang.brigadier.ImmutableStringReader; import com.mojang.brigadier.Message; 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.commands.arguments.coordinates.Coordinates; import net.minecraft.commands.arguments.coordinates.WorldCoordinate; import net.minecraft.commands.arguments.coordinates.WorldCoordinates; 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((Message)Component.translatable("argument.rotation.incomplete")); public static RotationArgument rotation() { return new RotationArgument(); } public static Coordinates getRotation(CommandContext context, String name) { return (Coordinates)context.getArgument(name, Coordinates.class); } public Coordinates parse(StringReader reader) throws CommandSyntaxException { int start = reader.getCursor(); if (!reader.canRead()) { throw ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)reader); } WorldCoordinate y = WorldCoordinate.parseDouble(reader, false); if (!reader.canRead() || reader.peek() != ' ') { reader.setCursor(start); throw ERROR_NOT_COMPLETE.createWithContext((ImmutableStringReader)reader); } reader.skip(); WorldCoordinate x = WorldCoordinate.parseDouble(reader, false); return new WorldCoordinates(x, y, new WorldCoordinate(true, 0.0)); } public Collection getExamples() { return EXAMPLES; } }