This class is used when multiple adjacent blocks are to be manipulated. Because of chunking
and multithreading, manipulating single blocks using cWorld:SetBlock() is a rather
time-consuming operation (locks for exclusive access need to be obtained, chunk lookup is done
for each block), so whenever you need to manipulate multiple adjacent blocks, it's better to wrap
the operation into a cBlockArea access. cBlockArea is capable of reading / writing across chunk
boundaries, has no chunk lookups for get and set operations and is not subject to multithreading
locking (because it is not shared among threads).
cBlockArea remembers its origin (MinX, MinY, MinZ coords in the Read() call) and therefore supports
absolute as well as relative get / set operations. Despite that, the contents of a cBlockArea can
be written back into the world at any coords.
Name | Parameters | Return value | Notes |
() (constructor) |
|
cBlockArea |
Creates a new empty cBlockArea object |
Clear |
|
|
Clears the object, resets it to zero size |
CopyFrom |
BlockAreaSrc |
|
Copies contents from BlockAreaSrc into self |
CopyTo |
BlockAreaDst |
|
Copies contents from self into BlockAreaDst. |
CountNonAirBlocks |
|
number |
Returns the count of blocks that are not air. Returns 0 if blocktypes not available. Block metas are ignored (if present, air with any meta is still considered air). |
CountSpecificBlocks |
BlockType |
number |
Counts the number of occurences of the specified blocktype contained in the area. |
CountSpecificBlocks |
BlockType, BlockMeta |
number |
Counts the number of occurrences of the specified blocktype + blockmeta combination contained in the area. |
Create |
SizeX, SizeY, SizeZ |
|
Initializes this BlockArea to an empty area of the specified size and origin of {0, 0, 0}. Datatypes are set to baTypes + baMetas. Any previous contents are lost. |
Create |
SizeX, SizeY, SizeZ, DataTypes |
|
Initializes this BlockArea to an empty area of the specified size and origin of {0, 0, 0}. Any previous contents are lost. |
Create |
Size |
|
Creates a new area of the specified size. Datatypes are set to baTypes + baMetas. Origin is set to all zeroes. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. |
Create |
Size, DataTypes |
|
Creates a new area of the specified size and contents. Origin is set to all zeroes. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. |
Crop |
AddMinX, SubMaxX, AddMinY, SubMaxY, AddMinZ, SubMaxZ |
|
Crops the specified number of blocks from each border. Modifies the size of this blockarea object. |
DumpToRawFile |
FileName |
|
Dumps the raw data into a file. For debugging purposes only. |
Expand |
SubMinX, AddMaxX, SubMinY, AddMaxY, SubMinZ, AddMaxZ |
|
Expands the specified number of blocks from each border. Modifies the size of this blockarea object. New blocks created with this operation are filled with zeroes. |
Fill |
DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight] |
|
Fills the entire block area with the same values, specified. Uses the DataTypes param to determine which content types are modified. |
FillRelCuboid |
MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight] |
|
Fills the specified cuboid with the same values (like Fill() ). |
FillRelCuboid |
RelCuboid, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight] |
|
Fills the specified cuboid (in relative coords) with the same values (like Fill() ). |
GetBlockLight |
BlockX, BlockY, BlockZ |
NIBBLETYPE |
Returns the blocklight at the specified absolute coords |
GetBlockMeta |
BlockX, BlockY, BlockZ |
NIBBLETYPE |
Returns the block meta at the specified absolute coords |
GetBlockSkyLight |
BlockX, BlockY, BlockZ |
NIBBLETYPE |
Returns the skylight at the specified absolute coords |
GetBlockType |
BlockX, BlockY, BlockZ |
BLOCKTYPE |
Returns the block type at the specified absolute coords |
GetBlockTypeMeta |
BlockX, BlockY, BlockZ |
BLOCKTYPE, NIBBLETYPE |
Returns the block type and meta at the specified absolute coords |
GetCoordRange |
|
MaxX, MaxY, MaxZ |
Returns the maximum relative coords in all 3 axes. See also GetSize(). |
GetDataTypes |
|
number |
Returns the mask of datatypes that the object is currently holding |
GetNonAirCropRelCoords |
[IgnoreBlockType] |
MinRelX, MinRelY, MinRelZ, MaxRelX, MaxRelY, MaxRelZ |
Returns the minimum and maximum coords in each direction for the first non-ignored block in each direction. If there are no non-ignored blocks within the area, or blocktypes are not present, the returned values are reverse-ranges (MinX <- m_RangeX, MaxX <- 0 etc.). IgnoreBlockType defaults to air. |
GetOrigin |
|
OriginX, OriginY, OriginZ |
Returns the origin coords of where the area was read from. |
GetOriginX |
|
number |
Returns the origin x-coord |
GetOriginY |
|
number |
Returns the origin y-coord |
GetOriginZ |
|
number |
Returns the origin z-coord |
GetRelBlockLight |
RelBlockX, RelBlockY, RelBlockZ |
NIBBLETYPE |
Returns the blocklight at the specified relative coords |
GetRelBlockMeta |
RelBlockX, RelBlockY, RelBlockZ |
NIBBLETYPE |
Returns the block meta at the specified relative coords |
GetRelBlockSkyLight |
RelBlockX, RelBlockY, RelBlockZ |
NIBBLETYPE |
Returns the skylight at the specified relative coords |
GetRelBlockType |
RelBlockX, RelBlockY, RelBlockZ |
BLOCKTYPE |
Returns the block type at the specified relative coords |
GetRelBlockTypeMeta |
RelBlockX, RelBlockY, RelBlockZ |
BLOCKTYPE, NIBBLETYPE |
Returns the block type and meta at the specified relative coords |
GetSize |
|
SizeX, SizeY, SizeZ |
Returns the size of the area in all 3 axes. See also GetCoordRange(). |
GetSizeX |
|
number |
Returns the size of the held data in the x-axis |
GetSizeY |
|
number |
Returns the size of the held data in the y-axis |
GetSizeZ |
|
number |
Returns the size of the held data in the z-axis |
GetVolume |
|
number |
Returns the volume of the area - the total number of blocks stored within. |
GetWEOffset |
|
Vector3i |
Returns the WE offset, a data value sometimes stored in the schematic files. Cuberite doesn't use this value, but provides access to it using this method. The default is {0, 0, 0}. |
HasBlockLights |
|
bool |
Returns true if current datatypes include blocklight |
HasBlockMetas |
|
bool |
Returns true if current datatypes include block metas |
HasBlockSkyLights |
|
bool |
Returns true if current datatypes include skylight |
HasBlockTypes |
|
bool |
Returns true if current datatypes include block types |
LoadFromSchematicFile |
FileName |
|
Clears current content and loads new content from the specified schematic file. Returns true if successful. Returns false and logs error if unsuccessful, old content is preserved in such a case. |
LoadFromSchematicString |
SchematicData |
|
Clears current content and loads new content from the specified string (assumed to contain .schematic data). Returns true if successful. Returns false and logs error if unsuccessful, old content is preserved in such a case. |
Merge |
BlockAreaSrc, RelX, RelY, RelZ, Strategy |
|
Merges BlockAreaSrc into this object at the specified relative coords, using the specified strategy |
Merge |
BlockAreaSrc, RelMinCoords, Strategy |
|
Merges BlockAreaSrc into this object at the specified relative coords, using the specified strategy |
MirrorXY |
|
|
Mirrors this block area around the XY plane. Modifies blocks' metas (if present) to match (i. e. furnaces facing the opposite direction). |
MirrorXYNoMeta |
|
|
Mirrors this block area around the XY plane. Doesn't modify blocks' metas. |
MirrorXZ |
|
|
Mirrors this block area around the XZ plane. Modifies blocks' metas (if present) |
MirrorXZNoMeta |
|
|
Mirrors this block area around the XZ plane. Doesn't modify blocks' metas. |
MirrorYZ |
|
|
Mirrors this block area around the YZ plane. Modifies blocks' metas (if present) |
MirrorYZNoMeta |
|
|
Mirrors this block area around the YZ plane. Doesn't modify blocks' metas. |
Read |
World, MinX, MaxX, MinY, MaxY, MinZ, MaxZ |
bool |
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
World, MinX, MaxX, MinY, MaxY, MinZ, MaxZ, DataTypes |
bool |
Reads the area from World, returns true if successful |
Read |
World, Point1, Point2 |
bool |
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
World, Point1, Point2, DataTypes |
bool |
Reads the area from World, returns true if successful |
Read |
World, Cuboid |
bool |
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
World, Cuboid, DataTypes |
bool |
Reads the area from World, returns true if successful |
RelLine |
RelX1, RelY1, RelZ1, RelX2, RelY2, RelZ2, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight] |
|
Draws a line between the two specified points. Sets only datatypes specified by DataTypes (baXXX constants). |
RelLine |
RelPoint1, RelPoint2, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight] |
|
Draws a line between the two specified points. Sets only datatypes specified by DataTypes (baXXX constants). |
RotateCCW |
|
|
Rotates the block area around the Y axis, counter-clockwise (east -> north). Modifies blocks' metas (if present) to match. |
RotateCCWNoMeta |
|
|
Rotates the block area around the Y axis, counter-clockwise (east -> north). Doesn't modify blocks' metas. |
RotateCW |
|
|
Rotates the block area around the Y axis, clockwise (north -> east). Modifies blocks' metas (if present) to match. |
RotateCWNoMeta |
|
|
Rotates the block area around the Y axis, clockwise (north -> east). Doesn't modify blocks' metas. |
SaveToSchematicFile |
FileName |
boolean |
Saves the current contents to a schematic file. Returns true if successful. |
SaveToSchematicString |
|
string |
Saves the current contents to a string (in a .schematic file format). Returns the data if successful, nil if failed. |
SetBlockLight |
BlockX, BlockY, BlockZ, BlockLight |
|
Sets the blocklight at the specified absolute coords |
SetBlockMeta |
BlockX, BlockY, BlockZ, BlockMeta |
|
Sets the block meta at the specified absolute coords |
SetBlockSkyLight |
BlockX, BlockY, BlockZ, SkyLight |
|
Sets the skylight at the specified absolute coords |
SetBlockType |
BlockX, BlockY, BlockZ, BlockType |
|
Sets the block type at the specified absolute coords |
SetBlockTypeMeta |
BlockX, BlockY, BlockZ, BlockType, BlockMeta |
|
Sets the block type and meta at the specified absolute coords |
SetOrigin |
OriginX, OriginY, OriginZ |
|
Resets the origin for the absolute coords. Only affects how absolute coords are translated into relative coords. |
SetOrigin |
Origin |
|
Resets the origin for the absolute coords. Only affects how absolute coords are translated into relative coords. |
SetRelBlockLight |
RelBlockX, RelBlockY, RelBlockZ, BlockLight |
|
Sets the blocklight at the specified relative coords |
SetRelBlockMeta |
RelBlockX, RelBlockY, RelBlockZ, BlockMeta |
|
Sets the block meta at the specified relative coords |
SetRelBlockSkyLight |
RelBlockX, RelBlockY, RelBlockZ, SkyLight |
|
Sets the skylight at the specified relative coords |
SetRelBlockType |
RelBlockX, RelBlockY, RelBlockZ, BlockType |
|
Sets the block type at the specified relative coords |
SetRelBlockTypeMeta |
RelBlockX, RelBlockY, RelBlockZ, BlockType, BlockMeta |
|
Sets the block type and meta at the specified relative coords |
SetWEOffset |
OffsetX, OffsetY, OffsetZ |
|
Sets the WE offset, a data value sometimes stored in the schematic files. Mostly used for WorldEdit. Cuberite doesn't use this value, but provides access to it using this method. |
SetWEOffset |
Offset |
|
Sets the WE offset, a data value sometimes stored in the schematic files. Mostly used for WorldEdit. Cuberite doesn't use this value, but provides access to it using this method. |
Write |
World, MinX, MinY, MinZ |
bool |
Writes the area into World at the specified coords, returns true if successful. baTypes and baMetas are written. |
Write |
World, MinX, MinY, MinZ, DataTypes |
bool |
Writes the area into World at the specified coords, returns true if successful |
Write |
World, MinPoint |
bool |
Writes the area into World at the specified coords, returns true if successful. baTypes and baMetas are written. |
Write |
World, MinPoint, DataTypes |
bool |
Writes the area into World at the specified coords, returns true if successful |
The strategy parameter specifies how individual blocks are combined together, using the table below.
For each strategy, evaluate the table rows from top downwards, the first match wins.