mcpp
C++ Minecraft Library
mcpp::Chunk Struct Reference

#include <util.h>

Classes

struct  Iterator
 An iterator for the Chunk's 3D block data. More...
 

Public Member Functions

Iterator begin ()
 
Iterator end ()
 
 Chunk (const Coordinate &loc1, const Coordinate &loc2, const std::vector< BlockType > &block_list)
 
 ~Chunk ()
 
Chunkoperator= (const Chunk &other) noexcept
 
BlockType get_worldspace (const Coordinate &pos)
 
BlockType get (int x, int y, int z)
 
int x_len () const
 
int y_len () const
 
int z_len () const
 
Coordinate base_pt () const
 

Detailed Description

Stores a 3D cuboid of BlockTypes while preserving their relative location to the base point they were gathered at and each other.

Constructor & Destructor Documentation

◆ Chunk()

mcpp::Chunk::Chunk ( const Coordinate loc1,
const Coordinate loc2,
const std::vector< BlockType > &  block_list 
)

Initialized by copying from a flat vector of blocks

◆ ~Chunk()

mcpp::Chunk::~Chunk ( )

Member Function Documentation

◆ base_pt()

Coordinate mcpp::Chunk::base_pt ( ) const

Gets the minimum coordinate in the Chunk.

Returns
the minimum coordinate in the Chunk

◆ begin()

Iterator mcpp::Chunk::begin ( )
inline

◆ end()

Iterator mcpp::Chunk::end ( )
inline

◆ get()

BlockType mcpp::Chunk::get ( int  x,
int  y,
int  z 
)

Local equivalent of get_worldspace, equivalent to a 3D array access of the internal data.

Parameters
xx element of array access
yy element of array access
zz element of array access
Returns
BlockType at specified location

◆ get_worldspace()

BlockType mcpp::Chunk::get_worldspace ( const Coordinate pos)

Accesses the Minecraft block at absolute position pos and returns its BlockType if it is in the included area.

Parameters
posAbolute position in the Minecraft world to query BlockType for
Returns
BlockType at specified location

◆ operator=()

Chunk& mcpp::Chunk::operator= ( const Chunk other)
noexcept

◆ x_len()

int mcpp::Chunk::x_len ( ) const

Gets the x length of the Chunk.

Returns
x length of the Chunk

◆ y_len()

int mcpp::Chunk::y_len ( ) const

Gets the y length of the Chunk.

Returns
y length of the Chunk

◆ z_len()

int mcpp::Chunk::z_len ( ) const

Gets the z length of the Chunk.

Returns
z length of the Chunk

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