Class DistributionHelpers

java.lang.Object
jeresources.api.distributions.DistributionHelpers

public class DistributionHelpers extends Object
  • Field Details

  • Constructor Details

    • DistributionHelpers

      public DistributionHelpers()
  • Method Details

    • getTriangularDistribution

      public static float[] getTriangularDistribution​(int midY, int range, float maxChance)
      Parameters:
      midY - the top, middle of the triangle
      range - length of the sides
      maxChance - chance at the top
      Returns:
      an array of 256 floats in triangular distribution
    • getTriangularDistribution

      public static float[] getTriangularDistribution​(int minY, int rand1, int rand2, float maxChance)
    • getSquareDistribution

      public static float[] getSquareDistribution​(int minY, int maxY, float chance)
      Parameters:
      minY - first occurrence
      maxY - last occurrence
      chance - the chance
      Returns:
      an array of 256 floats in square distribution
    • getRoundedSquareDistribution

      public static float[] getRoundedSquareDistribution​(int min0, int minY, int maxY, int max0, float chance)
      Parameters:
      min0 - start of the ramp
      minY - end of the ramp up
      maxY - start of the ramp down
      max0 - end of ramp down
      chance - the chance at the top
      Returns:
      an array of 256 floats in square distribution
    • getUnderwaterDistribution

      public static float[] getUnderwaterDistribution​(float chance)
    • getRampDistribution

      public static float[] getRampDistribution​(int minY, int maxY, float minChance, float maxChance)
      Parameters:
      minY - first occurrence
      maxY - last occurrence
      minChance - change at the bottom of the ramp
      maxChance - chance at the top of the ramp
      Returns:
      an array of floats with length |maxY - minY| in ramp distribution
    • getRampDistribution

      public static float[] getRampDistribution​(int minY, int maxY, float maxChance)
    • getOverworldSurfaceDistribution

      public static float[] getOverworldSurfaceDistribution​(int oreDiameter)
    • getOverworldSurface

      public static float[] getOverworldSurface()
    • addDistribution

      public static float[] addDistribution​(float[] base, float[] add)
      Parameters:
      base - base distribution
      add - the to add distribution
      Returns:
      the sum of both distributions
    • addDistribution

      public static DistributionBase addDistribution​(DistributionBase base, DistributionBase add)
    • addDistribution

      public static float[] addDistribution​(float[] base, float[] add, int offset)
      Parameters:
      base - base distribution
      add - the to add distribution
      offset - the first element from the base array to start adding to
      Returns:
      the sum of both distributions
    • reverse

      public static float[] reverse​(float[] array)
      Parameters:
      array - the float array to reverse
      Returns:
      a reversed version of the given array
    • calculateMeanLevel

      @Deprecated public static int calculateMeanLevel​(float[] distribution, int mid, int oldMid, float difference)
      Deprecated.
    • calculateMeanLevel

      public static int calculateMeanLevel​(float[] distribution, int mid)
      Parameters:
      distribution - the target array
      mid - the "best guess" of the midpoint
      Returns:
      the mid level of the distribution
    • divideArray

      public static float[] divideArray​(float[] array, float num)
      Parameters:
      array - the to divide array
      num - the denominator
      Returns:
      the divided array
    • multiplyArray

      public static float[] multiplyArray​(float[] array, float num)
      Parameters:
      array - the to multiply array
      num - the multiplier
      Returns:
      the divided array
    • maxJoinArray

      public static float[] maxJoinArray​(float[] array1, float[] array2)
    • sum

      public static float sum​(float[] distribution)
    • calculateChance

      public static float calculateChance​(int veinCount, int veinSize, int minY, int maxY)
      Parameters:
      veinCount - the amount of veins per chunk
      veinSize - the amount of blocks per vein
      minY - the lowest Y value for a vein
      maxY - the highest Y value for a vein
      Returns:
      the chance that a block appears within the specified Y boundaries
    • getDistributionFromPoints

      public static float[] getDistributionFromPoints​(DistributionHelpers.OrePoint... points)