Class XBlockData
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 Summary
FieldsModifier and TypeFieldDescriptionstatic XBlockData
Pre-configured block data for red sand blocks.static XBlockData
Pre-configured block data for source water blocks.static XBlockData
Pre-configured block data for stationary water.static XBlockData
Pre-configured block data for upper stone brick slabs. -
Constructor Summary
ConstructorsConstructorDescriptionXBlockData
(com.cryptomorin.xseries.XMaterial material) Creates block data from anXMaterial
with default properties.XBlockData
(com.cryptomorin.xseries.XMaterial material, int data) Creates block data from anXMaterial
with a specific data value.XBlockData
(XMaterialData materialData) Creates block data from existingXMaterialData
. -
Method Summary
-
Field Details
-
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
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
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
Pre-configured block data for red sand blocks.Represents red sand, which was
SAND:1
in pre-1.13 versions and becameXMaterial.RED_SAND
in 1.13+ versions. TheXMaterial
system handles this transition automatically.
-
-
Constructor Details
-
XBlockData
public XBlockData(com.cryptomorin.xseries.XMaterial material) Creates block data from anXMaterial
with default properties.This constructor creates an
XMaterialData
using the material's default data value, suitable for most basic block placement operations.- Parameters:
material
- theXMaterial
to use for this block data
-
XBlockData
public XBlockData(com.cryptomorin.xseries.XMaterial material, int data) Creates block data from anXMaterial
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
- theXMaterial
to use for this block datadata
- the specific data value to use
-
XBlockData
Creates block data from existingXMaterialData
.This constructor accepts pre-configured material data, allowing for more complex initialization scenarios or reuse of existing material data instances.
- Parameters:
materialData
- theXMaterialData
to use for this block data
-