mciwb.render#
Render a region of a Minecraft world to an image, so that you (or an AI agent) can see what a build looks like without joining the game.
First read the blocks with scan, then draw them with render:
from mciwb.render import scan, render
grid = scan(Volume.from_corners(a, b), world_folder, client)
render(grid, views=["top", "iso", "south"]).save("build.png")
The views are:
top: a plan, north up, showing the highest block of each column. Higher blocks are lighter, and a block higher than its northern neighbour has a light edge (a lower one a dark edge).north,south,east,west: elevations, the region seen from that side, e.g.southlooks north at the south face. Nearer blocks are lighter.iso: a 3D isometric view from the south east, with shaded faces.iso_ne,iso_nwandiso_swlook from the other corners.
Translucent blocks (glass, water, ice) and small ones (torches, flowers, fences) let the blocks behind them show through. Each view has axis labels with world coordinates, unless you ask for none.
Members
the names of the views that |
|
The pixels per block that make view about 512 pixels across and no more than 512 pixels high, or that do so for every view if view is None |
|
Draw one or more views of a region side by side in one image. |
|
Draw one view of a region, see |
|
Read the blocks in a region of the world, by the fastest means available. |
- mciwb.render.VIEWS = ('top', 'south', 'north', 'east', 'west', 'iso', 'iso_se', 'iso_ne', 'iso_nw', 'iso_sw')#
the names of the views that
rendercan draw
- mciwb.render.scan(vol: Volume, world_folder: Path | None = None, client: Client | None = None, dimension: str = 'overworld', max_rcon_blocks: int = 32768) BlockGrid[source]#
Read the blocks in a region of the world, by the fastest means available.
If world_folder is a world, its region files are read directly, after asking the server (if client is given) to save its changes to disk. Otherwise the blocks are read over RCON with client, one at a time.
- Parameters:
vol – the region to read
world_folder – the server’s world folder, e.g.
~/mciwb-server/worldfor the server ofmciwb startclient – an RCON client for the running server
dimension – overworld, the_nether or the_end (world files only)
max_rcon_blocks – refuse to read larger regions over RCON
- Raises:
ValueError – if neither source can read the region
- mciwb.render.render(grid: BlockGrid, views: Sequence[str] = ('top', 'iso'), scale: int | None = None, labels: bool = True, palette: Palette | None = None) Image[source]#
Draw one or more views of a region side by side in one image.
- Parameters:
grid – the blocks, from
scanviews – the views to draw, see the module documentation, or the name of one view
scale – pixels per block for every view. By default each view gets its own scale, chosen to make it about 512 pixels across, or smaller if needed to keep the image under 1500 pixels wide
labels – add a title, axis labels and grid lines with world coordinates
palette – block colours, defaults to
mciwb.palette.default_palette
- Returns:
a Pillow image: call its
save("file.png")method to save it