Class XBlockData

java.lang.Object
com.kamikazejam.kamicommon.nms.util.data.XBlockData

public class XBlockData extends Object
Cross-version block data representation using XSeries for compatibility.

This class serves as a pseudo-BlockData implementation that provides unified block data handling across all Minecraft versions. It combines XMaterialData for basic material representation with additional properties that map to 1.13+ BlockData states while maintaining compatibility with pre-1.13 data values.

The 1.13 "flattening" update introduced the BlockData system, replacing the old material ID + data value system with rich block state properties. This class bridges that gap by storing both the legacy material data and modern block state properties, allowing block utilities to handle both systems appropriately.

Block utilities (particularly IBlockUtil1_13) use the properties defined in this class to set appropriate block states when placing blocks, ensuring consistent behavior across all supported Minecraft versions.

Example usage:


 // Create basic block data
 XBlockData stone = new XBlockData(XMaterial.STONE);
 
 // Create with specific properties
 XBlockData upperSlab = new XBlockData(XMaterial.STONE_SLAB)
     .setSlabType(SlabType.TOP);
 
 // Create water with specific level
 XBlockData water = new XBlockData(XMaterial.WATER)
     .setLevel(8);
 

  • Field Details

    • SOURCE_WATER

      public static XBlockData SOURCE_WATER
      Pre-configured block data for source water blocks.

      Represents a full water source block, equivalent to placing water from a bucket. Uses the default data value for XMaterial.WATER.

    • STATIONARY_WATER

      public static XBlockData STATIONARY_WATER
      Pre-configured block data for stationary water.

      Represents stationary water with data value 8 for pre-1.13 compatibility and level 8 for 1.13+ versions. This typically represents water that doesn't flow or update.

    • UPPER_STONE_SLAB

      public static XBlockData UPPER_STONE_SLAB
      Pre-configured block data for upper stone brick slabs.

      Represents a stone brick slab positioned at the top of a block space. Uses data value 8 for pre-1.13 compatibility and SlabType.TOP for 1.13+ versions.

    • RED_SAND

      public static XBlockData RED_SAND
      Pre-configured block data for red sand blocks.

      Represents red sand, which was SAND:1 in pre-1.13 versions and became XMaterial.RED_SAND in 1.13+ versions. The XMaterial system handles this transition automatically.

  • Constructor Details

    • XBlockData

      public XBlockData(com.cryptomorin.xseries.XMaterial material)
      Creates block data from an XMaterial with default properties.

      This constructor creates an XMaterialData using the material's default data value, suitable for most basic block placement operations.

      Parameters:
      material - the XMaterial to use for this block data
    • XBlockData

      public XBlockData(com.cryptomorin.xseries.XMaterial material, int data)
      Creates block data from an XMaterial with a specific data value.

      This constructor allows specification of a custom data value, which is particularly useful for pre-1.13 compatibility where data values determine block variants and states.

      Parameters:
      material - the XMaterial to use for this block data
      data - the specific data value to use
    • XBlockData

      public XBlockData(XMaterialData materialData)
      Creates block data from existing XMaterialData.

      This constructor accepts pre-configured material data, allowing for more complex initialization scenarios or reuse of existing material data instances.

      Parameters:
      materialData - the XMaterialData to use for this block data