diff --git a/Substrate/SubstrateCS/Source/AlphaBlock.cs b/Substrate/SubstrateCS/Source/AlphaBlock.cs
index 158d570..d531eef 100644
--- a/Substrate/SubstrateCS/Source/AlphaBlock.cs
+++ b/Substrate/SubstrateCS/Source/AlphaBlock.cs
@@ -142,6 +142,21 @@ namespace Substrate
_tileEntity = te;
}
+ public void CreateTileEntity ()
+ {
+ BlockInfoEx info = BlockInfo.BlockTable[_id] as BlockInfoEx;
+ if (info == null) {
+ throw new InvalidOperationException("The given block is of a type that does not support TileEntities.");
+ }
+
+ TileEntity te = TileEntityFactory.Create(info.TileEntityName);
+ if (te == null) {
+ throw new UnknownTileEntityException("The TileEntity type '" + info.TileEntityName + "' has not been registered with the TileEntityFactory.");
+ }
+
+ _tileEntity = te;
+ }
+
///
/// Removes any Tile Entity currently attached to the block.
///
diff --git a/Substrate/SubstrateCS/Source/AlphaBlockCollection.cs b/Substrate/SubstrateCS/Source/AlphaBlockCollection.cs
index d5b702f..83ecf47 100644
--- a/Substrate/SubstrateCS/Source/AlphaBlockCollection.cs
+++ b/Substrate/SubstrateCS/Source/AlphaBlockCollection.cs
@@ -171,77 +171,43 @@ namespace Substrate
SetTileEntity(x, y, z, block.GetTileEntity().Copy());
}
- #region IBlockCollection Members
+ #region IBoundedBlockCollection Members
- ///
- /// Gets the length of this collection's X-dimension.
- ///
+ ///
public int XDim
{
get { return _xdim; }
}
- ///
- /// Gets the length of this collection's Y-dimension.
- ///
+ ///
public int YDim
{
get { return _ydim; }
}
- ///
- /// Gets the length of this collection's Z-dimension.
- ///
+ ///
public int ZDim
{
get { return _zdim; }
}
- ///
- /// Returns an object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible object.
- ///
- IBlock IBlockCollection.GetBlock (int x, int y, int z)
+ IBlock IBoundedBlockCollection.GetBlock (int x, int y, int z)
{
return GetBlock(x, y, z);
}
- ///
- /// Returns a reference object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible reference object.
- ///
- IBlock IBlockCollection.GetBlockRef (int x, int y, int z)
+ IBlock IBoundedBlockCollection.GetBlockRef (int x, int y, int z)
{
return GetBlockRef(x, y, z);
}
- ///
- /// Updates a block in this collection with values from an object.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An object to copy block data from.
+ ///
public void SetBlock (int x, int y, int z, IBlock block)
{
SetID(x, y, z, block.ID);
}
- ///
- /// Gets information on the type of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// A object containing information of a block's type.
+ ///
public BlockInfo GetInfo (int x, int y, int z)
{
return BlockInfo.BlockTable[_blocks[x, y, z]];
@@ -252,13 +218,7 @@ namespace Substrate
return BlockInfo.BlockTable[_blocks[index]];
}
- ///
- /// Gets the ID (type) of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The ID (type) of the specified block.
+ ///
public int GetID (int x, int y, int z)
{
return _blocks[x, y, z];
@@ -269,13 +229,7 @@ namespace Substrate
return _blocks[index];
}
- ///
- /// Sets the ID (type) of a block at the given local coordinates, maintaining consistency of data.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The new ID of the block.
+ ///
/// Depending on the options set for this , this method can be very
/// heavy-handed in the amount of work it does to maintain consistency of tile entities, lighting, fluid, etc.
/// for the affected block and possibly many other indirectly-affected blocks in the collection or neighboring
@@ -345,11 +299,7 @@ namespace Substrate
SetID(x, y, z, id);
}
- ///
- /// Returns a count of all blocks in this with the given ID (type).
- ///
- /// The ID of blocks to count.
- /// A count of all matching blocks.
+ ///
public int CountByID (int id)
{
int c = 0;
@@ -365,54 +315,26 @@ namespace Substrate
#endregion
- #region IDataBlockContainer Members
+ #region IBoundedDataBlockContainer Members
- ///
- /// Returns an object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible object.
- ///
- IDataBlock IDataBlockCollection.GetBlock (int x, int y, int z)
+ IDataBlock IBoundedDataBlockCollection.GetBlock (int x, int y, int z)
{
return GetBlock(x, y, z);
}
- ///
- /// Returns a reference object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible reference object.
- ///
- IDataBlock IDataBlockCollection.GetBlockRef (int x, int y, int z)
+ IDataBlock IBoundedDataBlockCollection.GetBlockRef (int x, int y, int z)
{
return GetBlockRef(x, y, z);
}
- ///
- /// Updates a block in this collection with values from an object.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An object to copy block data from.
+ ///
public void SetBlock (int x, int y, int z, IDataBlock block)
{
SetID(x, y, z, block.ID);
SetData(x, y, z, block.Data);
}
- ///
- /// Gets the data value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The data value of the specified block.
+ ///
public int GetData (int x, int y, int z)
{
return _data[x, y, z];
@@ -423,13 +345,7 @@ namespace Substrate
return _data[index];
}
- ///
- /// Sets the data value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The new data value of the block.
+ ///
public void SetData (int x, int y, int z, int data)
{
if (_data[x, y, z] != data) {
@@ -452,12 +368,7 @@ namespace Substrate
}
}
- ///
- /// Returns a count of all blocks in this matching the given ID (type) and data value.
- ///
- /// The ID of blocks to count.
- /// The data value of blocks to count.
- /// A count of all matching blocks.
+ ///
public int CountByData (int id, int data)
{
int c = 0;
@@ -473,41 +384,19 @@ namespace Substrate
#endregion
- #region ILitBlockCollection Members
+ #region IBoundedLitBlockCollection Members
- ///
- /// Not Implemented.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible object.
- ///
- ILitBlock ILitBlockCollection.GetBlock (int x, int y, int z)
+ ILitBlock IBoundedLitBlockCollection.GetBlock (int x, int y, int z)
{
throw new NotImplementedException();
}
- ///
- /// Returns a reference object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible reference object.
- ///
- ILitBlock ILitBlockCollection.GetBlockRef (int x, int y, int z)
+ ILitBlock IBoundedLitBlockCollection.GetBlockRef (int x, int y, int z)
{
return GetBlockRef(x, y, z);
}
- ///
- /// Updates a block in this collection with values from an object.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An object to copy block data from.
+ ///
public void SetBlock (int x, int y, int z, ILitBlock block)
{
SetID(x, y, z, block.ID);
@@ -515,13 +404,7 @@ namespace Substrate
SetSkyLight(x, y, z, block.SkyLight);
}
- ///
- /// Gets the block-source light value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The block-source light value of the specified block.
+ ///
public int GetBlockLight (int x, int y, int z)
{
return _blockLight[x, y, z];
@@ -532,13 +415,7 @@ namespace Substrate
return _blockLight[index];
}
- ///
- /// Gets the sky-source light value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The sky-source light value of the specified block.
+ ///
public int GetSkyLight (int x, int y, int z)
{
return _skyLight[x, y, z];
@@ -549,13 +426,7 @@ namespace Substrate
return _skyLight[index];
}
- ///
- /// Sets the blocks-source light value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The new block-source light value of the block.
+ ///
public void SetBlockLight (int x, int y, int z, int light)
{
if (_blockLight[x, y, z] != light) {
@@ -572,13 +443,7 @@ namespace Substrate
}
}
- ///
- /// Sets the sky-source light value of a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The new sky-source light value of the block.
+ ///
public void SetSkyLight (int x, int y, int z, int light)
{
if (_skyLight[x, y, z] != light) {
@@ -595,34 +460,19 @@ namespace Substrate
}
}
- ///
- /// Gets the lowest Y-coordinate of a block at which sky-source light remains unfiltered.
- ///
- /// Local X-coordinate of a map location.
- /// Local Z-coordinate of a map location.
- /// The height-map value of a map location for calculating sky-source lighting.
+ ///
public int GetHeight (int x, int z)
{
return _heightMap[x, z];
}
- ///
- /// Sets the lowest Y-coordinate of a block at which sky-source light remains unfiltered.
- ///
- /// Local X-coordinate of a map location.
- /// Local Z-coordinate of a map location.
- /// The new height-map value of the given map location.
+ ///
public void SetHeight (int x, int z, int height)
{
_heightMap[x, z] = (byte)height;
}
- ///
- /// Updates the block-source lighting of a block at the given local coordinates to maintain light consistency.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
+ ///
/// The lighting of the block will be updated to be consistent with the lighting in neighboring blocks.
/// If the block is itself a light source, many nearby blocks may be updated to maintain consistent lighting. These
/// updates may also touch neighboring objects, if they can be resolved.
@@ -635,12 +485,7 @@ namespace Substrate
_dirty = true;
}
- ///
- /// Updates the sky-source lighting of a block at the given local coordinates to maintain light consistency.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
+ ///
/// The lighting of the block will be updated to be consistent with the lighting in neighboring blocks.
/// If the block is itself a light source, many nearby blocks may be updated to maintain consistent lighting. These
/// updates may also touch neighboring objects, if they can be resolved.
@@ -771,54 +616,26 @@ namespace Substrate
#endregion
- #region IPropertyBlockCollection Members
+ #region IBoundedPropertyBlockCollection Members
- ///
- /// Returns an object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible object.
- ///
- IPropertyBlock IPropertyBlockCollection.GetBlock (int x, int y, int z)
+ IPropertyBlock IBoundedPropertyBlockCollection.GetBlock (int x, int y, int z)
{
return GetBlock(x, y, z);
}
- ///
- /// Returns a reference object compatible with the interface from local coordinates relative to this collection.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An -compatible reference object.
- ///
- IPropertyBlock IPropertyBlockCollection.GetBlockRef (int x, int y, int z)
+ IPropertyBlock IBoundedPropertyBlockCollection.GetBlockRef (int x, int y, int z)
{
return GetBlockRef(x, y, z);
}
- ///
- /// Updates a block in this collection with values from an object.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// An object to copy block data from.
+ ///
public void SetBlock (int x, int y, int z, IPropertyBlock block)
{
SetID(x, y, z, block.ID);
SetTileEntity(x, y, z, block.GetTileEntity().Copy());
}
- ///
- /// Gets a record for a block at the given local coordinates, if one exists.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// A for the given block, or null if the is missing or the block type does not use a .
+ ///
public TileEntity GetTileEntity (int x, int y, int z)
{
return _tileEntityManager.GetTileEntity(x, y, z);
@@ -832,15 +649,7 @@ namespace Substrate
return _tileEntityManager.GetTileEntity(x, y, z);
}
- ///
- /// Sets a record for a block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// The to add to the given block.
- /// Thrown when the being passed is of the wrong type for the given block.
- /// Thrown when the given block is of a type that does not support a record.
+ ///
public void SetTileEntity (int x, int y, int z, TileEntity te)
{
_tileEntityManager.SetTileEntity(x, y, z, te);
@@ -856,14 +665,7 @@ namespace Substrate
_dirty = true;
}
- ///
- /// Creates a default record suitable for the block at the given local coordinates.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
- /// Thrown when the given block is of a type that does not support a record.
- /// Thrown when the block type requests a that has not been registered with the .
+ ///
public void CreateTileEntity (int x, int y, int z)
{
_tileEntityManager.CreateTileEntity(x, y, z);
@@ -879,12 +681,7 @@ namespace Substrate
_dirty = true;
}
- ///
- /// Clears any record set for a block at the givne local coordinates, if one exists.
- ///
- /// Local X-coordinate of a block.
- /// Local Y-coordinate of a block.
- /// Local Z-coordinate of a block.
+ ///
public void ClearTileEntity (int x, int y, int z)
{
_tileEntityManager.ClearTileEntity(x, y, z);
@@ -936,6 +733,263 @@ namespace Substrate
}
+ #region Unbounded Container Implementations
+
+ IBlock IBlockCollection.GetBlock (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlock(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ IBlock IBlockCollection.GetBlockRef (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockRef(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IBlockCollection.SetBlock (int x, int y, int z, IBlock block)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlock(x, y, z, block);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ BlockInfo IBlockCollection.GetInfo (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetInfo(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ int IBlockCollection.GetID (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetID(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IBlockCollection.SetID (int x, int y, int z, int id)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetID(x, y, z, id);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ IDataBlock IDataBlockCollection.GetBlock (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlock(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ IDataBlock IDataBlockCollection.GetBlockRef (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockRef(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IDataBlockCollection.SetBlock (int x, int y, int z, IDataBlock block)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlock(x, y, z, block);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ int IDataBlockCollection.GetData (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetData(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IDataBlockCollection.SetData (int x, int y, int z, int data)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetData(x, y, z, data);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ ILitBlock ILitBlockCollection.GetBlock (int x, int y, int z)
+ {
+ throw new NotImplementedException();
+ }
+
+ ILitBlock ILitBlockCollection.GetBlockRef (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockRef(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void ILitBlockCollection.SetBlock (int x, int y, int z, ILitBlock block)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlock(x, y, z, block);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ int ILitBlockCollection.GetBlockLight (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockLight(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void ILitBlockCollection.SetBlockLight (int x, int y, int z, int light)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlockLight(x, y, z, light);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ int ILitBlockCollection.GetSkyLight (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetSkyLight(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void ILitBlockCollection.SetSkyLight (int x, int y, int z, int light)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetSkyLight(x, y, z, light);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ int ILitBlockCollection.GetHeight (int x, int z)
+ {
+ if (x >= 0 && x < _xdim && z >= 0 && z < ZDim) {
+ return GetHeight(x, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : "z");
+ }
+
+ void ILitBlockCollection.SetHeight (int x, int z, int height)
+ {
+ if (x >= 0 && x < _xdim && z >= 0 && z < ZDim) {
+ SetHeight(x, z, height);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : "z");
+ }
+
+ void ILitBlockCollection.UpdateBlockLight (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ UpdateBlockLight(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void ILitBlockCollection.UpdateSkyLight (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ UpdateSkyLight(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ IPropertyBlock IPropertyBlockCollection.GetBlock (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlock(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ IPropertyBlock IPropertyBlockCollection.GetBlockRef (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockRef(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IPropertyBlockCollection.SetBlock (int x, int y, int z, IPropertyBlock block)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlock(x, y, z, block);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ TileEntity IPropertyBlockCollection.GetTileEntity (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetTileEntity(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IPropertyBlockCollection.SetTileEntity (int x, int y, int z, TileEntity te)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetTileEntity(x, y, z, te);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IPropertyBlockCollection.CreateTileEntity (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ CreateTileEntity(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IPropertyBlockCollection.ClearTileEntity (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ ClearTileEntity(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ AlphaBlock IAlphaBlockCollection.GetBlock (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlock(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ AlphaBlockRef IAlphaBlockCollection.GetBlockRef (int x, int y, int z)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ return GetBlockRef(x, y, z);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ void IAlphaBlockCollection.SetBlock (int x, int y, int z, AlphaBlock block)
+ {
+ if (x >= 0 && x < _xdim && y >= 0 && y < _ydim && z >= 0 && z < ZDim) {
+ SetBlock(x, y, z, block);
+ }
+ throw new ArgumentOutOfRangeException(x < 0 || x >= _xdim ? "x" : y < 0 || y >= _ydim ? "y" : "z");
+ }
+
+ #endregion
+
/*#region IEnumerable Members
public IEnumerator GetEnumerator ()
diff --git a/Substrate/SubstrateCS/Source/AlphaBlockRef.cs b/Substrate/SubstrateCS/Source/AlphaBlockRef.cs
index cfa18f3..b4dc9b9 100644
--- a/Substrate/SubstrateCS/Source/AlphaBlockRef.cs
+++ b/Substrate/SubstrateCS/Source/AlphaBlockRef.cs
@@ -140,6 +140,11 @@ namespace Substrate
_collection.SetTileEntity(_index, te);
}
+ public void CreateTileEntity ()
+ {
+ _collection.CreateTileEntity(_index);
+ }
+
///
/// Removes any Tile Entity currently attached to the block.
///
diff --git a/Substrate/SubstrateCS/Source/Core/BlockInterface.cs b/Substrate/SubstrateCS/Source/Core/BlockInterface.cs
index eb4dd91..5bf603a 100644
--- a/Substrate/SubstrateCS/Source/Core/BlockInterface.cs
+++ b/Substrate/SubstrateCS/Source/Core/BlockInterface.cs
@@ -107,59 +107,60 @@ namespace Substrate.Core
///
/// A basic unconstrained container of blocks.
///
+ /// The scope of coordinates is undefined for unconstrained block containers.
public interface IBlockCollection
{
///
/// Gets a basic block from a block container..
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// A basic from the collection at the given coordinates.
IBlock GetBlock (int x, int y, int z);
///
/// Gets a reference object to a basic within a block container.
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// A basic acting as a reference directly into the container at the given coordinates.
IBlock GetBlockRef (int x, int y, int z);
///
/// Updates a block in a block container with data from an existing object.
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// The to copy basic data from.
void SetBlock (int x, int y, int z, IBlock block);
///
/// Gets a block's id (type) from a block container.
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// The block id (type) from the block container at the given coordinates.
int GetID (int x, int y, int z);
///
/// Sets a block's id (type) within a block container.
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// The id (type) to assign to a block at the given coordinates.
void SetID (int x, int y, int z, int id);
///
/// Gets info and attributes on a block's type within a block container.
///
- /// The X-coordinate of a block.
- /// The Y-coordinate of a block.
- /// The Z-coordinate of a block.
+ /// The global X-coordinate of a block.
+ /// The global Y-coordinate of a block.
+ /// The global Z-coordinate of a block.
/// A instance for the block's type.
BlockInfo GetInfo (int x, int y, int z);
}
@@ -169,11 +170,85 @@ namespace Substrate.Core
///
public interface IBoundedBlockCollection : IBlockCollection
{
+ ///
+ /// Gets the length of the X-dimension of the container.
+ ///
int XDim { get; }
+
+ ///
+ /// Gets the length of the Y-dimension of the container.
+ ///
int YDim { get; }
+
+ ///
+ /// Gets the length of the Z-dimension of the container.
+ ///
int ZDim { get; }
+ ///
+ /// Counts all instances of a block with the given type in the container.
+ ///
+ /// The id (type) of the block to count.
+ /// The count of blocks in the container matching the given id (type).
int CountByID (int id);
+
+ #region Local Overrides
+
+ ///
+ /// Gets a basic block from a block container..
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// A basic from the collection at the given coordinates.
+ new IBlock GetBlock (int x, int y, int z);
+
+ ///
+ /// Gets a reference object to a basic within a block container.
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// A basic acting as a reference directly into the container at the given coordinates.
+ new IBlock GetBlockRef (int x, int y, int z);
+
+ ///
+ /// Updates a block in a block container with data from an existing object.
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// The to copy basic data from.
+ new void SetBlock (int x, int y, int z, IBlock block);
+
+ ///
+ /// Gets a block's id (type) from a block container.
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// The block id (type) from the block container at the given coordinates.
+ new int GetID (int x, int y, int z);
+
+ ///
+ /// Sets a block's id (type) within a block container.
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// The id (type) to assign to a block at the given coordinates.
+ new void SetID (int x, int y, int z, int id);
+
+ ///
+ /// Gets info and attributes on a block's type within a block container.
+ ///
+ /// The container-local X-coordinate of a block.
+ /// The container-local Y-coordinate of a block.
+ /// The container-local Z-coordinate of a block.
+ /// A instance for the block's type.
+ new BlockInfo GetInfo (int x, int y, int z);
+
+ #endregion
}
///
@@ -195,6 +270,14 @@ namespace Substrate.Core
///
public interface IBoundedDataBlockCollection : IDataBlockCollection, IBoundedBlockCollection
{
+ new IDataBlock GetBlock (int x, int y, int z);
+ new IDataBlock GetBlockRef (int x, int y, int z);
+
+ new void SetBlock (int x, int y, int z, IDataBlock block);
+
+ new int GetData (int x, int y, int z);
+ new void SetData (int x, int y, int z, int data);
+
int CountByData (int id, int data);
}
@@ -228,6 +311,25 @@ namespace Substrate.Core
///
public interface IBoundedLitBlockCollection : ILitBlockCollection, IBoundedBlockCollection
{
+ new ILitBlock GetBlock (int x, int y, int z);
+ new ILitBlock GetBlockRef (int x, int y, int z);
+
+ new void SetBlock (int x, int y, int z, ILitBlock block);
+
+ // Local Light
+ new int GetBlockLight (int x, int y, int z);
+ new int GetSkyLight (int x, int y, int z);
+
+ new void SetBlockLight (int x, int y, int z, int light);
+ new void SetSkyLight (int x, int y, int z, int light);
+
+ new int GetHeight (int x, int z);
+ new void SetHeight (int x, int z, int height);
+
+ // Update and propagate light at a single block
+ new void UpdateBlockLight (int x, int y, int z);
+ new void UpdateSkyLight (int x, int y, int z);
+
// Zero out light in entire collection
void ResetBlockLight ();
void ResetSkyLight ();
@@ -267,6 +369,16 @@ namespace Substrate.Core
///
public interface IBoundedPropertyBlockCollection : IPropertyBlockCollection, IBoundedBlockCollection
{
+ new IPropertyBlock GetBlock (int x, int y, int z);
+ new IPropertyBlock GetBlockRef (int x, int y, int z);
+
+ new void SetBlock (int x, int y, int z, IPropertyBlock block);
+
+ new TileEntity GetTileEntity (int x, int y, int z);
+ new void SetTileEntity (int x, int y, int z, TileEntity te);
+
+ new void CreateTileEntity (int x, int y, int z);
+ new void ClearTileEntity (int x, int y, int z);
}
///
@@ -285,6 +397,10 @@ namespace Substrate.Core
///
public interface IBoundedAlphaBlockCollection : IAlphaBlockCollection, IBoundedDataBlockCollection, IBoundedLitBlockCollection, IBoundedPropertyBlockCollection
{
+ new AlphaBlock GetBlock (int x, int y, int z);
+ new AlphaBlockRef GetBlockRef (int x, int y, int z);
+
+ new void SetBlock (int x, int y, int z, AlphaBlock block);
}
///