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 pX, double pY, double pZ)
    • Vec3

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

    • fromRGB24

      public static Vec3 fromRGB24(int pPacked)
    • atLowerCornerOf

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

      public static Vec3 atLowerCornerWithOffset(Vec3i pToCopy, double pOffsetX, double pOffsetY, double pOffsetZ)
    • atCenterOf

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

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

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

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

      public Vec3 normalize()
    • dot

      public double dot(Vec3 pVec)
    • cross

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

      public Vec3 subtract(Vec3 pVec)
    • subtract

      public Vec3 subtract(double pX, double pY, double pZ)
    • add

      public Vec3 add(Vec3 pVec)
    • add

      public Vec3 add(double pX, double pY, double pZ)
      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 pPos, double pDistance)
      Checks if a position is within a certain distance of the coordinates.
    • distanceTo

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

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

      public double distanceToSqr(double pX, double pY, double pZ)
    • closerThan

      public boolean closerThan(Vec3 pPos, double pHorizontalDistance, double pVerticalDistance)
    • scale

      public Vec3 scale(double pFactor)
    • reverse

      public Vec3 reverse()
    • multiply

      public Vec3 multiply(Vec3 pVec)
    • multiply

      public Vec3 multiply(double pFactorX, double pFactorY, double pFactorZ)
    • offsetRandom

      public Vec3 offsetRandom(RandomSource pRandom, float pFactor)
    • length

      public double length()
    • lengthSqr

      public double lengthSqr()
    • horizontalDistance

      public double horizontalDistance()
    • horizontalDistanceSqr

      public double horizontalDistanceSqr()
    • equals

      public boolean equals(Object pOther)
      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 pTo, double pDelta)
      Lerps between this vector and the given vector.
      See Also:
    • xRot

      public Vec3 xRot(float pPitch)
    • yRot

      public Vec3 yRot(float pYaw)
    • zRot

      public Vec3 zRot(float pRoll)
    • directionFromRotation

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

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

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

      public double get(Direction.Axis pAxis)
    • with

      public Vec3 with(Direction.Axis pAxis, double pLength)
    • relative

      public Vec3 relative(Direction pDirection, double pLength)
    • 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()