Builders#

Builders: functions that place whole parts of a structure in one call.

The builders are grouped by what they make:

They share these conventions:

  • They send their commands with the RCON client of the current thread (get_client()), so they work as soon as an Iwb has connected.

  • Positions are Vec3. Coordinates follow Minecraft: y is up, north is -z and east is +x.

  • Blocks are Block: an Item, a block state string such as "oak_stairs[facing=east]", or a BlockState.

  • Every function that places blocks returns the bounding box of those blocks as a Volume, ready to grab, render or clear. (Schematic.paste returns the box that the schematic covers.)

  • A command that the server rejects, for example for an unknown block or a position in an unloaded chunk, raises BuildError. Arguments that make no sense raise ValueError.

The other names work something out and place nothing, so they return their answer and not a Volume: ground_height() and ground_heights() (which ask the server), trace_path(), arch_profile(), stair_shapes(), slab_of(), full_block_of() and facing_name(), and the methods of Schematic that convert, transform, load and save.

Example:

from mciwb.imports import Item, Vec3, column, foundation, gable_roof

corner1, corner2 = Vec3(0, 70, 0), Vec3(8, 70, 6)
base = foundation(corner1, corner2, Item.COBBLESTONE)
for x, z in ((0, 0), (8, 0), (0, 6), (8, 6)):
    column(Vec3(x, 71, z), 4, Item.STRIPPED_OAK_LOG)
roof = gable_roof(
    corner1 + Vec3(0, 4, 0), corner2 + Vec3(0, 4, 0), Item.SPRUCE_STAIRS
)

Placing blocks

Placer

Place blocks, recording the bounding box of every block placed.

BuildError

The server rejected a building command.

Roofs

gable_roof

Build a gable (pitched) roof: two slopes of stairs that meet at a ridge.

hip_roof

Build a hip roof: four slopes of stairs, one from each side.

flat_roof

Build a flat roof: one layer of blocks, with an optional parapet.

Arches and columns

arch

Build an arch standing in a vertical wall plane.

arch_profile

Work out the shape of an arch, without building it.

column

Build a square column standing at base.

Stairways and roads

stairway

Build a stairway along a path, climbing between the heights of its points.

road

Build a road along a path, following the terrain.

trace_path

List the blocks along the middle of a path through some points.

PathStep

One block along the middle of a path.

Terrain and foundations

foundation

Build a foundation that follows the terrain, with a level top.

ground_height

Find the y of the top ground block of one column.

ground_heights

Find the y of the top ground block of each of a set of columns.

Heightmap

The Minecraft heightmaps: what counts as the ground.

Block states

Block is the type of every argument that takes a block.

BlockState

A block id, its block state properties and its block entity data.

facing_name

Give the block state name of a direction.

stair_shapes

Work out the shape that Minecraft gives each block in a layer of stairs.

slab_of

Find the slab made of the same material as a stairs block.

full_block_of

Find the full block made of the same material as a stairs block.

Schematics

DATA_VERSION is the Minecraft data version written in saved schematics.

Schematic

A box of blocks with their block states.