The Region class
- class litemapy.Region(x, y, z, width, height, length)
Represents a schematic region.
- Parameters:
x (int) – the X coordinate of the region in the schematic
y (int) – the Y coordinate of the region in the schematic
z (int) – the Z coordinate of the region in the schematic
width (int) – the size of the region along the x-axis (can be negative!)
height (int) – the size of the region along the y-axis (can be negative!)
length (int) – the size of the region along the z-axis (can be negative!)
- Raises:
ValueError – if either width, height or length is 0
- allblockpos()
- as_schematic(name='Unnamed', author='', description='', mc_version=2975)
Creates a schematic that contains that region at the origin.
- filter(function)
Replaces all occurrences of
BlockStatewith others by providing a mapping function. This method works with the palette directly and the mapping function is therefore only called once per block state type in the region, and not for every position. This is a lot faster than manually iterating over region coordinates.- Parameters:
function ((BlockState) -> BlockState) – a mapping function
- static from_sponge_nbt(nbt)
Returns a Litematica Region based on an NBT Compound that conforms to the Sponge Schematic Format (version 2) used by mods like WorldEdit. Check the file format specification for more information.
- Parameters:
nbt (nbtlib.tag.Compound) – The Sponge schematic NBT Compound.
- Returns:
a Litematica Region built from the Sponge schematic and the Minecraft data version that the Sponge schematic was created for.
- Return type:
- static from_structure_nbt(structure)
Returns a Litematica Region based on an NBT Compound that conforms to Minecraft’s structure NBT files.
- static fromnbt(nbt)
Read a region from an NBT tag.
- getblock(x, y, z)
Get a
BlockStatein the region.- Parameters:
- Return type:
- getblockcount()
Counts the number of blocks in the region.
- Returns:
the number of non-air blocks in the region
- Return type:
- maxschemx()
- Returns:
the maximum X coordinate of this region in the schematics coordinate system
- Return type:
- maxschemy()
- Returns:
the maximum Y coordinate of this region in the schematics coordinate system
- Return type:
- maxschemz()
- Returns:
the maximum Z coordinate of this region in the schematics coordinate system
- Return type:
- maxx()
- Returns:
the maximum X coordinate of this region in its own coordinate system
- Return type:
- maxy()
- Returns:
the maximum Y coordinate of this region in its own coordinate system
- Return type:
- maxz()
- Returns:
the maximum Z coordinate of this region in its own coordinate system
- Return type:
- minschemx()
- Returns:
the minimum X coordinate of this region in the schematics coordinate system
- Return type:
- minschemy()
- Returns:
the minimum Y coordinate of this region in the schematics coordinate system
- Return type:
- minschemz()
- Returns:
the minimum Z coordinate of this region in the schematics coordinate system
- Return type:
- minx()
- Returns:
the minimum X coordinate of this region in its own coordinate system
- Return type:
- miny()
- Returns:
the minimum Y coordinate of this region in its own coordinate system
- Return type:
- minz()
- Returns:
the minimum Z coordinate of this region in its own coordinate system
- Return type:
- property palette
The palette used to store blocks within the region. Each entry in the palette is assured to be unique. Expected the first palette entry which is always “minecraft:air”, each entry is assured to have at least one instance in the region.
- Type:
- setblock(x, y, z, block)
Set a
BlockStatein the region.- Parameters:
x (int) – the X coordinate to set the block at
y (int) – the Y coordinate to set the block at
z (int) – the Z coordinate to set the block at
block (BlockState) – the new block state
- property tile_entities
The tile entities within the region.
- Type:
- to_sponge_nbt(mc_version=2975, gzipped=True, endianness='big')
Returns the Region as an NBT Compound file that conforms to the Sponge Schematic Format (version 2) used by mods like WorldEdit. Check the file format specification for more information.
- Parameters:
mc_version (int) – Minecraft data version that is being emulated (https://minecraft.wiki/w/Data_version). Should not be critical for newer versions of Minecraft.
gzipped (bool) – Whether the NBT Compound file should be compressed (WorldEdit only works with gzipped files).
endianness (str) – Endianness of the resulting NBT Compound file (‘big’ or ‘little’, WorldEdit only works with big endian files).
- Returns:
The Region represented as a Sponge Schematic NBT Compound file.
- Return type:
- to_structure_nbt(mc_version=2975, gzipped=True, byteorder='big')
Returns the Region as an NBT Compound file that conforms to Minecraft’s structure NBT files.
- Parameters:
mc_version (int) – Minecraft data version that is being emulated (https://minecraft.wiki/w/Data_version). Should not be critical for newer versions of Minecraft.
gzipped (bool) – Whether the NBT Compound file should be compressed (Vanilla Minecraft only works with gzipped files).
byteorder (str) – Endianness of the resulting NBT Compound file (‘big’ or ‘little’, Vanilla Minecraft only works with big endian files).
- Returns:
The Region represented as a Minecraft structure NBT file.
- Return type:
- property x
The X coordinate of the region within the schematic’s coordinate system. This property is read only.
- Type:
- xrange()
- Returns:
the range of coordinates this region contains along its X axis
- Return type:
- property y
The Y coordinate of the region within the schematic’s coordinate system. This property is read only.
- Type:
- yrange()
- Returns:
the range of coordinates this region contains along its Y axis
- Return type:
- property z
The Z coordinate of the region within the schematic’s coordinate system. The property is read only.
- Type: