59 const std::pair<AString, BlockState> &
block(
Vector3i aPos)
const;
Represents the state of a single block (previously known as "block meta").
Holds a palette that maps between block type + state and numbers.
Represents an area of blocks that are represented using a palette.
void setBlock(Vector3i aPos, const AString &aBlockTypeName, const BlockState &aBlockState)
Sets a single block using its full blockspec.
std::pair< UInt32, bool > maybePaletteIndex(const AString &aBlockTypeName, const BlockState &aBlockState) const
Returns the <index, true> into the palette that is used by the specified full blockspec.
const std::pair< AString, BlockState > & block(Vector3i aPos) const
Returns the full blockspec of the block at the specified position.
void crop(const cCuboid &aArea)
Crops this PBA by the specified coords.
Vector3i mSize
The size (dimensions) of the area.
std::vector< UInt32 > mBlocks
The blocks contained in the area, stored as indices into mPalette.
cCuboid whole() const
Returns a cCuboid that encompasses the entire PBA.
void fill(const AString &aBlockTypeName, const BlockState &aBlockState)
Fills the entire PBA with a single block of the specified type.
BlockTypePalette mPalette
The palette used in the area.
const BlockTypePalette & palette()
Returns the (reqd-only) palette used internally by this object.
PalettedBlockArea()
Creates a new uninitialized instance (all sizes zero).
const Vector3i & size() const
Returns the actual size of the area in all 3 axes.
UInt32 paletteIndex(const AString &aBlockTypeName, const BlockState &aBlockState)
Returns the index into the palette that is used by the specified full blockspec.
UInt32 blockPaletteIndex(Vector3i aPos) const
Returns the index into the palette for the block at the specified pos.
bool isPositionValid(Vector3i aPos) const
Returns true if the specified position is within the size bounds of the area.
void paste(const PalettedBlockArea &aSrc, Vector3i aDstOrigin=Vector3i())
Pastes (copies verbatim) the entire src PBA into this PBA.
void paste(const PalettedBlockArea &aSrc, const cCuboid &aSrcCuboid, Vector3i aDstOrigin=Vector3i())
Pastes (copies verbatim) a cCuboid out of the src PBA into this PBA.
UInt32 positionToIndex(Vector3i aPos) const
Converts the position to index in mBlocks.
const std::pair< AString, BlockState > & paletteEntry(UInt32 aPaletteIndex) const
Returns the blockspec represented by the specified palette index.
static PalettedBlockArea createFilled(Vector3i aSize, const AString &aBlockTypeName, const BlockState &aBlockState)
Creates a new PBA of the specified size filled with the specified block.