Skip to content
Freek Dijkstra edited this page Apr 29, 2012 · 9 revisions

nbt.chunk Module

Handles a single chunk of data (16x16x128 blocks) from a Minecraft save. Chunk is currently McRegion only.

*class nbt.chunk.Chunk(nbt)*

Bases: object

Class for representing a single chunk.

*__init__(nbt)*

*get_coords()*

Return the coordinates of this chunk.

*__repr__()*

Return a representation of this Chunk.

*class nbt.chunk.BlockArray(blocksBytes=None, dataBytes=None)*

Bases: object

Convenience class for dealing with a Block/data byte array.

*__init__(blocksBytes=None, dataBytes=None)*

Create a new BlockArray, defaulting to no block or data bytes.

*get_all_blocks()*

Return the blocks that are in this BlockArray.

*get_all_data()*

Return the data of all the blocks in this BlockArray.

*get_all_blocks_and_data()*

Return both blocks and data, packed together as tuples.

*get_blocks_struct()*

Return a dictionary with block ids keyed to (x, y, z).

*get_blocks_byte_array(buffer=False)*

Return a list of all blocks in this chunk.

*get_data_byte_array(buffer=False)*

Return a list of data for all blocks in this chunk.

*generate_heightmap(buffer=False, as_array=False)*

Return a heightmap, representing the highest solid blocks in this chunk.

*set_blocks(list=None, dict=None, fill_air=False)*

Sets all blocks in this chunk, using either a list or dictionary. Blocks not explicitly set can be filled to air by setting fill_air to True.

*set_block(x, y, z, id, data=0)*

Sets the block a x, y, z to the specified id, and optionally data.

*get_block(x, y, z, coord=False)*

Return the id of the block at x, y, z.

*get_data(x, y, z, coord=False)*

Return the data of the block at x, y, z.

*get_block_and_data(x, y, z, coord=False)*

Return the tuple of (id, data) for the block at x, y, z
Clone this wiki locally