Beispiel #1
0
 public void SetBlock(Pos.BlockPos pos, Block b) //sets a block relative to a chunk
 {
     if (empty)
     {
         return;
     }
     pos = pos.Normalize();
     blocks[pos.X, pos.Y, pos.Z] = b;
 }
Beispiel #2
0
 public Block GetBlock(Pos.BlockPos pos) //returns a relative block from a chunk
 {
     if (empty)
     {
         return(null);
     }
     pos = pos.Normalize();
     return(blocks[pos.X, pos.Y, pos.Z]);
 }
Beispiel #3
0
        public Block GetBlock(Pos.BlockPos pos) //retrieves a block from anywhere in the world
        {
            Pos.ChunkPos p         = pos.ToChunk();
            Pos.ChunkPos regionPos = new Pos.BlockPos(p.X, p.Y, p.Z).ToChunk();
            string       region    = regionPos.X.ToString() + "." + regionPos.Y.ToString() + "." + regionPos.Z.ToString();

            if (Regions.ContainsKey(region))
            {
                Chunk c = Regions[region].GetChunk(p.Normalize());
                if (c != null)
                {
                    return(c.GetBlock(pos.Normalize()));
                }
            }
            return(null);
        }