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 pRandom, int pHorizontalDistance, int pVerticalDistance)
      Gets a random position within a certain distance.
    • generateRandomDirectionWithinRadians

      @Nullable public static BlockPos generateRandomDirectionWithinRadians(RandomSource pRandom, int pMaxHorizontalDifference, int pYRange, int pY, double pX, double pZ, double pMaxAngleDelta)
      Parameters:
      pMaxHorizontalDifference - The maximum value in x and z, in absolute value , that could be returned.
      pYRange - The range plus or minus the y position to be chosen
      pY - The target y position
      pX - The x offset to the target position
      pZ - The z offset to the target position
      pMaxAngleDelta - 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 pPos, int pMaxY, Predicate<BlockPos> pPosPredicate)
      Returns:
      the highest above position that is within the provided conditions
    • moveUpToAboveSolid

      public static BlockPos moveUpToAboveSolid(BlockPos pPos, int pAboveSolidAmount, int pMaxY, Predicate<BlockPos> pPosPredicate)
      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 pMob, Supplier<BlockPos> pPosSupplier)
    • generateRandomPos

      @Nullable public static Vec3 generateRandomPos(Supplier<BlockPos> pPosSupplier, ToDoubleFunction<BlockPos> pToDoubleFunction)
      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 pMob, int pRange, RandomSource pRandom, BlockPos pPos)
      Returns:
      a random position within range, only if the mob is currently restricted