using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Mapping
{
///
/// Represent a chunk of terrain in a Minecraft world
///
public class Chunk
{
public const int SizeX = 16;
public const int SizeY = 16;
public const int SizeZ = 16;
///
/// Blocks contained into the chunk
///
private readonly Block[,,] blocks = new Block[SizeX, SizeY, SizeZ];
///
/// Read, or set the specified block
///
/// Block X
/// Block Y
/// Block Z
/// chunk at the given location
public Block this[int blockX, int blockY, int blockZ]
{
get
{
if (blockX < 0 || blockX >= SizeX)
throw new ArgumentOutOfRangeException("blockX", "Must be between 0 and " + (SizeX - 1) + " (inclusive)");
if (blockY < 0 || blockY >= SizeY)
throw new ArgumentOutOfRangeException("blockY", "Must be between 0 and " + (SizeY - 1) + " (inclusive)");
if (blockZ < 0 || blockZ >= SizeZ)
throw new ArgumentOutOfRangeException("blockZ", "Must be between 0 and " + (SizeZ - 1) + " (inclusive)");
return blocks[blockX, blockY, blockZ];
}
set
{
if (blockX < 0 || blockX >= SizeX)
throw new ArgumentOutOfRangeException("blockX", "Must be between 0 and " + (SizeX - 1) + " (inclusive)");
if (blockY < 0 || blockY >= SizeY)
throw new ArgumentOutOfRangeException("blockY", "Must be between 0 and " + (SizeY - 1) + " (inclusive)");
if (blockZ < 0 || blockZ >= SizeZ)
throw new ArgumentOutOfRangeException("blockZ", "Must be between 0 and " + (SizeZ - 1) + " (inclusive)");
blocks[blockX, blockY, blockZ] = value;
}
}
///
/// Get block at the specified location
///
/// Location, a modulo will be applied
/// The block
public Block GetBlock(Location location)
{
return this[location.ChunkBlockX, location.ChunkBlockY, location.ChunkBlockZ];
}
}
}