gdpc.block

Provides the Block class, which represents a Minecraft block.


class Block

A Minecraft block.

Block states can be stored in states, and block entity data can be stored in data as an SNBT string.

If id is an empty string or None, the block represents “nothing”. Placing such a block has no effect. This is opposed to blocks of air, which do replace existing blocks. Nothing-blocks can be useful in block palettes.

The transform methods modify a number of orientation-related block states. These are:

  • axis

  • facing

  • half

  • rotation

Other orientation-related block states are currently not supported by the transformation system, but support may be added in a future version.

__init__(id: str | None = 'minecraft:stone', states: dict[str, str] | None = None, data: str | None = None)

Constructs a Block instance with the given properties.

id : str | None = 'minecraft:stone'

Block ID

states : Dict[str, str]

Block states

data : str | None = None

Block entity data

transform(rotation: int = 0, flip: Vec3bLike = bvec3(0, 0, 0)) None

Transforms this block.

Flips first, rotates second.

transformed(rotation: int = 0, flip: Vec3bLike = bvec3(0, 0, 0)) Block

Returns a transformed copy of this block.

Flips first, rotates second.

stateString() str

Returns a string containing the block states of this block, including the outer brackets.

__hash__ = None
__match_args__ = ('id', 'states', 'data')
static fromBlockStateTag(blockStateTag: TAG_Compound, blockEntityTag: TAG_Compound | None = None) Block

Parses a block state compound tag (as found in chunk palettes) into a Block.

If blockEntityTag is provided, it is parsed into the Block’s data attribute.

transformedBlockOrPalette(block: Block | Sequence[Block], rotation: int, flip: Vec3bLike) Block | Sequence[Block]

Convenience function that transforms a block or a palette of blocks.