RotationArgument.java

net.minecraft.commands.arguments.coordinates.RotationArgument

信息

  • 全限定名:net.minecraft.commands.arguments.coordinates.RotationArgument
  • 类型:public class
  • 包:net.minecraft.commands.arguments.coordinates
  • 源码路径:src/main/java/net/minecraft/commands/arguments/coordinates/RotationArgument.java
  • 起始行号:L13
  • 实现:ArgumentType
  • 职责:

    TODO

字段/常量

  • EXAMPLES

    • 类型: Collection<String>
    • 修饰符: private static final
    • 源码定位: L14
    • 说明:

      TODO

  • ERROR_NOT_COMPLETE

    • 类型: SimpleCommandExceptionType
    • 修饰符: public static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static RotationArgument rotation() @ L17

  • 方法名:rotation
  • 源码定位:L17
  • 返回类型:RotationArgument
  • 修饰符:public static

参数:

说明:

TODO

public static Coordinates getRotation(CommandContext<CommandSourceStack> context, String name) @ L21

  • 方法名:getRotation
  • 源码定位:L21
  • 返回类型:Coordinates
  • 修饰符:public static

参数:

  • context: CommandContext
  • name: String

说明:

TODO

public Coordinates parse(StringReader reader) @ L25

  • 方法名:parse
  • 源码定位:L25
  • 返回类型:Coordinates
  • 修饰符:public

参数:

  • reader: StringReader

说明:

TODO

public Collection<String> getExamples() @ L42

  • 方法名:getExamples
  • 源码定位:L42
  • 返回类型:Collection
  • 修饰符:public

参数:

说明:

TODO

代码

public class RotationArgument implements ArgumentType<Coordinates> {
    private static final Collection<String> 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<CommandSourceStack> context, String name) {
        return context.getArgument(name, Coordinates.class);
    }
 
    public Coordinates parse(StringReader reader) throws CommandSyntaxException {
        int start = reader.getCursor();
        if (!reader.canRead()) {
            throw ERROR_NOT_COMPLETE.createWithContext(reader);
        } else {
            WorldCoordinate y = WorldCoordinate.parseDouble(reader, false);
            if (reader.canRead() && reader.peek() == ' ') {
                reader.skip();
                WorldCoordinate x = WorldCoordinate.parseDouble(reader, false);
                return new WorldCoordinates(x, y, new WorldCoordinate(true, 0.0));
            } else {
                reader.setCursor(start);
                throw ERROR_NOT_COMPLETE.createWithContext(reader);
            }
        }
    }
 
    @Override
    public Collection<String> getExamples() {
        return EXAMPLES;
    }
}

引用的其他类

  • CommandSourceStack

    • 引用位置: 参数
  • Coordinates

    • 引用位置: 实现/返回值
  • WorldCoordinate

    • 引用位置: 方法调用/构造调用
    • 关联成员: WorldCoordinate(), WorldCoordinate.parseDouble()
  • WorldCoordinates

    • 引用位置: 构造调用
    • 关联成员: WorldCoordinates()
  • Component

    • 引用位置: 方法调用
    • 关联成员: Component.translatable()