mciwb.imports#

The names that a build script needs, in one place: import them from here.

A script, or a module that a script uses, imports what it needs with:

from mciwb.imports import Direction, Item, Vec3, get_world

A script run with mciwb run, and the mciwb shell session, already have every one of these names, plus world: the Iwb that is connected to the server. (A module that the script imports does not: it uses the import above, and get_world() for world.)

The names come from two places:

A few names are not here. Import Backup, MinecraftServer, Palette, PlayerNotInWorldError, set_client() and new_thread() from mciwb, and set_colour() from mciwb.palette.

The tables below list every name in mciwb.imports. Each name links to where it is documented: in this reference, or in the documentation of mcipc for the two names that come from that library.

World#

Iwb

The connection to a Minecraft world, for scripts and the shell.

get_world

Return the current world object: the most recently created one.

Client

An RCON client for Minecraft Java Edition that copes with the server's other RCON clients.

get_client

Get the RCON client of the current thread.

See Connect and world.

Positions, blocks and shapes#

Vec3

A position in the world, or an offset between two positions.

Direction

The six unit vectors, as Vec3.

Item

Minecraft Java Edition blocks and items.

Volume

A box of blocks in the world, with its sides along the axes.

Anchor3

Which point of a box a position refers to: one of its eight corners, the middle of its top or bottom face, or its centre.

polygon

Build a hollow prism with a regular polygon as its cross section: a tower, or with fill_item a floor.

See Positions and boxes, Items and Shapes. In short:

  • Vec3(x, y, z) is a position or an offset. Y is up. It supports +, - and * number.

  • Direction holds the unit vectors NORTH (0, 0, -1), SOUTH (0, 0, 1), EAST (1, 0, 0), WEST (-1, 0, 0), UP and DOWN. Direction.cardinals() lists the four compass directions.

  • Item has a member for every block and item of the Minecraft release that mciwb supports, for example Item.STONE_BRICKS.

  • Volume.from_corners(a, b) is a box of blocks, and its fill(client, item) fills it. Anchor3 says which corner or face of a box a position refers to, for example Anchor3.BOTTOM_NW.

  • polygon(client, center, height, diameter, sides=4, direction=UP, item=..., mode=FillMode.KEEP) builds a hollow prism.

Cuboids (frozen)#

Blocks

A cuboid of blocks placed in the world, which can then be moved and rotated.

grab

Read the blocks of a region of the world, one block at a time.

save_items

Save a cuboid, a profile (a 2D list) or a row (a list) of Item to a JSON file.

load_items

Load the items that save_items() saved.

Planes3d

The three planes that Blocks.rotate() can turn blocks in.

and Cuboid, the type of a 3D array of Item. Blocks(client, position, cuboid) places one in the world, and grab(client, vol) reads one.

See Cuboids (frozen). Schematic is their successor.

Command modes#

These come from mcipc. FillMode is the mode of polygon() and of Placer.fill().

FillMode

Available fill modes.

SetblockMode

Available modes to set blocks.

Builders#

Placer

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

BuildError

The server rejected a building command.

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.

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.

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.

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.

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.

Schematic

A box of blocks with their block states.

and two that are not functions or classes: Block, the type of every argument that takes a block, and DATA_VERSION, the Minecraft data version written in saved schematics.

See Builders.

Scan and render#

mciwb.render.scan

Read the blocks in a region of the world, by the fastest means available.

mciwb.render.render

Draw one or more views of a region side by side in one image.

BlockGrid

The blocks of a cuboid region of the world.

See Scan and render.

Interactive (frozen)#

Player

A player in the world, with their position and the way they are facing.

Monitor

A background thread that calls a list of functions again and again.

Switch

A lever, button, pressure plate or tripwire hook that calls a function.

Signs

Watch for command signs placed by one player, and call a function for each.

CopyPaste

Select a box of blocks in the world, then copy, fill or clear it.

Wall

Draw walls between pairs of points in the world.

WallMaker

Build walls interactively with command signs.

parse_nbt

Convert SNBT text, such as the reply to data get, to Python objects.

See Interactive (frozen).

Not in mciwb.imports#

A few names that scripts sometimes need are imported from elsewhere: