Class XMaterialData

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

public class XMaterialData extends Object
Cross-version material data wrapper using XSeries for compatibility.

This class serves as a pseudo-MaterialData implementation that combines XMaterial with legacy data values to provide consistent material representation across all Minecraft versions. It bridges the gap between pre-1.13 material data values and 1.13+ flattened materials.

In pre-1.13 versions, blocks were identified by a material ID and a data value (0-15) that specified variants like color, orientation, or state. The 1.13 "flattening" update replaced this system with individual materials for each variant. This class abstracts those differences by storing both the XMaterial and the legacy data value when needed.

Example usage:


 // Create with default data value from XMaterial
 XMaterialData data = new XMaterialData(XMaterial.STONE_BRICKS);
 
 // Create with specific data value for pre-1.13 compatibility
 XMaterialData redWool = new XMaterialData(XMaterial.RED_WOOL, 14);
 

  • Constructor Details

    • XMaterialData

      public XMaterialData(@NotNull @NotNull com.cryptomorin.xseries.XMaterial material)
      Creates material data with the default data value from XMaterial.

      This constructor uses the default data value provided by the XMaterial instance, which is typically the most appropriate value for representing that material in pre-1.13 versions.

      Parameters:
      material - the XMaterial to wrap
    • XMaterialData

      public XMaterialData(@NotNull @NotNull com.cryptomorin.xseries.XMaterial material, int data)
      Creates material data with a specific data value.

      This constructor allows explicit specification of the data value, which is useful when you need a specific variant that differs from the XMaterial's default data value. This is particularly important for pre-1.13 compatibility where data values determine material variants.

      Parameters:
      material - the XMaterial to wrap
      data - the specific data value to use (will be cast to byte)