WorldCoordinates.java

net.minecraft.commands.arguments.coordinates.WorldCoordinates

信息

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

    TODO

字段/常量

  • ZERO_ROTATION
    • 类型: WorldCoordinates
    • 修饰符: public static final
    • 源码定位: L10
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public Vec3 getPosition(CommandSourceStack sender) @ L12

  • 方法名:getPosition
  • 源码定位:L12
  • 返回类型:Vec3
  • 修饰符:public

参数:

  • sender: CommandSourceStack

说明:

TODO

public Vec2 getRotation(CommandSourceStack sender) @ L18

  • 方法名:getRotation
  • 源码定位:L18
  • 返回类型:Vec2
  • 修饰符:public

参数:

  • sender: CommandSourceStack

说明:

TODO

public boolean isXRelative() @ L24

  • 方法名:isXRelative
  • 源码定位:L24
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean isYRelative() @ L29

  • 方法名:isYRelative
  • 源码定位:L29
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean isZRelative() @ L34

  • 方法名:isZRelative
  • 源码定位:L34
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public static WorldCoordinates parseInt(StringReader reader) @ L39

  • 方法名:parseInt
  • 源码定位:L39
  • 返回类型:WorldCoordinates
  • 修饰符:public static

参数:

  • reader: StringReader

说明:

TODO

public static WorldCoordinates parseDouble(StringReader reader, boolean centerCorrect) @ L59

  • 方法名:parseDouble
  • 源码定位:L59
  • 返回类型:WorldCoordinates
  • 修饰符:public static

参数:

  • reader: StringReader
  • centerCorrect: boolean

说明:

TODO

public static WorldCoordinates absolute(double x, double y, double z) @ L79

  • 方法名:absolute
  • 源码定位:L79
  • 返回类型:WorldCoordinates
  • 修饰符:public static

参数:

  • x: double
  • y: double
  • z: double

说明:

TODO

public static WorldCoordinates absolute(Vec2 rotation) @ L83

  • 方法名:absolute
  • 源码定位:L83
  • 返回类型:WorldCoordinates
  • 修饰符:public static

参数:

  • rotation: Vec2

说明:

TODO

代码

public record WorldCoordinates(WorldCoordinate x, WorldCoordinate y, WorldCoordinate z) implements Coordinates {
    public static final WorldCoordinates ZERO_ROTATION = absolute(new Vec2(0.0F, 0.0F));
 
    @Override
    public Vec3 getPosition(CommandSourceStack sender) {
        Vec3 pos = sender.getPosition();
        return new Vec3(this.x.get(pos.x), this.y.get(pos.y), this.z.get(pos.z));
    }
 
    @Override
    public Vec2 getRotation(CommandSourceStack sender) {
        Vec2 rot = sender.getRotation();
        return new Vec2((float)this.x.get(rot.x), (float)this.y.get(rot.y));
    }
 
    @Override
    public boolean isXRelative() {
        return this.x.isRelative();
    }
 
    @Override
    public boolean isYRelative() {
        return this.y.isRelative();
    }
 
    @Override
    public boolean isZRelative() {
        return this.z.isRelative();
    }
 
    public static WorldCoordinates parseInt(StringReader reader) throws CommandSyntaxException {
        int start = reader.getCursor();
        WorldCoordinate x = WorldCoordinate.parseInt(reader);
        if (reader.canRead() && reader.peek() == ' ') {
            reader.skip();
            WorldCoordinate y = WorldCoordinate.parseInt(reader);
            if (reader.canRead() && reader.peek() == ' ') {
                reader.skip();
                WorldCoordinate z = WorldCoordinate.parseInt(reader);
                return new WorldCoordinates(x, y, z);
            } else {
                reader.setCursor(start);
                throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
            }
        } else {
            reader.setCursor(start);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
        }
    }
 
    public static WorldCoordinates parseDouble(StringReader reader, boolean centerCorrect) throws CommandSyntaxException {
        int start = reader.getCursor();
        WorldCoordinate x = WorldCoordinate.parseDouble(reader, centerCorrect);
        if (reader.canRead() && reader.peek() == ' ') {
            reader.skip();
            WorldCoordinate y = WorldCoordinate.parseDouble(reader, false);
            if (reader.canRead() && reader.peek() == ' ') {
                reader.skip();
                WorldCoordinate z = WorldCoordinate.parseDouble(reader, centerCorrect);
                return new WorldCoordinates(x, y, z);
            } else {
                reader.setCursor(start);
                throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
            }
        } else {
            reader.setCursor(start);
            throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
        }
    }
 
    public static WorldCoordinates absolute(double x, double y, double z) {
        return new WorldCoordinates(new WorldCoordinate(false, x), new WorldCoordinate(false, y), new WorldCoordinate(false, z));
    }
 
    public static WorldCoordinates absolute(Vec2 rotation) {
        return new WorldCoordinates(new WorldCoordinate(false, rotation.x), new WorldCoordinate(false, rotation.y), new WorldCoordinate(true, 0.0));
    }
}

引用的其他类

  • CommandSourceStack

    • 引用位置: 参数
  • Coordinates

    • 引用位置: 实现
  • WorldCoordinate

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

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: Vec2()
  • Vec3

    • 引用位置: 构造调用/返回值
    • 关联成员: Vec3()