Quadrant.java
com.mojang.math.Quadrant
信息
- 全限定名:com.mojang.math.Quadrant
- 类型:public enum
- 包:com.mojang.math
- 源码路径:src/main/java/com/mojang/math/Quadrant.java
- 起始行号:L8
- 职责:
TODO
字段/常量
-
IDENTITY, BLOCK_ROT_Z_90, BLOCK_ROT_Z_180, BLOCK_ROT_Z_270- 类型:
R0(,OctahedralGroup.IDENTITY,OctahedralGroup.IDENTITY,OctahedralGroup. - 修饰符:
package-private - 源码定位:
L9 - 说明:
TODO
- 类型:
-
CODEC- 类型:
Codec<Quadrant> - 修饰符:
public static final default - 源码定位:
L14 - 说明:
TODO
- 类型:
-
shift- 类型:
int - 修饰符:
public final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
rotationX- 类型:
OctahedralGroup - 修饰符:
public final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
rotationY- 类型:
OctahedralGroup - 修饰符:
public final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
rotationZ- 类型:
OctahedralGroup - 修饰符:
public final - 源码定位:
L33 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private Quadrant(int shift, OctahedralGroup rotationX, OctahedralGroup rotationY, OctahedralGroup rotationZ) @ L35
- 构造器名:Quadrant
- 源码定位:L35
- 修饰符:private
参数:
- shift: int
- rotationX: OctahedralGroup
- rotationY: OctahedralGroup
- rotationZ: OctahedralGroup
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static Quadrant parseJson(int degrees) @ L42
- 方法名:parseJson
- 源码定位:L42
- 返回类型:Quadrant
- 修饰符:public static
参数:
- degrees: int
说明:
TODO
public static OctahedralGroup fromXYAngles(Quadrant xRotation, Quadrant yRotation) @ L53
- 方法名:fromXYAngles
- 源码定位:L53
- 返回类型:OctahedralGroup
- 修饰符:public static
参数:
- xRotation: Quadrant
- yRotation: Quadrant
说明:
TODO
public static OctahedralGroup fromXYZAngles(Quadrant xRotation, Quadrant yRotation, Quadrant zRotation) @ L57
- 方法名:fromXYZAngles
- 源码定位:L57
- 返回类型:OctahedralGroup
- 修饰符:public static
参数:
- xRotation: Quadrant
- yRotation: Quadrant
- zRotation: Quadrant
说明:
TODO
public int rotateVertexIndex(int index) @ L61
- 方法名:rotateVertexIndex
- 源码定位:L61
- 返回类型:int
- 修饰符:public
参数:
- index: int
说明:
TODO
代码
public enum Quadrant {
R0(0, OctahedralGroup.IDENTITY, OctahedralGroup.IDENTITY, OctahedralGroup.IDENTITY),
R90(1, OctahedralGroup.BLOCK_ROT_X_90, OctahedralGroup.BLOCK_ROT_Y_90, OctahedralGroup.BLOCK_ROT_Z_90),
R180(2, OctahedralGroup.BLOCK_ROT_X_180, OctahedralGroup.BLOCK_ROT_Y_180, OctahedralGroup.BLOCK_ROT_Z_180),
R270(3, OctahedralGroup.BLOCK_ROT_X_270, OctahedralGroup.BLOCK_ROT_Y_270, OctahedralGroup.BLOCK_ROT_Z_270);
public static final Codec<Quadrant> CODEC = Codec.INT.comapFlatMap(degrees -> {
return switch (Mth.positiveModulo(degrees, 360)) {
case 0 -> DataResult.success(R0);
case 90 -> DataResult.success(R90);
case 180 -> DataResult.success(R180);
case 270 -> DataResult.success(R270);
default -> DataResult.error(() -> "Invalid rotation " + degrees + " found, only 0/90/180/270 allowed");
};
}, quadrant -> {
return switch (quadrant) {
case R0 -> 0;
case R90 -> 90;
case R180 -> 180;
case R270 -> 270;
};
});
public final int shift;
public final OctahedralGroup rotationX;
public final OctahedralGroup rotationY;
public final OctahedralGroup rotationZ;
private Quadrant(int shift, OctahedralGroup rotationX, OctahedralGroup rotationY, OctahedralGroup rotationZ) {
this.shift = shift;
this.rotationX = rotationX;
this.rotationY = rotationY;
this.rotationZ = rotationZ;
}
@Deprecated
public static Quadrant parseJson(int degrees) {
return switch (Mth.positiveModulo(degrees, 360)) {
case 0 -> R0;
case 90 -> R90;
case 180 -> R180;
case 270 -> R270;
default -> throw new JsonParseException("Invalid rotation " + degrees + " found, only 0/90/180/270 allowed");
};
}
public static OctahedralGroup fromXYAngles(Quadrant xRotation, Quadrant yRotation) {
return yRotation.rotationY.compose(xRotation.rotationX);
}
public static OctahedralGroup fromXYZAngles(Quadrant xRotation, Quadrant yRotation, Quadrant zRotation) {
return zRotation.rotationZ.compose(yRotation.rotationY.compose(xRotation.rotationX));
}
public int rotateVertexIndex(int index) {
return (index + this.shift) % 4;
}
}引用的其他类
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.positiveModulo()
- 引用位置: