Skip to content

ChunkUtils

Aram edited this page Jan 9, 2025 · 2 revisions

ChunkUtils

Overview

The ChunkUtils class in the software.bluelib.utils.minecraft package provides methods for interacting with Minecraft chunks. This utility class allows you to retrieve biome information, tile entity data, and count the number of blocks in a chunk.

Key Methods

  1. getBiomeOfChunk(Level, ChunkPos)
    Retrieves the Biome of the specified chunk.

    Biome biome = ChunkUtils.getBiomeOfChunk(level, chunkPos);
  2. getBiomeRegistryNameOfChunk(Level, ChunkPos)
    Retrieves the biome registry name of the specified chunk.

    String registryName = ChunkUtils.getBiomeRegistryNameOfChunk(level, chunkPos);
  3. getBiomeSimpleNameOfChunk(Level, ChunkPos)
    Retrieves the simple name of the biome in the specified chunk.

    String simpleName = ChunkUtils.getBiomeSimpleNameOfChunk(level, chunkPos);
  4. getChunkTileEntities(Level, ChunkPos)
    Retrieves the tile entities within the specified chunk.

    Collection<BlockEntity> tileEntities = ChunkUtils.getChunkTileEntities(level, chunkPos);
  5. getChunkTileEntitiesRegistryNames(Level, ChunkPos)
    Retrieves the registry names of tile entities in the specified chunk.

    String tileEntityRegistryNames = ChunkUtils.getChunkTileEntitiesRegistryNames(level, chunkPos);
  6. getChunkTileEntitiesSimpleNames(Level, ChunkPos)
    Retrieves the simple names of tile entities in the specified chunk.

    String tileEntitySimpleNames = ChunkUtils.getChunkTileEntitiesSimpleNames(level, chunkPos);
  7. getChunkBlockCount(Level, ChunkPos)
    Counts the number of non-air blocks in the specified chunk.

    int nonAirBlockCount = ChunkUtils.getChunkBlockCount(level, chunkPos);

Usage Notes

  • Error Handling: Each method logs an error message if an exception occurs, providing helpful context for debugging.
  • Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.