Something went wrong. Try again.
The Minecraft: Java Edition decompiled source code.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193package com.mojang.math;
import java.util.Arrays;import java.util.Map;import java.util.stream.Collectors;import net.minecraft.core.Direction;import net.minecraft.core.FrontAndTop;import net.minecraft.util.StringRepresentable;import net.minecraft.util.Util;import org.joml.Matrix3f;import org.joml.Matrix3fc;import org.joml.Vector3i;import org.jspecify.annotations.Nullable;
public enum OctahedralGroup implements StringRepresentable { IDENTITY("identity", SymmetricGroup3.P123, false, false, false), ROT_180_FACE_XY("rot_180_face_xy", SymmetricGroup3.P123, true, true, false), ROT_180_FACE_XZ("rot_180_face_xz", SymmetricGroup3.P123, true, false, true), ROT_180_FACE_YZ("rot_180_face_yz", SymmetricGroup3.P123, false, true, true), ROT_120_NNN("rot_120_nnn", SymmetricGroup3.P231, false, false, false), ROT_120_NNP("rot_120_nnp", SymmetricGroup3.P312, true, false, true), ROT_120_NPN("rot_120_npn", SymmetricGroup3.P312, false, true, true), ROT_120_NPP("rot_120_npp", SymmetricGroup3.P231, true, false, true), ROT_120_PNN("rot_120_pnn", SymmetricGroup3.P312, true, true, false), ROT_120_PNP("rot_120_pnp", SymmetricGroup3.P231, true, true, false), ROT_120_PPN("rot_120_ppn", SymmetricGroup3.P231, false, true, true), ROT_120_PPP("rot_120_ppp", SymmetricGroup3.P312, false, false, false), ROT_180_EDGE_XY_NEG("rot_180_edge_xy_neg", SymmetricGroup3.P213, true, true, true), ROT_180_EDGE_XY_POS("rot_180_edge_xy_pos", SymmetricGroup3.P213, false, false, true), ROT_180_EDGE_XZ_NEG("rot_180_edge_xz_neg", SymmetricGroup3.P321, true, true, true), ROT_180_EDGE_XZ_POS("rot_180_edge_xz_pos", SymmetricGroup3.P321, false, true, false), ROT_180_EDGE_YZ_NEG("rot_180_edge_yz_neg", SymmetricGroup3.P132, true, true, true), ROT_180_EDGE_YZ_POS("rot_180_edge_yz_pos", SymmetricGroup3.P132, true, false, false), ROT_90_X_NEG("rot_90_x_neg", SymmetricGroup3.P132, false, false, true), ROT_90_X_POS("rot_90_x_pos", SymmetricGroup3.P132, false, true, false), ROT_90_Y_NEG("rot_90_y_neg", SymmetricGroup3.P321, true, false, false), ROT_90_Y_POS("rot_90_y_pos", SymmetricGroup3.P321, false, false, true), ROT_90_Z_NEG("rot_90_z_neg", SymmetricGroup3.P213, false, true, false), ROT_90_Z_POS("rot_90_z_pos", SymmetricGroup3.P213, true, false, false), INVERSION("inversion", SymmetricGroup3.P123, true, true, true), INVERT_X("invert_x", SymmetricGroup3.P123, true, false, false), INVERT_Y("invert_y", SymmetricGroup3.P123, false, true, false), INVERT_Z("invert_z", SymmetricGroup3.P123, false, false, true), ROT_60_REF_NNN("rot_60_ref_nnn", SymmetricGroup3.P312, true, true, true), ROT_60_REF_NNP("rot_60_ref_nnp", SymmetricGroup3.P231, true, false, false), ROT_60_REF_NPN("rot_60_ref_npn", SymmetricGroup3.P231, false, false, true), ROT_60_REF_NPP("rot_60_ref_npp", SymmetricGroup3.P312, false, false, true), ROT_60_REF_PNN("rot_60_ref_pnn", SymmetricGroup3.P231, false, true, false), ROT_60_REF_PNP("rot_60_ref_pnp", SymmetricGroup3.P312, true, false, false), ROT_60_REF_PPN("rot_60_ref_ppn", SymmetricGroup3.P312, false, true, false), ROT_60_REF_PPP("rot_60_ref_ppp", SymmetricGroup3.P231, true, true, true), SWAP_XY("swap_xy", SymmetricGroup3.P213, false, false, false), SWAP_YZ("swap_yz", SymmetricGroup3.P132, false, false, false), SWAP_XZ("swap_xz", SymmetricGroup3.P321, false, false, false), SWAP_NEG_XY("swap_neg_xy", SymmetricGroup3.P213, true, true, false), SWAP_NEG_YZ("swap_neg_yz", SymmetricGroup3.P132, false, true, true), SWAP_NEG_XZ("swap_neg_xz", SymmetricGroup3.P321, true, false, true), ROT_90_REF_X_NEG("rot_90_ref_x_neg", SymmetricGroup3.P132, true, false, true), ROT_90_REF_X_POS("rot_90_ref_x_pos", SymmetricGroup3.P132, true, true, false), ROT_90_REF_Y_NEG("rot_90_ref_y_neg", SymmetricGroup3.P321, true, true, false), ROT_90_REF_Y_POS("rot_90_ref_y_pos", SymmetricGroup3.P321, false, true, true), ROT_90_REF_Z_NEG("rot_90_ref_z_neg", SymmetricGroup3.P213, false, true, true), ROT_90_REF_Z_POS("rot_90_ref_z_pos", SymmetricGroup3.P213, true, false, true);
private final Matrix3fc transformation; private final String name; @Nullable private Map<Direction, Direction> rotatedDirections; private final boolean invertX; private final boolean invertY; private final boolean invertZ; private final SymmetricGroup3 permutation; private static final OctahedralGroup[][] CAYLEY_TABLE = Util.make(() -> { OctahedralGroup[] octahedralGroups = values(); OctahedralGroup[][] octahedralGroups1 = new OctahedralGroup[octahedralGroups.length][octahedralGroups.length]; Map map = Arrays.stream(octahedralGroups).collect(Collectors.toMap(OctahedralGroup::trace, octahedralGroup2 -> (OctahedralGroup)octahedralGroup2));
for (OctahedralGroup octahedralGroup : octahedralGroups) { for (OctahedralGroup octahedralGroup1 : octahedralGroups) { SymmetricGroup3 symmetricGroup3 = octahedralGroup1.permutation.compose(octahedralGroup.permutation); boolean bl = octahedralGroup.inverts(Direction.Axis.X) ^ octahedralGroup1.inverts(octahedralGroup.permutation.permuteAxis(Direction.Axis.X)); boolean bl1 = octahedralGroup.inverts(Direction.Axis.Y) ^ octahedralGroup1.inverts(octahedralGroup.permutation.permuteAxis(Direction.Axis.Y)); boolean bl2 = octahedralGroup.inverts(Direction.Axis.Z) ^ octahedralGroup1.inverts(octahedralGroup.permutation.permuteAxis(Direction.Axis.Z)); octahedralGroups1[octahedralGroup.ordinal()][octahedralGroup1.ordinal()] = (OctahedralGroup)map.get(trace(bl, bl1, bl2, symmetricGroup3)); } }
return octahedralGroups1; }); private static final OctahedralGroup[] INVERSE_TABLE = Arrays.stream(values()) .map(octahedralGroup -> Arrays.stream(values()).filter(octahedralGroup2 -> octahedralGroup.compose(octahedralGroup2) == IDENTITY).findAny().get()) .toArray(OctahedralGroup[]::new); private static final OctahedralGroup[][] XY_TABLE = Util.make(new OctahedralGroup[Quadrant.values().length][Quadrant.values().length], octahedralGroups -> { for (Quadrant quadrant : Quadrant.values()) { for (Quadrant quadrant1 : Quadrant.values()) { OctahedralGroup octahedralGroup = IDENTITY;
for (int i = 0; i < quadrant1.shift; i++) { octahedralGroup = octahedralGroup.compose(ROT_90_Y_NEG); }
for (int j = 0; j < quadrant.shift; j++) { octahedralGroup = octahedralGroup.compose(ROT_90_X_NEG); }
octahedralGroups[quadrant.ordinal()][quadrant1.ordinal()] = octahedralGroup; } } });
private OctahedralGroup(final String string1, final SymmetricGroup3 symmetricGroup3, final boolean bl, final boolean bl1, final boolean bl2) { this.name = string1; this.invertX = bl; this.invertY = bl1; this.invertZ = bl2; this.permutation = symmetricGroup3; this.transformation = new Matrix3f().scaling(bl ? -1.0F : 1.0F, bl1 ? -1.0F : 1.0F, bl2 ? -1.0F : 1.0F).mul(symmetricGroup3.transformation()); }
private static int trace(boolean bl, boolean bl1, boolean bl2, SymmetricGroup3 symmetricGroup3) { int i = (bl2 ? 4 : 0) + (bl1 ? 2 : 0) + (bl ? 1 : 0); return symmetricGroup3.ordinal() << 3 | i; }
private int trace() { return trace(this.invertX, this.invertY, this.invertZ, this.permutation); }
public OctahedralGroup compose(OctahedralGroup octahedralGroup1) { return CAYLEY_TABLE[this.ordinal()][octahedralGroup1.ordinal()]; }
public OctahedralGroup inverse() { return INVERSE_TABLE[this.ordinal()]; }
public Matrix3fc transformation() { return this.transformation; }
@Override public String toString() { return this.name; }
@Override public String getSerializedName() { return this.name; }
public Direction rotate(Direction direction) { if (this.rotatedDirections == null) { this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { Direction.Axis axis = direction1.getAxis(); Direction.AxisDirection axisDirection = direction1.getAxisDirection(); Direction.Axis axis1 = this.permutation.inverse().permuteAxis(axis); Direction.AxisDirection axisDirection1 = this.inverts(axis1) ? axisDirection.opposite() : axisDirection; return Direction.fromAxisAndDirection(axis1, axisDirection1); }); }
return this.rotatedDirections.get(direction); }
public Vector3i rotate(Vector3i vector3i) { this.permutation.permuteVector(vector3i); vector3i.x = vector3i.x * (this.invertX ? -1 : 1); vector3i.y = vector3i.y * (this.invertY ? -1 : 1); vector3i.z = vector3i.z * (this.invertZ ? -1 : 1); return vector3i; }
public boolean inverts(Direction.Axis axis) { return switch (axis) { case X -> this.invertX; case Y -> this.invertY; case Z -> this.invertZ; }; }
public SymmetricGroup3 permutation() { return this.permutation; }
public FrontAndTop rotate(FrontAndTop frontAndTop) { return FrontAndTop.fromFrontAndTop(this.rotate(frontAndTop.front()), this.rotate(frontAndTop.top())); }
public static OctahedralGroup fromXYAngles(Quadrant quadrant, Quadrant quadrant1) { return XY_TABLE[quadrant.ordinal()][quadrant1.ordinal()]; }}