Botcraft 1.21.4
Loading...
Searching...
No Matches
Botcraft::Chunk Class Reference

#include <Chunk.hpp>

Public Member Functions

 Chunk (const int min_y_, const unsigned int height_, const size_t dim_index, const bool has_sky_light_)
 
 Chunk (const Chunk &c)
 
int GetMinY () const
 
int GetHeight () const
 
bool GetModifiedSinceLastRender () const
 
void SetModifiedSinceLastRender (const bool b)
 
void LoadChunkData (const std::vector< unsigned char > &data)
 
void LoadChunkBlockEntitiesData (const std::vector< ProtocolCraft::BlockEntityInfo > &block_entities)
 
void SetBlockEntityData (const Position &pos, const ProtocolCraft::NBT::Value &block_entity)
 
void RemoveBlockEntityData (const Position &pos)
 
ProtocolCraft::NBT::Value GetBlockEntityData (const Position &pos) const
 
const BlockstateGetBlock (const Position &pos) const
 
void SetBlock (const Position &pos, const Blockstate *block)
 
void SetBlock (const Position &pos, const BlockstateId id)
 
unsigned char GetBlockLight (const Position &pos) const
 
void SetBlockLight (const Position &pos, const unsigned char v)
 
unsigned char GetSkyLight (const Position &pos) const
 
void SetSkyLight (const Position &pos, const unsigned char v)
 
size_t GetDimensionIndex () const
 
bool GetHasSkyLight () const
 
bool HasSection (const int y) const
 
void AddSection (const int y)
 
const BiomeGetBiome (const int x, const int y, const int z) const
 
const BiomeGetBiome (const int i) const
 
void SetBiomes (const std::vector< int > &new_biomes)
 
void SetBiome (const int x, const int y, const int z, const int new_biome)
 
void SetBiome (const int i, const int new_biome)
 
void LoadBiomesData (const std::vector< unsigned char > &data)
 
void UpdateNeighbour (Chunk *const neighbour, const Orientation direction)
 
void AddLoader (const std::thread::id &thread_id)
 Add a thread to the loaders list.
 
size_t RemoveLoader (const std::thread::id &thread_id)
 Remove a thread from the loaders list.
 

Static Public Member Functions

static Position BlockCoordsToChunkCoords (const Position &pos)
 

Private Member Functions

bool IsInsideChunk (const Position &pos, const bool ignore_gui_borders) const
 
void LoadSectionBiomeData (const int section_y, ProtocolCraft::ReadIterator &iter, size_t &length)
 

Private Attributes

std::vector< std::shared_ptr< Section > > sections
 
std::vector< unsigned char > biomes
 
std::unordered_map< Position, ProtocolCraft::NBT::Valueblock_entities_data
 
size_t dimension_index
 
bool has_sky_light
 
int min_y
 
int height
 
bool modified_since_last_rendered
 
std::unordered_set< std::thread::id > loaded_from
 

Detailed Description

Definition at line 24 of file Chunk.hpp.

Constructor & Destructor Documentation

◆ Chunk() [1/2]

Botcraft::Chunk::Chunk ( const int  min_y_,
const unsigned int  height_,
const size_t  dim_index,
const bool  has_sky_light_ 
)

Definition at line 22 of file Chunk.cpp.

References Botcraft::CHUNK_WIDTH, and Botcraft::SECTION_HEIGHT.

◆ Chunk() [2/2]

Botcraft::Chunk::Chunk ( const Chunk c)

Member Function Documentation

◆ AddLoader()

void Botcraft::Chunk::AddLoader ( const std::thread::id &  thread_id)

Add a thread to the loaders list.

Parameters
thread_idId of the thread

Definition at line 944 of file Chunk.cpp.

References loaded_from.

◆ AddSection()

void Botcraft::Chunk::AddSection ( const int  y)

Definition at line 690 of file Chunk.cpp.

References has_sky_light, and sections.

Referenced by SetBlock(), SetBlockLight(), and SetSkyLight().

◆ BlockCoordsToChunkCoords()

Position Botcraft::Chunk::BlockCoordsToChunkCoords ( const Position pos)
static

◆ GetBiome() [1/2]

const Biome * Botcraft::Chunk::GetBiome ( const int  i) const

◆ GetBiome() [2/2]

const Biome * Botcraft::Chunk::GetBiome ( const int  x,
const int  y,
const int  z 
) const

Definition at line 720 of file Chunk.cpp.

References GetBiome(), and min_y.

Referenced by GetBiome().

◆ GetBlock()

◆ GetBlockEntityData()

NBT::Value Botcraft::Chunk::GetBlockEntityData ( const Position pos) const

Definition at line 496 of file Chunk.cpp.

References block_entities_data.

◆ GetBlockLight()

unsigned char Botcraft::Chunk::GetBlockLight ( const Position pos) const

◆ GetDimensionIndex()

size_t Botcraft::Chunk::GetDimensionIndex ( ) const

Definition at line 675 of file Chunk.cpp.

References dimension_index.

◆ GetHasSkyLight()

bool Botcraft::Chunk::GetHasSkyLight ( ) const

Definition at line 680 of file Chunk.cpp.

References has_sky_light.

◆ GetHeight()

int Botcraft::Chunk::GetHeight ( ) const

Definition at line 87 of file Chunk.cpp.

References height.

◆ GetMinY()

