fCraft  0.638
Custom Minecraft Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events
fCraft.Map Class Reference

Represents a map file (associated with a world or not). Maps can be created blank (using Map constructor), generated terrain (using MapGenerator), or loaded from file (using fCraft.MapConversion.MapUtility). More...

+ Collaboration diagram for fCraft.Map:

Public Member Functions

void ResetSpawn ()
 Resets spawn to the default location (top center of the map).
 
 Map (World world, int width, int length, int height, bool initBlockArray)
 Creates an empty new map of given dimensions. Dimensions cannot be changed after creation.
 
bool Save ([NotNull] string fileName)
 Saves this map to a file in the default format (FCMv3).
 
int Index (int x, int y, int z)
 Converts given coordinates to a block array index.
 
int Index (Vector3I coords)
 Converts given coordinates to a block array index.
 
void SetBlock (int x, int y, int z, Block type)
 Sets a block in a safe way. Note that using SetBlock does not relay changes to players. Use QueueUpdate() for changing blocks on live maps/worlds.
 
void SetBlock (Vector3I coords, Block type)
 Sets a block at given coordinates. Checks bounds.
 
void SetBlock (int index, Block type)
 Sets a block at given coordinates.
 
Block GetBlock (int x, int y, int z)
 Gets a block at given coordinates. Checks bounds.
 
Block GetBlock (Vector3I coords)
 Gets a block at given coordinates. Checks bounds.
 
bool InBounds (int x, int y, int z)
 Checks whether the given coordinate (in block units) is within the bounds of the map.
 
bool InBounds (Vector3I vec)
 Checks whether the given coordinate (in block units) is within the bounds of the map.
 
void QueueUpdate (BlockUpdate update)
 Queues a new block update to be processed. Due to concurrent nature of the server, there is no guarantee that updates will be applied in any specific order.
 
void ClearUpdateQueue ()
 Clears all pending updates.
 
void CancelAllDrawOps ()
 Cancels and stops all active draw operations.
 
bool ConvertBlockTypes ([NotNull] byte[] mapping)
 Converts nonstandard (50-255) blocks using the given mapping.
 
bool RemoveUnknownBlocktypes ()
 Replaces all nonstandard (50-255) blocks with air.
 
short[,] ComputeHeightmap ()
 Calculates a 2D heightmap, based on the highest solid block for each column of blocks. Air, Brown/Red mushrooms, Glass, Leaves, Red/Yellow flowers, and Saplings are considered non-solid.
 
byte[] GetCompressedCopy ()
 Gets a compressed (GZip) copy of the map (raw block data with signed, 32bit, big-endian block count prepended). If the map has not been modified since last GetCompressedCopy call, returns a cached copy.
 
int SearchColumn (int x, int y, Block id)
 Searches the map, from top to bottom, for the first appearance of a given block.
 
int SearchColumn (int x, int y, Block id, int zStart)
 Searches the map, from top to bottom, for the first appearance of a given block.
 

Static Public Member Functions

static bool IsValidDimension (int dimension)
 Checks if a given map dimension (width, height, or length) is acceptable. Values between 1 and 2047 are technically allowed.
 
static bool IsRecommendedDimension (int dimension)
 Checks if a given map dimension (width, height, or length) is among the set of recommended values Recommended values are: 16, 32, 64, 128, 256, 512, 1024
 
static bool GetBlockByName ([NotNull] string blockName, bool allowNoneBlock, out Block block)
 Finds Block corresponding to given blockName.
 

Public Attributes

const MapFormat SaveFormat = MapFormat.FCMv3
 Current default map format for saving.
 
readonly int Width
 Map width, in blocks. Equivalent to Notch's X (horizontal).
 
readonly int Length
 Map length, in blocks. Equivalent to Notch's Z (horizontal).
 
readonly int Height
 Map height, in blocks. Equivalent to Notch's Y (vertical).
 
readonly BoundingBox Bounds
 Map boundaries. Can be useful for calculating volume or interesections.
 
readonly int Volume
 Map volume, in terms of blocks.
 
byte[] Blocks
 Array of map blocks. Use Index(x,y,h) to convert coordinates to array indices. Use QueueUpdate() for working on live maps to ensure that all players get updated.
 

Properties

World World [get, set]
 The world associated with this map, if any. May be null.
 
Position Spawn [get, set]
 Default spawning point on the map. A warning is logged when given coordinates are outside the map.
 
