Class WorldUtils

java.lang.Object
io.hymods.lib.utils.WorldUtils

public class WorldUtils extends Object
Utility class for world and block operations
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<BlockInfo>
    findBlocks(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius, Predicate<com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType> predicate)
    Finds blocks matching a predicate in an area
    static List<BlockInfo>
    getAdjacentBlocks(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z, boolean includeDiagonals)
    Gets adjacent blocks
    static com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType
    getBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z)
    Gets a block at a specific position
    static com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType
    getBlock(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d position)
    Gets a block at a vector position
    static List<BlockInfo>
    getBlocksInArea(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3i min, com.hypixel.hytale.math.vector.Vector3i max)
    Gets all blocks in a cubic area
    static List<BlockInfo>
    getBlocksInSphere(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius)
    Gets all blocks in a sphere
    static long
    getChunkIndex(int chunkX, int chunkZ)
    Gets the chunk index from chunk coordinates
    static long
    getChunkIndexAtBlock(int blockX, int blockZ)
    Gets the chunk index for a block position
    static int
    getFirstAirBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int startY, int z, int maxY)
    Finds the first air block above a position
    static int
    getHighestBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int z, int maxY)
    Finds the highest solid block at a position
    static boolean
    isAirBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block)
    Checks if a block is air or empty
    static boolean
    isChunkLoaded(com.hypixel.hytale.server.core.universe.world.World world, int chunkX, int chunkZ)
    Checks if a chunk is loaded
    static boolean
    isSolidBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block)
    Checks if a block is solid
    static boolean
    setBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z, com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType blockType)
    Sets a block at a specific position Note: Block setting requires chunk access via world.getChunk(index).setBlock()

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBlock

      public static com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType getBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z)
      Gets a block at a specific position
      Parameters:
      world - The world
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      Returns:
      The block type at the position
    • getBlock

      public static com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType getBlock(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d position)
      Gets a block at a vector position
      Parameters:
      world - The world
      position - The position
      Returns:
      The block type at the position
    • setBlock

      public static boolean setBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z, com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType blockType)
      Sets a block at a specific position Note: Block setting requires chunk access via world.getChunk(index).setBlock()
      Parameters:
      world - The world
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      blockType - The block type to set
      Returns:
      true if the block was set successfully
    • getBlocksInArea

      public static List<BlockInfo> getBlocksInArea(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3i min, com.hypixel.hytale.math.vector.Vector3i max)
      Gets all blocks in a cubic area
      Parameters:
      world - The world
      min - Minimum corner
      max - Maximum corner
      Returns:
      List of block positions and types
    • getBlocksInSphere

      public static List<BlockInfo> getBlocksInSphere(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius)
      Gets all blocks in a sphere
      Parameters:
      world - The world
      center - Center of the sphere
      radius - Radius of the sphere
      Returns:
      List of block positions and types
    • getHighestBlock

      public static int getHighestBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int z, int maxY)
      Finds the highest solid block at a position
      Parameters:
      world - The world
      x - X coordinate
      z - Z coordinate
      maxY - Maximum Y to check
      Returns:
      Y coordinate of highest solid block, or -1 if none found
    • getFirstAirBlock

      public static int getFirstAirBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int startY, int z, int maxY)
      Finds the first air block above a position
      Parameters:
      world - The world
      x - X coordinate
      startY - Starting Y coordinate
      z - Z coordinate
      maxY - Maximum Y to check
      Returns:
      Y coordinate of first air block, or -1 if none found
    • isAirBlock

      public static boolean isAirBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block)
      Checks if a block is air or empty
      Parameters:
      block - The block type
      Returns:
      true if the block is air/empty
    • isSolidBlock

      public static boolean isSolidBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block)
      Checks if a block is solid
      Parameters:
      block - The block type
      Returns:
      true if the block is solid
    • getAdjacentBlocks

      public static List<BlockInfo> getAdjacentBlocks(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z, boolean includeDiagonals)
      Gets adjacent blocks
      Parameters:
      world - The world
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      includeDiagonals - Whether to include diagonal blocks
      Returns:
      List of adjacent blocks
    • findBlocks

      public static List<BlockInfo> findBlocks(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius, Predicate<com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType> predicate)
      Finds blocks matching a predicate in an area
      Parameters:
      world - The world
      center - Center position
      radius - Search radius
      predicate - Block filter predicate
      Returns:
      List of matching blocks
    • getChunkIndexAtBlock

      public static long getChunkIndexAtBlock(int blockX, int blockZ)
      Gets the chunk index for a block position
      Parameters:
      blockX - Block X coordinate
      blockZ - Block Z coordinate
      Returns:
      The chunk index
    • getChunkIndex

      public static long getChunkIndex(int chunkX, int chunkZ)
      Gets the chunk index from chunk coordinates
      Parameters:
      chunkX - Chunk X coordinate
      chunkZ - Chunk Z coordinate
      Returns:
      The chunk index
    • isChunkLoaded

      public static boolean isChunkLoaded(com.hypixel.hytale.server.core.universe.world.World world, int chunkX, int chunkZ)
      Checks if a chunk is loaded
      Parameters:
      world - The world
      chunkX - Chunk X coordinate
      chunkZ - Chunk Z coordinate
      Returns:
      true if the chunk is loaded