Stairways and roads#
Stairways and roads along a path.
A path is a polyline: a list of points, where each straight section runs along x or along z (not diagonally). Turn corners by adding a point at the corner. The path is the line of blocks that people walk on top of, and it is width blocks wide, centred on the line (an even width has its extra block on the right, looking along the path).
stairway() builds at the heights of its points,
climbing between them. road() ignores their heights
and lays its blocks in the ground, following the terrain. Both return the
bounding box of the blocks they placed, as a Volume.
trace_path() gives the blocks along the middle of a
path without building anything.
The middle and the outside of a wide path climb one block at a time round a corner, but the inside of the corner is shorter, so it climbs too steeply to walk up. For a wide stairway that is easy to walk all the way across, make it level for a few blocks either side of each corner.
- mciwb.builders.stairway(points, stairs=Item.STONE_BRICK_STAIRS, *, landing=None, width=1, support=None, clearance=0)[source]#
Build a stairway along a path, climbing between the heights of its points.
Each point is a block of the walkway, the block that people stand on, so the walkway’s surface is one block above it. Each section between two points climbs (or descends) at most one block for each block along it. Where a block is higher than the one before it there is a stairs block (facing the way up), elsewhere a level landing block. So points at the same height give a level path.
The path may pass over itself, as in a spiral staircase round a tower or a switchback: each pass gets its own blocks. Choose the points so that there is headroom between one pass and the next one above it.
For example, from (0, 64, 0) east to (4, 66, 0):
◢ # y = 66: stairs, then a landing at the end ◢ # y = 65: stairs, landing # y = 64: a landing at the start
- Parameters:
points (Sequence[Vec3]) -- The walkway blocks at the start, each corner and the end. Each section runs along x or along z, see
trace_path().stairs (Item | str | BlockState) -- The stairs to climb with.
landing (Item | str | BlockState | None) -- The block for the level parts. Defaults to the full block matching stairs, from
full_block_of():Item.STONE_BRICKSfor the default stairs.width (int) -- The width of the stairway, in blocks. It is centred on the path, and an even width has its extra block on the right, looking along the path.
support (Item | str | BlockState | None) -- If given, fill the space under the stairway with this block, down to the height of its lowest block (only replacing air). Where the stairway passes over itself, the support stops above the headroom of the pass below. By default nothing is built under the stairway.
clearance (int) -- Set this many blocks above the walkway to air, to make headroom through the terrain. The default, 0, clears nothing.
- Returns:
The bounding box of the stairway, including its support and the space it cleared.
- Raises:
ValueError -- If the path is not valid (see
trace_path()), width is less than 1, or landing is not given and stairs is not a stairs block with a matching full block.BuildError -- If the server rejects a command, for example for an unknown block or an unloaded chunk.
- Return type:
Example:
from mciwb.imports import Item, Vec3, stairway # up 4 blocks going east, a level corner, then up 3 going south steps = stairway( [Vec3(0, 64, 0), Vec3(5, 68, 0), Vec3(7, 68, 0), Vec3(7, 71, 4)], Item.SANDSTONE_STAIRS, width=2, support=Item.SANDSTONE, clearance=3, )
- mciwb.builders.road(points, block=Item.DIRT_PATH, *, width=3, border=None, clearance=2, heightmap=Heightmap.MOTION_BLOCKING_NO_LEAVES)[source]#
Build a road along a path, following the terrain.
Each block of the road replaces the top ground block of its column, so the road does not smooth the terrain: it steps up and down with it. Use
stairway()for a path at fixed heights.The ground is read with
ground_heights(), so every column of the road must be in a loaded chunk.- Parameters:
points (Sequence[Vec3]) -- The start, each corner and the end of the road, as
Vec3. Their y is ignored. Each section runs along x or along z, seetrace_path().block (Item | str | BlockState) -- The road surface.
width (int) -- The width of the road, in blocks. It is centred on the path, and an even width has its extra block on the right, looking along the path.
border (Item | str | BlockState | None) -- If given, the block along both edges of the road, in place of block. The edges are part of the width, so a road less than 3 wide is all border.
clearance (int) -- Set this many blocks above the road to air, clearing grass, flowers and snow. 0 clears nothing.
heightmap (Heightmap | str) -- What counts as the ground: a
Heightmapor its name. The default ignores leaves, but the road goes over the top of water.
- Returns:
The bounding box of the road and the space it cleared.
- Raises:
ValueError -- If the path is not valid (see
trace_path()), width is less than 1, or heightmap is not the name of a heightmap.BuildError -- If a column of the road is not in a loaded chunk, or the server rejects a command, for example for an unknown block.
- Return type:
Example:
from mciwb.imports import Item, Vec3, road # the y of the points does not matter path = [Vec3(0, 0, 0), Vec3(20, 0, 0), Vec3(20, 0, 15)] road(path, Item.GRAVEL, width=5, border=Item.COBBLESTONE)
- mciwb.builders.trace_path(points)[source]#
List the blocks along the middle of a path through some points.
The heights of the blocks are spread evenly between the heights of the points. In a section that climbs (or descends) by less than its length, the last block before each point (the first block after it, when descending) stays level, so that a corner is a landing.
Nothing is sent to the server.
stairway()androad()use this to follow their paths.- Parameters:
points (Sequence[Vec3]) -- The start of the path, each corner and the end, in order. Each section between two points runs along x or along z, and climbs or descends at most one block for each block along it. Positions are rounded down to whole blocks, and a point that repeats the one before it is ignored.
- Returns:
One
PathStepfor each block of the path, from the first point to the last.- Raises:
ValueError -- If there are fewer than two points, a section is diagonal or vertical, a section climbs or descends more than one block for each block along it, or all the points are the same block.
- Return type:
Example
>>> steps = trace_path([Vec3(0, 64, 0), Vec3(4, 66, 0)]) >>> [tuple(step.pos) for step in steps] [(0, 64, 0), (1, 65, 0), (2, 65, 0), (3, 66, 0), (4, 66, 0)] >>> steps[1].direction Vec3(x=1, y=0, z=0)
- class mciwb.builders.PathStep(pos, direction)[source]#
One block along the middle of a path.
trace_path()returns a list of these, in order along the path.