bool HasChangedSinceSave [get, set]
 Whether the map was modified since last time it was saved.
 
DateTime DateModified [get, set]
 
DateTime DateCreated [get, set]
 
Guid Guid [get, set]
 
MetadataCollection< string > Metadata [get, set]
 Map metadata, excluding zones.
 
ZoneCollection Zones [get, set]
 All zones within a map.
 
int UpdateQueueLength [get]
 Number of blocks that are waiting to be processed.
 
int DrawQueueLength [get]
 Number of active draw operations.
 
long DrawQueueBlockCount [get]
 Total estimated number of blocks left to process, from all draw operations combined.
 

Detailed Description

Represents a map file (associated with a world or not). Maps can be created blank (using Map constructor), generated terrain (using MapGenerator), or loaded from file (using fCraft.MapConversion.MapUtility).

Constructor & Destructor Documentation

fCraft.Map.Map ( World  world,
int  width,
int  length,
int  height,
bool  initBlockArray 
)

Creates an empty new map of given dimensions. Dimensions cannot be changed after creation.

Parameters
worldWorld that owns this map. May be null, and may be changed later.
widthWidth (horizontal, Notch's X).
lengthLength (horizontal, Notch's Z).
heightHeight (vertical, Notch's Y).
initBlockArrayIf true, the Blocks array will be created.
Exceptions
ArgumentOutOfRangeExceptionWidth, length, or height is not between 16 and 2048.
ArgumentExceptionMap volume exceeds Int32.MaxValue.

Member Function Documentation

void fCraft.Map.CancelAllDrawOps ( )

Cancels and stops all active draw operations.

void fCraft.Map.ClearUpdateQueue ( )

Clears all pending updates.

short [,] fCraft.Map.ComputeHeightmap ( )

Calculates a 2D heightmap, based on the highest solid block for each column of blocks. Air, Brown/Red mushrooms, Glass, Leaves, Red/Yellow flowers, and Saplings are considered non-solid.

Returns
A 2D array of same Width/Length as the map. Value at each coordinate corresponds to the highest solid point on the map.
bool fCraft.Map.ConvertBlockTypes ( [NotNull] byte[]  mapping)

Converts nonstandard (50-255) blocks using the given mapping.

Parameters
mappingByte array of length 256.
Returns
True if any blocks needed conversion/mapping.
Block fCraft.Map.GetBlock ( int  x,
int  y,
int  z 
)

Gets a block at given coordinates. Checks bounds.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
zZ coordinate (height, Notch's Y).
Returns
Block type, as a Block enumeration. Block.None if coordinates were out of bounds.
Block fCraft.Map.GetBlock ( Vector3I  coords)

Gets a block at given coordinates. Checks bounds.

Parameters
coordsCoordinate vector (X,Y,Z).
Returns
Block type, as a Block enumeration. Undefined if coordinates were out of bounds.
static bool fCraft.Map.GetBlockByName ( [NotNull] string  blockName,
bool  allowNoneBlock,
out Block  block 
)
static

Finds Block corresponding to given blockName.

Parameters
blockNameGiven block name to parse.
allowNoneBlockWhether "none" block type is acceptible.
blockBlock corresponding to given blockName; Block.Undefined if value could not be parsed.
Returns
True if given blockName was parsed as an acceptible block type.
Exceptions
ArgumentNullExceptionblockName is null.
byte [] fCraft.Map.GetCompressedCopy ( )

Gets a compressed (GZip) copy of the map (raw block data with signed, 32bit, big-endian block count prepended). If the map has not been modified since last GetCompressedCopy call, returns a cached copy.

bool fCraft.Map.InBounds ( int  x,
int  y,
int  z 
)

Checks whether the given coordinate (in block units) is within the bounds of the map.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
zZ coordinate (height, Notch's Y).
bool fCraft.Map.InBounds ( Vector3I  vec)

Checks whether the given coordinate (in block units) is within the bounds of the map.

Parameters
vecCoordinate vector (X,Y,Z).
int fCraft.Map.Index ( int  x,
int  y,
int  z 
)

Converts given coordinates to a block array index.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
zZ coordinate (height, Notch's Y).
Returns
Index of the block in Map.Blocks array.
int fCraft.Map.Index ( Vector3I  coords)

Converts given coordinates to a block array index.

Parameters
coordsCoordinate vector (X,Y,Z).
Returns
Index of the block in Map.Blocks array.
static bool fCraft.Map.IsRecommendedDimension ( int  dimension)
static

Checks if a given map dimension (width, height, or length) is among the set of recommended values Recommended values are: 16, 32, 64, 128, 256, 512, 1024

static bool fCraft.Map.IsValidDimension ( int  dimension)
static

Checks if a given map dimension (width, height, or length) is acceptable. Values between 1 and 2047 are technically allowed.

void fCraft.Map.QueueUpdate ( BlockUpdate  update)

Queues a new block update to be processed. Due to concurrent nature of the server, there is no guarantee that updates will be applied in any specific order.

bool fCraft.Map.RemoveUnknownBlocktypes ( )

Replaces all nonstandard (50-255) blocks with air.

Returns
True if any blocks needed replacement.
void fCraft.Map.ResetSpawn ( )

Resets spawn to the default location (top center of the map).

bool fCraft.Map.Save ( [NotNull] string  fileName)

Saves this map to a file in the default format (FCMv3).

Returns
Whether the saving succeeded.
int fCraft.Map.SearchColumn ( int  x,
int  y,
Block  id 
)

Searches the map, from top to bottom, for the first appearance of a given block.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
idBlock type to search for.
Returns
Height (Z coordinate; Notch's X) of the blocktype's first appearance. -1 if given blocktype was not found.
int fCraft.Map.SearchColumn ( int  x,
int  y,
Block  id,
int  zStart 
)

Searches the map, from top to bottom, for the first appearance of a given block.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
idBlock type to search for.
zStartStarting height. No blocks above this point will be checked.
Returns
Height (Z coordinate; Notch's X) of the blocktype's first appearance. -1 if given blocktype was not found.
void fCraft.Map.SetBlock ( int  x,
int  y,
int  z,
Block  type 
)

Sets a block in a safe way. Note that using SetBlock does not relay changes to players. Use QueueUpdate() for changing blocks on live maps/worlds.

Parameters
xX coordinate (width).
yY coordinate (length, Notch's Z).
zZ coordinate (height, Notch's Y).
typeBlock type to set.
void fCraft.Map.SetBlock ( Vector3I  coords,
Block  type 
)

Sets a block at given coordinates. Checks bounds.

Parameters
coordsCoordinate vector (X,Y,Z).
typeBlock type to set.
void fCraft.Map.SetBlock ( int  index,
Block  type 
)

Sets a block at given coordinates.

Parameters
indexIndex of the block (use map.Index(x,y,z)).
typeBlock type to set.

Member Data Documentation

byte [] fCraft.Map.Blocks

Array of map blocks. Use Index(x,y,h) to convert coordinates to array indices. Use QueueUpdate() for working on live maps to ensure that all players get updated.

readonly BoundingBox fCraft.Map.Bounds

Map boundaries. Can be useful for calculating volume or interesections.

readonly int fCraft.Map.Height

Map height, in blocks. Equivalent to Notch's Y (vertical).

readonly int fCraft.Map.Length

Map length, in blocks. Equivalent to Notch's Z (horizontal).

const MapFormat fCraft.Map.SaveFormat = MapFormat.FCMv3

Current default map format for saving.

readonly int fCraft.Map.Volume

Map volume, in terms of blocks.

readonly int fCraft.Map.Width

Map width, in blocks. Equivalent to Notch's X (horizontal).

Property Documentation

DateTime fCraft.Map.DateCreated
getset
DateTime fCraft.Map.DateModified
getset
long fCraft.Map.DrawQueueBlockCount
get

Total estimated number of blocks left to process, from all draw operations combined.

int fCraft.Map.DrawQueueLength
get

Number of active draw operations.

Guid fCraft.Map.Guid
getset
bool fCraft.Map.HasChangedSinceSave
getset

Whether the map was modified since last time it was saved.

MetadataCollection<string> fCraft.Map.Metadata
getset

Map metadata, excluding zones.

Position fCraft.Map.Spawn
getset

Default spawning point on the map. A warning is logged when given coordinates are outside the map.

int fCraft.Map.UpdateQueueLength
get

Number of blocks that are waiting to be processed.

World fCraft.Map.World
getset

The world associated with this map, if any. May be null.

ZoneCollection fCraft.Map.Zones
getset

All zones within a map.


The documentation for this class was generated from the following file: