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
    • STREAM_CODEC

      public static final StreamCodec<io.netty.buffer.ByteBuf, Vec3> STREAM_CODEC
    • LP_STREAM_CODEC

      public static final StreamCodec<io.netty.buffer.ByteBuf, Vec3> LP_STREAM_CODEC
    • ZERO

      public static final Vec3 ZERO
    • X_AXIS

      public static final Vec3 X_AXIS
    • Y_AXIS

      public static final Vec3 Y_AXIS
    • Z_AXIS

      public static final Vec3 Z_AXIS
    • 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(Vector3fc vec)
    • Vec3

      public Vec3(Vec3i vec)
  • Method Details

    • atLowerCornerOf

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

      public static Vec3 atLowerCornerWithOffset(Vec3i pos, double x, double y, double z)
    • atCenterOf

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

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

      public static Vec3 upFromBottomCenterOf(Vec3i pos, double yOffset)
      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 value)
    • subtract

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

      public Vec3 add(double value)
    • 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 vec, double distanceXZ, double distanceY)
    • scale

      public Vec3 scale(double scale)
    • reverse

      public Vec3 reverse()
    • multiply

      public Vec3 multiply(Vec3 scale)
    • multiply

      public Vec3 multiply(double xScale, double yScale, double zScale)
    • horizontal

      public Vec3 horizontal()
    • offsetRandom

      public Vec3 offsetRandom(RandomSource random, float offset)
    • offsetRandomXZ

      public Vec3 offsetRandomXZ(RandomSource random, float offset)
    • length

      public double length()
    • lengthSqr

      public double lengthSqr()
    • horizontalDistance

      public double horizontalDistance()
    • horizontalDistanceSqr

      public double horizontalDistanceSqr()
    • equals

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

      public Vec3 xRot(float radians)
    • yRot

      public Vec3 yRot(float radians)
    • zRot

      public Vec3 zRot(float radians)
    • rotateClockwise90

      public Vec3 rotateClockwise90()
    • directionFromRotation

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

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

      public Vec2 rotation()
    • align

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

      public double get(Direction.Axis axis)
    • with

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

      public Vec3 relative(Direction direction, double distance)
    • 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 Vector3f toVector3f()
    • projectedOn

      public Vec3 projectedOn(Vec3 onto)
    • applyLocalCoordinatesToRotation

      public static Vec3 applyLocalCoordinatesToRotation(Vec2 rotation, Vec3 direction)
    • addLocalCoordinates

      public Vec3 addLocalCoordinates(Vec3 direction)
    • isFinite

      public boolean isFinite()