int Botcraft::Chunk::GetMinY ( ) const

Definition at line 82 of file Chunk.cpp.

References min_y.

◆ GetModifiedSinceLastRender()

bool Botcraft::Chunk::GetModifiedSinceLastRender ( ) const

Definition at line 93 of file Chunk.cpp.

References modified_since_last_rendered.

◆ GetSkyLight()

◆ HasSection()

bool Botcraft::Chunk::HasSection ( const int  y) const

Definition at line 685 of file Chunk.cpp.

References sections.

◆ IsInsideChunk()

bool Botcraft::Chunk::IsInsideChunk ( const Position pos,
const bool  ignore_gui_borders 
) const
private

◆ LoadBiomesData()

void Botcraft::Chunk::LoadBiomesData ( const std::vector< unsigned char > &  data)

Definition at line 776 of file Chunk.cpp.

References LOG_WARNING, and Botcraft::SECTION_HEIGHT.

◆ LoadChunkBlockEntitiesData()

void Botcraft::Chunk::LoadChunkBlockEntitiesData ( const std::vector< ProtocolCraft::BlockEntityInfo > &  block_entities)

Definition at line 443 of file Chunk.cpp.

References Botcraft::CHUNK_WIDTH.

◆ LoadChunkData()

◆ LoadSectionBiomeData()

void Botcraft::Chunk::LoadSectionBiomeData ( const int  section_y,
ProtocolCraft::ReadIterator iter,
size_t &  length 
)
private

◆ RemoveBlockEntityData()

void Botcraft::Chunk::RemoveBlockEntityData ( const Position pos)

Definition at line 491 of file Chunk.cpp.

References block_entities_data.

◆ RemoveLoader()

size_t Botcraft::Chunk::RemoveLoader ( const std::thread::id &  thread_id)

Remove a thread from the loaders list.

Parameters
thread_idId of the thread
Returns
Number of remaining loaders

Definition at line 949 of file Chunk.cpp.

References loaded_from.

◆ SetBiome() [1/2]

void Botcraft::Chunk::SetBiome ( const int  i,
const int  new_biome 
)

Definition at line 760 of file Chunk.cpp.

References biomes, and modified_since_last_rendered.

◆ SetBiome() [2/2]

void Botcraft::Chunk::SetBiome ( const int  x,
const int  y,
const int  z,
const int  new_biome 
)

Definition at line 754 of file Chunk.cpp.

References min_y, and SetBiome().

Referenced by SetBiome().

◆ SetBiomes()

void Botcraft::Chunk::SetBiomes ( const std::vector< int > &  new_biomes)

◆ SetBlock() [1/2]

void Botcraft::Chunk::SetBlock ( const Position pos,
const Blockstate block 
)

◆ SetBlock() [2/2]

◆ SetBlockEntityData()

void Botcraft::Chunk::SetBlockEntityData ( const Position pos,
const ProtocolCraft::NBT::Value block_entity 
)

Definition at line 477 of file Chunk.cpp.

References block_entities_data, IsInsideChunk(), and modified_since_last_rendered.

◆ SetBlockLight()

void Botcraft::Chunk::SetBlockLight ( const Position pos,
const unsigned char  v 
)

◆ SetModifiedSinceLastRender()

void Botcraft::Chunk::SetModifiedSinceLastRender ( const bool  b)

Definition at line 98 of file Chunk.cpp.

References modified_since_last_rendered.

◆ SetSkyLight()

void Botcraft::Chunk::SetSkyLight ( const Position pos,
const unsigned char  v 
)

◆ UpdateNeighbour()

void Botcraft::Chunk::UpdateNeighbour ( Chunk *const  neighbour,
const Orientation  direction 
)

Member Data Documentation

◆ biomes

std::vector<unsigned char> Botcraft::Chunk::biomes
private

Definition at line 109 of file Chunk.hpp.

Referenced by Chunk(), GetBiome(), SetBiome(), and SetBiomes().

◆ block_entities_data

std::unordered_map<Position, ProtocolCraft::NBT::Value> Botcraft::Chunk::block_entities_data
private

Definition at line 111 of file Chunk.hpp.

Referenced by Chunk(), GetBlockEntityData(), RemoveBlockEntityData(), and SetBlockEntityData().

◆ dimension_index

size_t Botcraft::Chunk::dimension_index
private

Definition at line 113 of file Chunk.hpp.

Referenced by Chunk(), and GetDimensionIndex().

◆ has_sky_light

bool Botcraft::Chunk::has_sky_light
private

Definition at line 114 of file Chunk.hpp.

Referenced by AddSection(), Chunk(), GetHasSkyLight(), GetSkyLight(), and SetSkyLight().

◆ height

int Botcraft::Chunk::height
private

Definition at line 121 of file Chunk.hpp.

Referenced by Chunk(), GetHeight(), IsInsideChunk(), LoadChunkData(), SetBiomes(), and UpdateNeighbour().

◆ loaded_from

std::unordered_set<std::thread::id> Botcraft::Chunk::loaded_from
private

Definition at line 126 of file Chunk.hpp.

Referenced by AddLoader(), Chunk(), and RemoveLoader().

◆ min_y

◆ modified_since_last_rendered

bool Botcraft::Chunk::modified_since_last_rendered
private

◆ sections

std::vector<std::shared_ptr<Section> > Botcraft::Chunk::sections
private

The documentation for this class was generated from the following files: