Class JOMLConversion

java.lang.Object
dev.ryanhcode.sable.companion.math.JOMLConversion

public final class JOMLConversion extends Object
Utility for converting between Mojang and JOML math types.
Since:
1.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.joml.Vector3dc
    A non-changing always (0.5, 0.5, 0.5) vector.
    static final org.joml.Vector3dc
    A non-changing always (1.0, 1.0, 1.0) vector.
    static final org.joml.Quaterniondc
    A non-changing always zero vector.
    static final org.joml.Vector3dc
    A non-changing always zero vector.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.joml.Vector3d
    atBottomCenterOf(net.minecraft.core.Vec3i toCopy)
    Copies the coordinates of a Mojang Vec3i and centers them horizontally (x and z).
    static org.joml.Vector3d
    atBottomCenterOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
    Copies the coordinates of a Mojang Vec3i and centers them horizontally (x and z).
    static org.joml.Vector3d
    atCenterOf(net.minecraft.core.Vec3i toCopy)
    Copies the coordinates of a Mojang Vec3i and centers them.
    static org.joml.Vector3d
    atCenterOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
    Copies the coordinates of a Mojang Vec3i and centers them.
    static org.joml.Vector3d
    atLowerCornerOf(net.minecraft.core.Vec3i toCopy)
    Copies the coordinates of a Mojang Vec3i exactly.
    static org.joml.Vector3d
    atLowerCornerOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
    Copies the coordinates of a Mojang Vec3i exactly.
    static org.joml.Vector3d
    atLowerCornerWithOffset(net.minecraft.core.Vec3i toCopy, double offsetX, double offsetY, double offsetZ)
    Copies the coordinates of a Mojang Vec3i exactly with offset.
    static org.joml.Vector3d
    atLowerCornerWithOffset(net.minecraft.core.Vec3i toCopy, double offsetX, double offsetY, double offsetZ, org.joml.Vector3d dest)
    Copies the coordinates of a Mojang Vec3i exactly with offset.
    static org.joml.Vector3d
    getAABBCenter(net.minecraft.world.phys.AABB aabb)
    Calculates the center of the specified Mojang AABB.
    static org.joml.Vector3d
    getAABBCenter(net.minecraft.world.phys.AABB aabb, org.joml.Vector3d dest)
    Calculates the center of the specified Mojang AABB.
    static org.joml.Vector3d
    toJOML(net.minecraft.core.Position vec3)
    Converts a Mojang Vec3 to a JOML Vector3d.
    static org.joml.Vector3d
    toJOML(net.minecraft.core.Position vec3, org.joml.Vector3d dest)
    Converts a Mojang Vec3 to a JOML Vector3d.
    static org.joml.Vector3i
    toJOML(net.minecraft.core.Vec3i vec3)
    Converts a Mojang Vec3i to a JOML Vector3i.
    static org.joml.Vector3i
    toJOML(net.minecraft.core.Vec3i vec3, org.joml.Vector3i dest)
    Converts a Mojang Vec3I to a JOML Vector3i.
    static org.joml.Vector2f
    toJOML(net.minecraft.world.phys.Vec2 vec2)
    Converts a Mojang Vec2 to a JOML Vector2f.
    static org.joml.Vector2f
    toJOML(net.minecraft.world.phys.Vec2 vec2, org.joml.Vector2f dest)
    Converts a Mojang Vec2 to a JOML Vector2f.
    static net.minecraft.world.phys.Vec2
    toMojang(org.joml.Vector2fc vec2f)
    Converts a JOML Vector2f to a Mojang Vec2.
    static net.minecraft.world.phys.Vec3
    toMojang(org.joml.Vector3dc vec3d)
    Converts a JOML Vector3d to a Mojang Vec3.
    static net.minecraft.core.Vec3i
    toMojang(org.joml.Vector3ic vec3i)
    Converts a JOML Vector3i to a Mojang Vec3i.
    static org.joml.Vector3d
    upFromBottomCenterOf(net.minecraft.core.Vec3i toCopy, double verticalOffset)
    Copies the coordinates of a Mojang Vec3i and centers them horizontally and applies a vertical offset.
    static org.joml.Vector3d
    upFromBottomCenterOf(net.minecraft.core.Vec3i toCopy, double verticalOffset, org.joml.Vector3d dest)
    Copies the coordinates of a Mojang Vec3i and centers them horizontally and applies a vertical offset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ZERO

      public static final org.joml.Vector3dc ZERO
      A non-changing always zero vector.
    • ONE

      public static final org.joml.Vector3dc ONE
      A non-changing always (1.0, 1.0, 1.0) vector.
    • HALF

      public static final org.joml.Vector3dc HALF
      A non-changing always (0.5, 0.5, 0.5) vector.
    • QUAT_IDENTITY

      public static final org.joml.Quaterniondc QUAT_IDENTITY
      A non-changing always zero vector.
  • Constructor Details

    • JOMLConversion

      public JOMLConversion()
  • Method Details

    • toJOML

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3d toJOML(net.minecraft.core.Position vec3, org.joml.Vector3d dest)
      Converts a Mojang Vec3 to a JOML Vector3d.
      Parameters:
      vec3 - The Mojang Vec3
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • toJOML

      @Contract(value="_->new", pure=true) public static org.joml.Vector3d toJOML(net.minecraft.core.Position vec3)
      Converts a Mojang Vec3 to a JOML Vector3d.
      Parameters:
      vec3 - the Mojang Vec3
      Returns:
      A new JOML Vector3d
    • toJOML

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector2f toJOML(net.minecraft.world.phys.Vec2 vec2, org.joml.Vector2f dest)
      Converts a Mojang Vec2 to a JOML Vector2f.
      Parameters:
      vec2 - The Mojang Vec2
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector2f
    • toJOML

      @Contract(value="_->new", pure=true) public static org.joml.Vector2f toJOML(net.minecraft.world.phys.Vec2 vec2)
      Converts a Mojang Vec2 to a JOML Vector2f.
      Parameters:
      vec2 - The Mojang Vec2
      Returns:
      A new JOML Vector2f
    • toJOML

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3i toJOML(net.minecraft.core.Vec3i vec3, org.joml.Vector3i dest)
      Converts a Mojang Vec3I to a JOML Vector3i.
      Parameters:
      vec3 - the Mojang Vec3i
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • toJOML

      @Contract(value="_->new", pure=true) public static org.joml.Vector3i toJOML(net.minecraft.core.Vec3i vec3)
      Converts a Mojang Vec3i to a JOML Vector3i.
      Parameters:
      vec3 - the Mojang Vec3i
      Returns:
      A new JOML Vector3d
    • atLowerCornerOf

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3d atLowerCornerOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
      Copies the coordinates of a Mojang Vec3i exactly.
      Parameters:
      toCopy - The Mojang Vec3i
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • atLowerCornerOf

      @Contract(value="_->new", pure=true) public static org.joml.Vector3d atLowerCornerOf(net.minecraft.core.Vec3i toCopy)
      Copies the coordinates of a Mojang Vec3i exactly.
      Parameters:
      toCopy - The Mojang Vec3i
      Returns:
      A new JOML Vector3d
    • atLowerCornerWithOffset

      @Contract(value="_,_,_,_,_->param5", mutates="param5") public static org.joml.Vector3d atLowerCornerWithOffset(net.minecraft.core.Vec3i toCopy, double offsetX, double offsetY, double offsetZ, org.joml.Vector3d dest)
      Copies the coordinates of a Mojang Vec3i exactly with offset.
      Parameters:
      toCopy - The Mojang Vec3i
      offsetX - Offset in the x to add
      offsetY - Offset in the y to add
      offsetZ - Offset in the z to add
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • atLowerCornerWithOffset

      @Contract(value="_,_,_,_->new", pure=true) public static org.joml.Vector3d atLowerCornerWithOffset(net.minecraft.core.Vec3i toCopy, double offsetX, double offsetY, double offsetZ)
      Copies the coordinates of a Mojang Vec3i exactly with offset.
      Parameters:
      toCopy - The Mojang Vec3i
      offsetX - Offset in the x to add
      offsetY - Offset in the y to add
      offsetZ - Offset in the z to add
      Returns:
      A new JOML Vector3d
    • atCenterOf

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3d atCenterOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
      Copies the coordinates of a Mojang Vec3i and centers them.
      Parameters:
      toCopy - The Mojang Vec3i
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • atCenterOf

      @Contract(value="_->new", pure=true) public static org.joml.Vector3d atCenterOf(net.minecraft.core.Vec3i toCopy)
      Copies the coordinates of a Mojang Vec3i and centers them.
      Parameters:
      toCopy - The Mojang Vec3i
      Returns:
      A new JOML Vector3d
    • atBottomCenterOf

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3d atBottomCenterOf(net.minecraft.core.Vec3i toCopy, org.joml.Vector3d dest)
      Copies the coordinates of a Mojang Vec3i and centers them horizontally (x and z).
      Parameters:
      toCopy - The Mojang Vec3i
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • atBottomCenterOf

      @Contract(value="_->new", pure=true) public static org.joml.Vector3d atBottomCenterOf(net.minecraft.core.Vec3i toCopy)
      Copies the coordinates of a Mojang Vec3i and centers them horizontally (x and z).
      Parameters:
      toCopy - The Mojang Vec3i
      Returns:
      A new JOML Vector3d
    • upFromBottomCenterOf

      @Contract(value="_,_,_->param3", mutates="param3") public static org.joml.Vector3d upFromBottomCenterOf(net.minecraft.core.Vec3i toCopy, double verticalOffset, org.joml.Vector3d dest)
      Copies the coordinates of a Mojang Vec3i and centers them horizontally and applies a vertical offset.
      Parameters:
      toCopy - The Mojang Vec3i
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d
    • upFromBottomCenterOf

      @Contract(value="_,_->new", pure=true) public static org.joml.Vector3d upFromBottomCenterOf(net.minecraft.core.Vec3i toCopy, double verticalOffset)
      Copies the coordinates of a Mojang Vec3i and centers them horizontally and applies a vertical offset.
      Parameters:
      toCopy - The Mojang Vec3i
      Returns:
      A new JOML Vector3d
    • toMojang

      @Contract(value="_->new", pure=true) public static net.minecraft.world.phys.Vec3 toMojang(org.joml.Vector3dc vec3d)
      Converts a JOML Vector3d to a Mojang Vec3.
      Parameters:
      vec3d - the JOML Vector3d
      Returns:
      the Mojang Vec3
    • toMojang

      @Contract(value="_->new", pure=true) public static net.minecraft.world.phys.Vec2 toMojang(org.joml.Vector2fc vec2f)
      Converts a JOML Vector2f to a Mojang Vec2.
      Parameters:
      vec2f - the JOML Vector2f
      Returns:
      the Mojang Vec2
    • toMojang

      @Contract(value="_->new", pure=true) public static net.minecraft.core.Vec3i toMojang(org.joml.Vector3ic vec3i)
      Converts a JOML Vector3i to a Mojang Vec3i.
      Parameters:
      vec3i - the JOML Vector3d
      Returns:
      the Mojang Vec3
    • getAABBCenter

      @Contract(value="_->new", pure=true) public static org.joml.Vector3d getAABBCenter(net.minecraft.world.phys.AABB aabb)
      Calculates the center of the specified Mojang AABB.
      Parameters:
      aabb - The Mojang AABB
      Returns:
      A new JOML Vector3d
    • getAABBCenter

      @Contract(value="_,_->param2", mutates="param2") public static org.joml.Vector3d getAABBCenter(net.minecraft.world.phys.AABB aabb, org.joml.Vector3d dest)
      Calculates the center of the specified Mojang AABB.
      Parameters:
      aabb - The Mojang AABB
      dest - The JOML vector to store into
      Returns:
      The passed in JOML Vector3d