Class RandomPos

java.lang.Object
net.minecraft.world.entity.ai.util.RandomPos

public class RandomPos extends Object
  • Field Details

  • Constructor Details

    • RandomPos

      public RandomPos()
  • Method Details

    • generateRandomDirection

      public static BlockPos generateRandomDirection(RandomSource random, int horizontalDistance, int verticalDistance)
      Gets a random position within a certain distance.
    • generateRandomDirectionWithinRadians

      @Nullable public static BlockPos generateRandomDirectionWithinRadians(RandomSource random, int maxHorizontalDifference, int yRange, int y, double x, double z, double maxAngleDelta)
      Parameters:
      maxHorizontalDifference - The maximum value in x and z, in absolute value, that could be returned.
      yRange - The range plus or minus the y position to be chosen
      y - The target y position
      x - The x offset to the target position
      z - The z offset to the target position
      maxAngleDelta - The maximum variance of the returned angle, from the base angle being a vector from (0, 0) to (x , z).
      Returns:
      a random (x, y, z) coordinate by picking a point (x, z), adding a random angle, up to a difference of maxAngleDelta. The y position is randomly chosen from the range [y - yRange, y + yRange]. Will be null if the chosen coordinate is outside a distance of maxHorizontalDistance from the origin.
    • moveUpOutOfSolid

      public static BlockPos moveUpOutOfSolid(BlockPos pos, int maxY, Predicate<BlockPos> posPredicate)
      Returns:
      the highest above position that is within the provided conditions
    • moveUpToAboveSolid

      public static BlockPos moveUpToAboveSolid(BlockPos pos, int aboveSolidAmount, int maxY, Predicate<BlockPos> posPredicate)
      Finds a position above based on the conditions. After it finds the position once, it will continue to move up until aboveSolidAmount is reached or the position is no longer valid
    • generateRandomPos

      @Nullable public static Vec3 generateRandomPos(PathfinderMob mob, Supplier<BlockPos> posSupplier)
    • generateRandomPos

      @Nullable public static Vec3 generateRandomPos(Supplier<BlockPos> posSupplier, ToDoubleFunction<BlockPos> toDoubleFunction)
      Tries 10 times to maximize the return value of the position to double function based on the supplied position
    • generateRandomPosTowardDirection

      public static BlockPos generateRandomPosTowardDirection(PathfinderMob mob, int range, RandomSource random, BlockPos pos)
      Returns:
      a random position within range, only if the mob is currently restricted