Class CaveNodeShapeUtils

java.lang.Object
com.hypixel.hytale.server.worldgen.cave.shape.CaveNodeShapeUtils

public class CaveNodeShapeUtils extends Object
  • Field Details

  • Constructor Details

    • CaveNodeShapeUtils

      public CaveNodeShapeUtils()
  • Method Details

    • getBoxAnchor

      @Nonnull public static org.joml.Vector3d getBoxAnchor(@Nonnull org.joml.Vector3d vector, @Nonnull IWorldBounds bounds, double tx, double ty, double tz)
      Returns the projected point inside a cuboid represented by the IWorldBounds.
      Parameters:
      vector - The vector to assign the result to.
      bounds - The bounds inside which the point should be projected.
      tx - The projection in the x-axis.
      ty - The projection in the y-axis.
      tz - The projection in the z-axis.
      Returns:
      The position of the projected point (tx,ty,tz) within the bounds.
    • getLineAnchor

      @Nonnull public static org.joml.Vector3d getLineAnchor(@Nonnull org.joml.Vector3d vector, @Nonnull org.joml.Vector3d o, @Nonnull org.joml.Vector3d v, double t)
      Returns the point at the projection 't' on the line o + v.
      Parameters:
      vector - The vector to assign the result to.
      o - The start point of the line.
      v - The direction of the line.
      t - The projection along the line.
      Returns:
      The projected point along the line.
    • getSphereAnchor

      @Nonnull public static org.joml.Vector3d getSphereAnchor(@Nonnull org.joml.Vector3d vector, @Nonnull org.joml.Vector3d origin, double rx, double ry, double rz, double tx, double ty, double tz)
      Returns the projected point inside a sphere/ellipsoid.
      Parameters:
      vector - The vector to assign the result to.
      origin - The center point of the ellipsoid.
      rx - The x-radius of the ellipsoid.
      ry - The y-radius of the ellipsoid.
      rz - The z-radius of the ellipsoid.
      tx - The projection in the x-axis.
      ty - The projection in the y-axis.
      tz - The projection in the z-axis.
      Returns:
      The position of the projected point (tx,ty,tz) within the sphere/ellipsoid
    • getPipeAnchor

      @Nonnull public static org.joml.Vector3d getPipeAnchor(@Nonnull org.joml.Vector3d vector, @Nonnull org.joml.Vector3d o, @Nonnull org.joml.Vector3d v, double rx, double ry, double rz, double t, double tv, double th)
      Returns the projected point inside a tube/cylinder shape.
      Parameters:
      vector - The vector to assign the result to.
      o - The start point of the line.
      v - The direction of the line.
      rx - The x-radius of the tube at the projection point t on the line o + v.
      ry - The y-radius of the tube at the projection point t on the line o + v.
      rz - The z-radius of the tube at the projection point t on the line o + v.
      t - The projection point on the line o + v.
      tv - The vertical projection on the circular cross-section at the point t on the line o + v.
      th - The horizontal projection on the circular cross-section at the point t on the line o + v.
      Returns:
      The position of the projected point (tx,ty,tz) within the tube/cylinder.
    • getOffset

      @Nonnull public static org.joml.Vector3d getOffset(@Nullable CaveNode parent, @Nonnull CaveNodeType.CaveNodeChildEntry childEntry)
      Get the origin offset vector for a child cave node, applying rotations if the parent node happens to be a PrefabCaveNode.
      Parameters:
      parent - The parent cave node.
      childEntry - The child node configuration being generated.
      Returns:
      The offset vector for the child cave node.
    • getEndRadius

      public static double getEndRadius(@Nullable CaveNode node, @Nonnull IDoubleRange range, Random random)
      Get the radius of a CaveNode at its end. If the node shape supports independent values for its horizontal and vertical radii, the lower of the two will be selected.
      Parameters:
      node - The CaveNode whose end radius should be retrieved.
      range - The IDoubleRange to be used as a fallback when the radius cannot be determined.
      random - The Random to be used as a fallback when the end radius cannot be determined.
      Returns:
      The end radius of the CaveNode or a randomly selected value controlled by the range.
    • getEndWidth

      public static double getEndWidth(@Nullable CaveNode node, @Nonnull IDoubleRange range, Random random)
      Get the horizontal radius of a CaveNode at its end.
      Parameters:
      node - The CaveNode whose horizontal end radius should be retrieved.
      range - The IDoubleRange to be used as a fallback when the radius cannot be determined.
      random - The Random to be used as a fallback when the end radius cannot be determined.
      Returns:
      The end height of the CaveNode or a randomly selected value controlled by the range.
    • getEndHeight

      public static double getEndHeight(@Nullable CaveNode node, @Nonnull IDoubleRange range, Random random)
      Get the vertical radius of a CaveNode at its end.
      Parameters:
      node - The CaveNode whose vertical end radius should be retrieved.
      range - The IDoubleRange to be used as a fallback when the radius cannot be determined.
      random - The Random to be used as a fallback when the end radius cannot be determined.
      Returns:
      The end width of the CaveNode or a randomly selected value controlled by the range.
    • getEndRadius

      public static double getEndRadius(@Nonnull CaveNodeShape shape, @Nonnull BiDoubleToDoubleFunction widthHeightSelector)
      Get the radius of the CaveNodeShape at its end.
      Parameters:
      shape - The cave node whose end radius should be retrieved.
      widthHeightSelector - Function for selecting between the horizontal invalid input: '&' vertical radii if supported by the node shape.
      Returns:
      The radius of the CaveNodeShape or -1 if the end radius cannot be determined.
    • getFillingBlock

      @Nullable public static BlockFluidEntry getFillingBlock(@Nonnull CaveType cave, @Nonnull CaveNodeType node, int y, @Nonnull Random random)
      Get the filling block for a cave node at a given height.
      Parameters:
      cave - The CaveType the node belongs to.
      node - The CaveNode being generated.
      y - The height to get the filling block at.
      random - A Random used to select a filling block when multiple options exist
      Returns:
      The block to fill the cave with at the given height.
    • isCoverMatchingParent

      public static boolean isCoverMatchingParent(int cx, int cz, int y, @Nonnull ChunkGeneratorExecution execution, @Nonnull CaveNodeType.CaveNodeCoverEntry cover)
      Test a position within the given chunk to see if a cover can be placed above or below the 'parent' of that position.
      Parameters:
      cx - The chunk column x-coordinate to test.
      cz - The chunk column z-coordinate to test.
      y - The y-coordinate at which the cover is being placed in the chunk.
      execution - The ChunkGeneratorExecution for the current chunk being populated.
      cover - The cover that is populating the chunk at the given coordinates.
      Returns:
      True if the parent block position is within the chunk height bounds and the block at that position is matching the cover's parent mask.
    • invalidateCover

      public static boolean invalidateCover(int x, int y, int z, CaveNodeType.CaveNodeCoverType type, @Nonnull ChunkGeneratorExecution execution, @Nonnull BlockTypeAssetMap<String, BlockType> blockTypeMap)
      Test the block at the provided chunk-relative coordinates to see if it is a cover block that requires a supporting block below it. Note: This doesn't actually test the support requirement since this check is used during cave population where it's already known that the block below has been set to air/liquid.
      Parameters:
      x - The chunk-relative x coordinate.
      y - The chunk-relative x coordinate.
      z - The chunk-relative x coordinate.
      execution - The current ChunkGeneratorExecution.
      blockTypeMap - The BlockTypeAssetMap.
      Returns:
      True if the block is a cover and requires a supporting block below it.