Class VecUtils

java.lang.Object
baritone.api.utils.VecUtils

public final class VecUtils extends Object
Since:
10/13/2018
Author:
Brady
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.phys.Vec3
    calculateBlockCenter(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
    Calculates the center of the block at the specified position's bounding box
    static double
    distanceToCenter(net.minecraft.core.BlockPos pos, double x, double y, double z)
    Gets the distance from the specified position to the assumed center of the specified block position.
    static double
    entityDistanceToCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
    Gets the distance from the specified entity's position to the assumed center of the specified block position.
    static double
    entityFlatDistanceToCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
    Gets the distance from the specified entity's position to the assumed center of the specified block position, ignoring the Y axis.
    static net.minecraft.world.phys.Vec3
    getBlockPosCenter(net.minecraft.core.BlockPos pos)
    Gets the assumed center position of the given block position.

    Methods inherited from class java.lang.Object

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

    • calculateBlockCenter

      public static net.minecraft.world.phys.Vec3 calculateBlockCenter(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      Calculates the center of the block at the specified position's bounding box
      Parameters:
      world - The world that the block is in, used to provide the bounding box
      pos - The block position
      Returns:
      The center of the block's bounding box
      See Also:
    • getBlockPosCenter

      public static net.minecraft.world.phys.Vec3 getBlockPosCenter(net.minecraft.core.BlockPos pos)
      Gets the assumed center position of the given block position. This is done by adding 0.5 to the X, Y, and Z axes.

      TODO: We may want to consider replacing many usages of this method with #calculateBlockCenter(BlockPos)

      Parameters:
      pos - The block position
      Returns:
      The assumed center of the position
      See Also:
    • distanceToCenter

      public static double distanceToCenter(net.minecraft.core.BlockPos pos, double x, double y, double z)
      Gets the distance from the specified position to the assumed center of the specified block position.
      Parameters:
      pos - The block position
      x - The x pos
      y - The y pos
      z - The z pos
      Returns:
      The distance from the assumed block center to the position
      See Also:
    • entityDistanceToCenter

      public static double entityDistanceToCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
      Gets the distance from the specified entity's position to the assumed center of the specified block position.
      Parameters:
      entity - The entity
      pos - The block position
      Returns:
      The distance from the entity to the block's assumed center
      See Also:
    • entityFlatDistanceToCenter

      public static double entityFlatDistanceToCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
      Gets the distance from the specified entity's position to the assumed center of the specified block position, ignoring the Y axis.
      Parameters:
      entity - The entity
      pos - The block position
      Returns:
      The horizontal distance from the entity to the block's assumed center
      See Also: