Class Vec3

java.lang.Object
net.minecraft.world.phys.Vec3
All Implemented Interfaces:
Position

public class Vec3 extends Object implements Position
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<Vec3> CODEC
    • ZERO

      public static final Vec3 ZERO
    • x

      public final double x
    • y

      public final double y
    • z

      public final double z
  • Constructor Details

    • Vec3

      public Vec3(double x, double y, double z)
    • Vec3

      public Vec3(org.joml.Vector3f vector)
  • Method Details

    • fromRGB24

      public static Vec3 fromRGB24(int packed)
    • atLowerCornerOf

      public static Vec3 atLowerCornerOf(Vec3i toCopy)
      Copies the coordinates of an int vector exactly.
    • atLowerCornerWithOffset

      public static Vec3 atLowerCornerWithOffset(Vec3i toCopy, double offsetX, double offsetY, double offsetZ)
    • atCenterOf

      public static Vec3 atCenterOf(Vec3i toCopy)
      Copies the coordinates of an Int vector and centers them.
    • atBottomCenterOf

      public static Vec3 atBottomCenterOf(Vec3i toCopy)
      Copies the coordinates of an int vector and centers them horizontally (x and z)
    • upFromBottomCenterOf

      public static Vec3 upFromBottomCenterOf(Vec3i toCopy, double verticalOffset)
      Copies the coordinates of an int vector and centers them horizontally and applies a vertical offset.
    • vectorTo

      public Vec3 vectorTo(Vec3 vec)
      Returns a new vector with the result of the specified vector minus this.
    • normalize

      public Vec3 normalize()
    • dot

      public double dot(Vec3 vec)
    • cross

      public Vec3 cross(Vec3 vec)
      Returns a new vector with the result of this vector x the specified vector.
    • subtract

      public Vec3 subtract(Vec3 vec)
    • subtract

      public Vec3 subtract(double x, double y, double z)
    • add

      public Vec3 add(Vec3 vec)
    • add

      public Vec3 add(double x, double y, double z)
      Adds the specified x,y,z vector components to this vector and returns the resulting vector. Does not change this vector.
    • closerThan

      public boolean closerThan(Position pos, double distance)
      Checks if a position is within a certain distance of the coordinates.
    • distanceTo

      public double distanceTo(Vec3 vec)
      Euclidean distance between this and the specified vector, returned as double.
    • distanceToSqr

      public double distanceToSqr(Vec3 vec)
      The square of the Euclidean distance between this and the specified vector.
    • distanceToSqr

      public double distanceToSqr(double x, double y, double z)
    • closerThan

      public boolean closerThan(Vec3 pos, double horizontalDistance, double verticalDistance)
    • scale

      public Vec3 scale(double factor)
    • reverse

      public Vec3 reverse()
    • multiply

      public Vec3 multiply(Vec3 vec)
    • multiply

      public Vec3 multiply(double factorX, double factorY, double factorZ)
    • offsetRandom

      public Vec3 offsetRandom(RandomSource random, float factor)
    • length

      public double length()
    • lengthSqr

      public double lengthSqr()
    • horizontalDistance

      public double horizontalDistance()
    • horizontalDistanceSqr

      public double horizontalDistanceSqr()
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lerp

      public Vec3 lerp(Vec3 to, double delta)
      Lerps between this vector and the given vector.
      See Also:
    • xRot

      public Vec3 xRot(float pitch)
    • yRot

      public Vec3 yRot(float yaw)
    • zRot

      public Vec3 zRot(float roll)
    • directionFromRotation

      public static Vec3 directionFromRotation(Vec2 vec)
      Returns a Vec3 from the given pitch and yaw degrees as Vec2.
    • directionFromRotation

      public static Vec3 directionFromRotation(float pitch, float yaw)
      Returns a Vec3 from the given pitch and yaw degrees.
    • align

      public Vec3 align(EnumSet<Direction.Axis> axes)
    • get

      public double get(Direction.Axis axis)
    • with

      public Vec3 with(Direction.Axis axis, double length)
    • relative

      public Vec3 relative(Direction direction, double length)
    • x

      public final double x()
      Specified by:
      x in interface Position
    • y

      public final double y()
      Specified by:
      y in interface Position
    • z

      public final double z()
      Specified by:
      z in interface Position
    • toVector3f

      public org.joml.Vector3f toVector3f()