Class WorldUtil

java.lang.Object
com.hypixel.hytale.server.core.modules.collision.WorldUtil

public final class WorldUtil extends Object
A utility class for collision-specific world functions.
  • Constructor Details

    • WorldUtil

      public WorldUtil()
  • Method Details

    • isFluidOnlyBlock

      public static boolean isFluidOnlyBlock(@Nonnull BlockType blockType, int fluidId)
      Determine if a block consists only of fluid regarding collisions.
      Parameters:
      blockType - BlockType to test.
      fluidId - The fluid ID at the block position.
      Returns:
      true if the block can be considered fluid only.
    • isSolidOnlyBlock

      public static boolean isSolidOnlyBlock(@Nonnull BlockType blockType, int fluidId)
      Determine if a block is solid without fluid.
      Parameters:
      blockType - BlockType to test.
      fluidId - The fluid ID at the block position.
      Returns:
      true if block is solid and contains no fluid.
    • isEmptyOnlyBlock

      public static boolean isEmptyOnlyBlock(@Nonnull BlockType blockType, int fluidId)
      Determine if a block is plain empty.
      Parameters:
      blockType - BlockType to test.
      fluidId - The fluid ID at the block position.
      Returns:
      true if block is empty and contains no fluid.
    • getFluidIdAtPosition

      public static int getFluidIdAtPosition(@Nonnull ChunkStore chunkStore, int x, int y, int z)
      Returns the fluid ID at the given block position.
      Parameters:
      chunkStore - The chunk store to resolve the section from.
      x - The X block coordinate.
      y - The Y block coordinate.
      z - The Z block coordinate.
      Returns:
      the fluid ID at the position, or Fluid.EMPTY_ID if none.
    • getPackedMaterialAndFluidAtPosition

      public static long getPackedMaterialAndFluidAtPosition(@Nonnull ChunkStore chunkStore, double x, double y, double z)
      Returns the material and fluid ID at the given position, packed into a long.

      The material ordinal is packed into the left 32 bits, and the fluid ID is packed into the right 32 bits. Use MathUtil.unpackLeft(long) to extract the material ordinal, and MathUtil.unpackRight(long) to extract the fluid ID.

      Parameters:
      chunkStore - The chunk store to resolve the section from.
      x - The X coordinate of the position.
      y - The Y coordinate of the position.
      z - The Z coordinate of the position.
      Returns:
      a packed long containing material ordinal, left, and fluid ID, right.
    • findFluidBlock

      public static int findFluidBlock(@Nonnull ChunkStore chunkStore, int x, int y, int z, boolean allowBubble)
      Get bottom most fluid block for fluid depth computation.

      The initial block x/y/z can point to a non fluid block if allowBubble is set to true. In that case x/y/z is assumed to be a ground block and an empty block can be on top (caused by submerging blocks).

      Parameters:
      chunkStore - The chunk store to resolve sections from.
      x - The X block coordinate.
      y - The Y block coordinate.
      z - The Z block coordinate.
      allowBubble - Tolerate a ground bubble from submerging.
      Returns:
      y coordinate of fluid block or -1 if there is none.
    • getWaterLevel

      public static int getWaterLevel(@Nonnull ChunkStore chunkStore, int x, int z, int startY, int maxY)
      Compute water level at a given block position.

      Water level is given by a consecutive number of fully fluid blocks from start position upwards allowing for a ground bubble.

      Parameters:
      chunkStore - The chunk store to resolve sections from.
      x - The X block coordinate.
      z - The Z block coordinate.
      startY - The Y coordinate to start.
      maxY - The highest Y block coordinate the walk may visit.
      Returns:
      water level from this position upwards or -1 if there is no water.
    • findFarthestEmptySpaceBelow

      public static int findFarthestEmptySpaceBelow(@Nonnull ChunkStore chunkStore, int x, int y, int z, int yFail, int minY)
      Compute y block position of the farthest consecutive empty block below given position.
      Parameters:
      chunkStore - The chunk store to resolve sections from.
      x - The X block coordinate.
      y - The Y block coordinate.
      z - The Z block coordinate.
      yFail - The Y value to be returned when initial y is below minY.
      minY - The lowest Y block coordinate the scan may visit.
      Returns:
      y block coordinate of farthest empty block below initial block position, minY when the scan reaches it, or yFail.
    • findFarthestEmptySpaceAbove

      public static int findFarthestEmptySpaceAbove(@Nonnull ChunkStore chunkStore, int x, int y, int z, int yFail, int maxY)
      Compute y block position of the farthest consecutive empty block above given position.
      Parameters:
      chunkStore - The chunk store to resolve sections from.
      x - The X block coordinate.
      y - The Y block coordinate.
      z - The Z block coordinate.
      yFail - The Y value to be returned when initial y is above maxY.
      maxY - The highest Y block coordinate the scan may visit.
      Returns:
      y block coordinate of farthest empty block above initial block position, maxY when the scan reaches it, or yFail.