Interface NMSChunkSection

All Superinterfaces:
NMSObject

public interface NMSChunkSection extends NMSObject
NMS wrapper interface for Minecraft chunk section objects.

This interface provides a version-independent abstraction for working with chunk sections, which are 16x16x16 block cubes that make up chunks. Chunk sections are the fundamental storage units for blocks in Minecraft, providing efficient storage and manipulation of block data within chunks.

Each chunk section covers a 16-block-high slice of a chunk, with sections stacked vertically from the world's minimum height to maximum height. Sections can be empty (containing only air) or populated with various block types and states.

The wrapper provides direct block manipulation within the section coordinate space (0-15 for X and Z, section-relative for Y) and abstracts away the complexity of version-specific block storage formats.

Example usage:


 // Get chunk section
 NMSChunkSection section = chunk.getOrCreateSection(64);
 
 // Set blocks within the section
 section.setType(0, 0, 0, Material.STONE);
 section.setType(15, 15, 15, customBlockData);
 
 // Check if section is empty
 if (!section.isEmpty()) {
     // Process non-empty section
 }
 

  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull NMSChunk
    Retrieves the parent chunk that contains this section.
    boolean
    Checks if this chunk section is empty.
    void
    setType(int x, int y, int z, @NotNull XBlockData blockData)
    Sets the block type and data at the specified coordinates within this section.
    USES PlaceType.NMS for fastest placement.
    void
    setType(int x, int y, int z, @NotNull Material material)
    Sets the block type at the specified coordinates within this section.
    USES PlaceType.NMS for fastest placement.

    Methods inherited from interface com.kamikazejam.kamicommon.nms.wrappers.NMSObject

    getHandle
  • Method Details

    • getNMSChunk

      @NotNull @NotNull NMSChunk getNMSChunk()
      Retrieves the parent chunk that contains this section.

      This method provides access to the chunk that this section belongs to, enabling access to chunk-level operations and maintaining the hierarchical relationship between chunks and their sections.

      Returns:
      the NMSChunk that contains this section
    • setType

      void setType(int x, int y, int z, @NotNull @NotNull Material material)
      Sets the block type at the specified coordinates within this section.
      USES PlaceType.NMS for fastest placement. Don't use the NMSChunk API if you want physics or updates.

      This method places a block of the specified material at the given coordinates within the section. Coordinates are relative to the section (0-15 for X and Z, section-relative for Y).

      This is a simplified block placement method that uses the material's default block state. For more complex block data, use the setType(int, int, int, XBlockData) overload.

      Parameters:
      x - the X coordinate within the section (0-15)
      y - the Y coordinate within the section (section-relative)
      z - the Z coordinate within the section (0-15)
      material - the Material to place at the specified location
    • setType

      void setType(int x, int y, int z, @NotNull @NotNull XBlockData blockData)
      Sets the block type and data at the specified coordinates within this section.
      USES PlaceType.NMS for fastest placement. Don't use the NMSChunk API if you want physics or updates.

      This method places a block with the specified block data at the given coordinates within the section. The XBlockData provides cross-version compatibility for block states, properties, and legacy data values.

      This method should be used when placing blocks that require specific properties, orientations, or states that cannot be represented by a simple material type.

      Parameters:
      x - the X coordinate within the section (0-15)
      y - the Y coordinate within the section (section-relative)
      z - the Z coordinate within the section (0-15)
      blockData - the XBlockData containing material and state information
    • isEmpty

      boolean isEmpty()
      Checks if this chunk section is empty.

      An empty section contains only air blocks and has no meaningful block data. Empty sections are often optimized by the Minecraft engine to save memory and processing time.

      This method is useful for determining whether a section needs processing or can be skipped in bulk operations.

      Returns:
      true if the section contains only air blocks, false otherwise