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. Most functions in this class come in pair, one that
works with the absolute coords (what the coords would have been in the original world the area was read
from) and one (usually with "Rel" in their name) that work on the relative coords (those range from
zero to Size - 1). Also note that most functions will raise an error if an out-of-range coord is
supplied to them.
Block entities stored inside a cBlockArea object have their position set to the relative position
within the area.
Calls to any setter of this class will not trigger simulator updates (lava, water, redstone).
Name | Parameters | Return value | Notes |
() (constructor) |
|
|
Creates a new empty cBlockArea object |
Clear |
|
|
Clears the object, resets it to zero size |
CopyFrom |
|
|
Copies contents from BlockAreaSrc into self |
CopyTo |
|
|
Copies contents from self into BlockAreaDst. |
CountNonAirBlocks |
|
|
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 |
|
|
Counts the number of occurences of the specified blocktype contained in the area. |
CountSpecificBlocks |
BlockType | number | BlockMeta | number |
|
|
Counts the number of occurrences of the specified blocktype + blockmeta combination contained in the area. |
Create |
|
|
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. |
Create |
|
|
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 |
SizeX | number | SizeY | number | SizeZ | number |
|
|
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 | number | SizeY | number | SizeZ | number | DataTypes | number |
|
|
Initializes this BlockArea to an empty area of the specified size and origin of {0, 0, 0}. Any previous contents are lost. |
Crop |
AddMinX | number | SubMaxX | number | AddMinY | number | SubMaxY | number | AddMinZ | number | SubMaxZ | number |
|
|
Crops the specified number of blocks from each border. Modifies the size of this blockarea object. |
DoWithBlockEntityAt |
BlockX | number | BlockY | number | BlockZ | number | Callback | function |
|
|
Calls the specified callback with the block entity at the specified absolute coords. The CallbackFunction has the following signature: function Callback(BlockEntity) Returns false if there's no block entity at the specified coords. Returns the value that the callback has returned otherwise. |
DoWithBlockEntityAt |
|
|
Calls the specified callback with the block entity at the specified absolute coords. The CallbackFunction has the following signature: function Callback(BlockEntity) Returns false if there's no block entity at the specified coords. Returns the value that the callback has returned otherwise. |
DoWithBlockEntityRelAt |
|
|
Calls the specified callback with the block entity at the specified relative coords. The CallbackFunction has the following signature: function Callback(BlockEntity) Returns false if there's no block entity at the specified coords. Returns the value that the callback has returned otherwise. |
DoWithBlockEntityRelAt |
RelX | number | RelY | number | RelZ | number | Callback | function |
|
|
Calls the specified callback with the block entity at the specified relative coords. The CallbackFunction has the following signature: function Callback(BlockEntity) Returns false if there's no block entity at the specified coords. Returns the value that the callback has returned otherwise. |
DumpToRawFile |
|
|
Dumps the raw data into a file. For debugging purposes only. |
Expand |
SubMinX | number | AddMaxX | number | SubMinY | number | AddMaxY | number | SubMinZ | number | AddMaxZ | number |
|
|
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 | number | BlockType | number | BlockMeta | number | BlockLight | number | BlockSkyLight | number |
|
|
Fills the entire block area with the same values, specified. Uses the DataTypes param to determine which content types are modified. |
FillRelCuboid |
RelCuboid | cCuboid | DataTypes | number | BlockType | number | BlockMeta | number | BlockLight | number | BlockSkyLight | number |
|
|
Fills the specified cuboid (in relative coords) with the same values (like Fill() ). |
FillRelCuboid |
MinRelX | number | MaxRelX | number | MinRelY | number | MaxRelY | number | MinRelZ | number | MaxRelZ | number | DataTypes | number | BlockType | number | BlockMeta | number | BlockLight | number | BlockSkyLight | number |
|
|
Fills the specified cuboid with the same values (like Fill() ). |
ForEachBlockEntity |
|
|
Calls the specified callback with the block entity for each block entity contained in the object. Returns true if all block entities have been processed (including when there are zero block entities), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature: function Callback(BlockEntity) The callback should return false or no value to continue with the next block entity, or true to abort the enumeration. |
GetBlockLight |
BlockX | number | BlockY | number | BlockZ | number |
|
|
Returns the blocklight (emissive light) at the specified absolute coords |
GetBlockMeta |
BlockX | number | BlockY | number | BlockZ | number |
|
|
Returns the block meta at the specified absolute coords |
GetBlockSkyLight |
BlockX | number | BlockY | number | BlockZ | number |
|
|
Returns the skylight at the specified absolute coords |
GetBlockType |
BlockX | number | BlockY | number | BlockZ | number |
|
|
Returns the block type at the specified absolute coords |
GetBlockTypeMeta |
BlockX | number | BlockY | number | BlockZ | number |
|
BlockType | number | BlockMeta | number |
|
Returns the block type and meta at the specified absolute coords |
GetBounds |
|
|
Returns the cuboid that specifies the original coords of the world from which the area was read. Basically constructs a cCuboid out of GetOrigin() and GetOrigin() + GetCoordRange(). |
GetCoordRange |
|
MaxX | number | MaxY | number | MaxZ | number |
|
Returns the maximum relative coords in all 3 axes. See also GetSize(). |
GetDataTypes |
|
|
Returns the mask of datatypes (ba* constants added together) that the object is currently holding. |
GetNonAirCropRelCoords |
|
MinRelX | number | MinRelY | number | MinRelZ | number | MaxRelX | number | MaxRelY | number | MaxRelZ | number |
|
Returns the minimum and maximum coords in each direction for the first block in each direction of type different to IgnoredBlockType (E_BLOCK_AIR by default). 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 | number | OriginY | number | OriginZ | number |
|
Returns the origin coords of where the area was read from. |
GetOriginX |
|
|
Returns the origin x-coord |
GetOriginY |
|
|
Returns the origin y-coord |
GetOriginZ |
|
|
Returns the origin z-coord |
GetRelBlockLight |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
|
Returns the blocklight at the specified relative coords |
GetRelBlockMeta |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
|
Returns the block meta at the specified relative coords |
GetRelBlockSkyLight |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
|
Returns the skylight at the specified relative coords |
GetRelBlockType |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
|
Returns the block type at the specified relative coords |
GetRelBlockTypeMeta |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
BLOCKTYPE | number | NIBBLETYPE | number |
|
Returns the block type and meta at the specified relative coords |
GetSize |
|
SizeX | number | SizeY | number | SizeZ | number |
|
Returns the size of the area in all 3 axes. See also GetCoordRange(). |
GetSizeX |
|
|
Returns the size of the held data in the x-axis |
GetSizeY |
|
|
Returns the size of the held data in the y-axis |
GetSizeZ |
|
|
Returns the size of the held data in the z-axis |
GetVolume |
|
|
Returns the volume of the area - the total number of blocks stored within. |
GetWEOffset |
|
|
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}. |
HasBlockEntities |
|
|
Returns true if current datatypes include block entities. |
HasBlockLights |
|
|
Returns true if current datatypes include blocklight |
HasBlockMetas |
|
|
Returns true if current datatypes include block metas |
HasBlockSkyLights |
|
|
Returns true if current datatypes include skylight |
HasBlockTypes |
|
|
Returns true if current datatypes include block types |
IsValidCoords |
BlockX | number | BlockY | number | BlockZ | number |
|
|
Returns true if the specified absolute coords are within the area. |
IsValidCoords |
|
|
Returns true if the specified absolute coords are within the area. |
IsValidDataTypeCombination |
|
|
(STATIC) Returns true if the specified combination of datatypes (ba* constants added together) is valid. Most combinations are valid, but for example baBlockEntities without baTypes is an invalid combination. |
IsValidRelCoords |
RelBlockX | number | RelBlockY | number | RelBlockZ | number |
|
|
Returns true if the specified relative coords are within the area. |
IsValidRelCoords |
|
|
Returns true if the specified relative coords are within the area. |
LoadFromSchematicFile |
|
|
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 |
|
|
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 | cBlockArea | RelMinCoords | number | Strategy | string |
|
|
Merges BlockAreaSrc into this object at the specified relative coords, using the specified strategy |
Merge |
BlockAreaSrc | cBlockArea | RelX | number | RelY | number | RelZ | number | Strategy | string |
|
|
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 |
|
|
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
|
|
Reads the area from World, returns true if successful. DataTypes is the sum of baXXX datatypes to be read |
Read |
|
|
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
World | cWorld | MinX | number | MaxX | number | MinY | number | MaxY | number | MinZ | number | MaxZ | number |
|
|
Reads the area from World, returns true if successful. baTypes and baMetas are read. |
Read |
World | cWorld | MinX | number | MaxX | number | MinY | number | MaxY | number | MinZ | number | MaxZ | number | DataTypes | number |
|
|
Reads the area from World, returns true if successful. DataTypes is a sum of baXXX datatypes to read. |
Read |
|
|
Reads the area from World, returns true if successful. DataTypes is a sum of baXXX datatypes to be read. |
RelLine |
RelPoint1 | Vector3i | RelPoint2 | Vector3i | DataTypes | number | BlockType | number | BlockMeta | number | BlockLight | number | BlockSkyLight | number |
|
|
Draws a line between the two specified points. Sets only datatypes specified by DataTypes (baXXX constants). |
RelLine |
RelX1 | number | RelY1 | number | RelZ1 | number | RelX2 | number | RelY2 | number | RelZ2 | number | DataTypes | number | BlockType | number | BlockMeta | number | BlockLight | number | BlockSkyLight | number |
|
|
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 |
|
|
Saves the current contents to a schematic file. Returns true if successful. |
SaveToSchematicString |
|
|
Saves the current contents to a string (in a .schematic file format). Returns the data if successful, nil if failed. |
SetBlockLight |
BlockX | number | BlockY | number | BlockZ | number | BlockLight | number |
|
|
Sets the blocklight at the specified absolute coords |
SetBlockMeta |
BlockX | number | BlockY | number | BlockZ | number | BlockMeta | number |
|
|
Sets the block meta at the specified absolute coords. |
SetBlockSkyLight |
BlockX | number | BlockY | number | BlockZ | number | BlockSkyLight | number |
|
|
Sets the skylight at the specified absolute coords |
SetBlockType |
BlockX | number | BlockY | number | BlockZ | number | BlockType | number |
|
|
Sets the block type at the specified absolute coords |
SetBlockTypeMeta |
BlockX | number | BlockY | number | BlockZ | number | BlockType | number | BlockMeta | number |
|
|
Sets the block type and meta at the specified absolute coords |
SetOrigin |
OriginX | number | OriginY | number | OriginZ | number |
|
|
Resets the origin for the absolute coords. Only affects how absolute coords are translated into relative coords. |
SetOrigin |
|
|
Resets the origin for the absolute coords. Only affects how absolute coords are translated into relative coords. |
SetRelBlockLight |
RelBlockX | number | RelBlockY | number | RelBlockZ | number | BlockLight | number |
|
|
Sets the blocklight at the specified relative coords |
SetRelBlockMeta |
RelBlockX | number | RelBlockY | number | RelBlockZ | number | BlockMeta | number |
|
|
Sets the block meta at the specified relative coords |
SetRelBlockSkyLight |
RelBlockX | number | RelBlockY | number | RelBlockZ | number | BlockSkyLight | number |
|
|
Sets the skylight at the specified relative coords |
SetRelBlockType |
RelBlockX | number | RelBlockY | number | RelBlockZ | number | BlockType | number |
|
|
Sets the block type at the specified relative coords |
SetRelBlockTypeMeta |
RelBlockX | number | RelBlockY | number | RelBlockZ | number | BlockType | number | BlockMeta | number |
|
|
Sets the block type and meta at the specified relative coords |
SetWEOffset |
|
|
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 |
OffsetX | number | OffsetY | number | OffsetZ | number |
|
|
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 |
|
|
Writes the area into World at the specified coords, returns true if successful. All present data types are written. |
Write |
|
|
Writes the area into World at the specified coords, returns true if successful. DataTypes is the sum of baXXX datatypes to write. |
Write |
World | cWorld | MinX | number | MinY | number | MinZ | number |
|
|
Writes the area into World at the specified coords, returns true if successful. All present data types are written. |
Write |
World | cWorld | MinX | number | MinY | number | MinZ | number | DataTypes | number |
|
|
Writes the area into World at the specified coords, returns true if successful. DataTypes is the sum of baXXX datatypes to write. |
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.