Class XMaterialData
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 Summary
ConstructorsConstructorDescriptionXMaterialData
(@NotNull com.cryptomorin.xseries.XMaterial material) Creates material data with the default data value fromXMaterial
.XMaterialData
(@NotNull com.cryptomorin.xseries.XMaterial material, int data) Creates material data with a specific data value. -
Method Summary
-
Constructor Details
-
XMaterialData
public XMaterialData(@NotNull @NotNull com.cryptomorin.xseries.XMaterial material) Creates material data with the default data value fromXMaterial
.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
- theXMaterial
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
- theXMaterial
to wrapdata
- the specific data value to use (will be cast to byte)
-