Class WorldUtils
java.lang.Object
io.hymods.lib.utils.WorldUtils
Utility class for world and block operations
-
Method Summary
Modifier and TypeMethodDescriptionfindBlocks(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 areagetAdjacentBlocks(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z, boolean includeDiagonals) Gets adjacent blocksstatic com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockTypegetBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int y, int z) Gets a block at a specific positionstatic com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockTypegetBlock(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d position) Gets a block at a vector positiongetBlocksInArea(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 areagetBlocksInSphere(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius) Gets all blocks in a spherestatic longgetChunkIndex(int chunkX, int chunkZ) Gets the chunk index from chunk coordinatesstatic longgetChunkIndexAtBlock(int blockX, int blockZ) Gets the chunk index for a block positionstatic intgetFirstAirBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int startY, int z, int maxY) Finds the first air block above a positionstatic intgetHighestBlock(com.hypixel.hytale.server.core.universe.world.World world, int x, int z, int maxY) Finds the highest solid block at a positionstatic booleanisAirBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block) Checks if a block is air or emptystatic booleanisChunkLoaded(com.hypixel.hytale.server.core.universe.world.World world, int chunkX, int chunkZ) Checks if a chunk is loadedstatic booleanisSolidBlock(com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType block) Checks if a block is solidstatic booleansetBlock(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()
-
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 worldx- X coordinatey- Y coordinatez- 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 worldposition- 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 worldx- X coordinatey- Y coordinatez- Z coordinateblockType- 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 worldmin- Minimum cornermax- 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 worldcenter- Center of the sphereradius- 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 worldx- X coordinatez- Z coordinatemaxY- 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 worldx- X coordinatestartY- Starting Y coordinatez- Z coordinatemaxY- 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 worldx- X coordinatey- Y coordinatez- Z coordinateincludeDiagonals- 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 worldcenter- Center positionradius- Search radiuspredicate- 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 coordinateblockZ- 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 coordinatechunkZ- 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 worldchunkX- Chunk X coordinatechunkZ- Chunk Z coordinate- Returns:
- true if the chunk is loaded
-