LocalCoordinates.java
net.minecraft.commands.arguments.coordinates.LocalCoordinates
信息
- 全限定名:net.minecraft.commands.arguments.coordinates.LocalCoordinates
- 类型:public record
- 包:net.minecraft.commands.arguments.coordinates
- 源码路径:src/main/java/net/minecraft/commands/arguments/coordinates/LocalCoordinates.java
- 起始行号:L9
- 实现:Coordinates
- 职责:
TODO
字段/常量
PREFIX_LOCAL_COORDINATE- 类型:
char - 修饰符:
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() @ L23
- 方法名:isXRelative
- 源码定位:L23
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isYRelative() @ L28
- 方法名:isYRelative
- 源码定位:L28
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isZRelative() @ L33
- 方法名:isZRelative
- 源码定位:L33
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public static LocalCoordinates parse(StringReader reader) @ L38
- 方法名:parse
- 源码定位:L38
- 返回类型:LocalCoordinates
- 修饰符:public static
参数:
- reader: StringReader
说明:
TODO
private static double readDouble(StringReader reader, int start) @ L58
- 方法名:readDouble
- 源码定位:L58
- 返回类型:double
- 修饰符:private static
参数:
- reader: StringReader
- start: int
说明:
TODO
代码
public record LocalCoordinates(double left, double up, double forwards) implements Coordinates {
public static final char PREFIX_LOCAL_COORDINATE = '^';
@Override
public Vec3 getPosition(CommandSourceStack sender) {
Vec3 source = sender.getAnchor().apply(sender);
return Vec3.applyLocalCoordinatesToRotation(sender.getRotation(), new Vec3(this.left, this.up, this.forwards)).add(source.x, source.y, source.z);
}
@Override
public Vec2 getRotation(CommandSourceStack sender) {
return Vec2.ZERO;
}
@Override
public boolean isXRelative() {
return true;
}
@Override
public boolean isYRelative() {
return true;
}
@Override
public boolean isZRelative() {
return true;
}
public static LocalCoordinates parse(StringReader reader) throws CommandSyntaxException {
int start = reader.getCursor();
double left = readDouble(reader, start);
if (reader.canRead() && reader.peek() == ' ') {
reader.skip();
double up = readDouble(reader, start);
if (reader.canRead() && reader.peek() == ' ') {
reader.skip();
double forwards = readDouble(reader, start);
return new LocalCoordinates(left, up, forwards);
} else {
reader.setCursor(start);
throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
}
} else {
reader.setCursor(start);
throw Vec3Argument.ERROR_NOT_COMPLETE.createWithContext(reader);
}
}
private static double readDouble(StringReader reader, int start) throws CommandSyntaxException {
if (!reader.canRead()) {
throw WorldCoordinate.ERROR_EXPECTED_DOUBLE.createWithContext(reader);
} else if (reader.peek() != '^') {
reader.setCursor(start);
throw Vec3Argument.ERROR_MIXED_TYPE.createWithContext(reader);
} else {
reader.skip();
return reader.canRead() && reader.peek() != ' ' ? reader.readDouble() : 0.0;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用/构造调用/返回值 - 关联成员:
Vec3(), Vec3.applyLocalCoordinatesToRotation()
- 引用位置: