gdpc.block_state_tools

Utilities for working with orientation-related block states.

You most likely don’t need to use this module directly: block transformations are already handled by the Block class.


AXIS_VALUES = ('x', 'y', 'z')

The possible values for the “axis” block state.

FACING_VALUES = ('up', 'down', 'north', 'east', 'south', 'west')

The possible values for the “facing” block state.

ROTATION_VALUES = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15')

The possible values for the “rotation” block state.

facingToRotation(facing: str) str

Converts facing to the corresponding “rotation” block state string.

rotationToFacing(rotation: str) str

Converts rotation to the nearest corresponding “facing” block state string.

vectorToAxis(vec: Vec3iLike) str

Returns the “axis” block state string corresponding to the direction vector vec.

axisToVector(axis: str) ivec3

Returns the direction vector corresponding to the “axis” block state string axis.

vectorToFacing(vec: Vec3iLike) str

Returns the “facing” block state string corresponding to the direction vector vec.

facingToVector(facing: str) ivec3

Returns the direction vector corresponding to the “facing” block state string facing.

rotationToVector(rotation: str) ivec3

Returns the axis-aligned direction vector corresponding to rotation.

rotateAxis(axis: str, rotation: int) str

Returns the rotated “axis” block state string.

transformAxis(axis: str, rotation: int = 0) str

Returns the transformed “axis” block state string.

rotateFacing(facing: str, rotation: int) str

Returns the rotated “facing” block state string.

flipFacing(facing: str, flip: Vec3bLike) str

Returns the flipped “facing” block state string.

transformFacing(facing: str, rotation: int = 0, flip: Vec3bLike = bvec3(0, 0, 0)) str

Returns the transformed “facing” block state string.

Flips first, rotates second.

invertFacing(facing: str) str

Returns the inverted “facing” block state string.

rotateRotation(blockStateRotation: str, rotation: int) str

Returns the rotated “rotation” block state string.

Yes, this name is confusing. blockStateRotation denotes a value of the “rotation” block state, as used by e.g. signs. rotation denotes a rotation as used by GDPC’s transformation system, so one of {0,1,2,3}. This function name is consistent with the other block state rotation functions.

flipRotation(rotation: str, flip: Vec3bLike) str

Returns the flipped “rotation” block state string.

transformRotation(blockStateRotation: str, rotation: int = 0, flip: Vec3bLike = bvec3(0, 0, 0)) str

Returns the transformed “rotation” block state string.

Flips first, rotates second.

invertHalf(half: str) str

Returns the inverted “half” block state string.

flipHalf(half: str, flip: Vec3bLike) str

Returns the flipped “half” block state string.

transformHalf(half: str, flip: Vec3bLike = bvec3(0, 0, 0)) str

Returns the transformed “half” block state string.