![]() |
Botcraft 1.21.4
|
#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 Blockstate * | GetBlock (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 Biome * | GetBiome (const int x, const int y, const int z) const |
const Biome * | GetBiome (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::Value > | block_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 |
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.
Botcraft::Chunk::Chunk | ( | const Chunk & | c | ) |
Definition at line 45 of file Chunk.cpp.
References biomes, block_entities_data, dimension_index, has_sky_light, height, loaded_from, min_y, Botcraft::SECTION_HEIGHT, and sections.
void Botcraft::Chunk::AddLoader | ( | const std::thread::id & | thread_id | ) |
Add a thread to the loaders list.
thread_id | Id of the thread |
Definition at line 944 of file Chunk.cpp.
References loaded_from.
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().
Definition at line 73 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH, Botcraft::Vector3< T >::x, and Botcraft::Vector3< T >::z.
Referenced by Botcraft::Renderer::RenderingManager::Handle().
const Biome * Botcraft::Chunk::GetBiome | ( | const int | i | ) | const |
Definition at line 726 of file Chunk.cpp.
References biomes, Botcraft::AssetsManager::GetBiome(), and Botcraft::AssetsManager::getInstance().
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().
const Blockstate * Botcraft::Chunk::GetBlock | ( | const Position & | pos | ) | const |
Definition at line 507 of file Chunk.cpp.
References Botcraft::Section::CoordsToBlockIndex(), Botcraft::AssetsManager::GetBlockstate(), Botcraft::AssetsManager::getInstance(), IsInsideChunk(), min_y, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by Botcraft::World::UpdateChunk(), and UpdateNeighbour().
NBT::Value Botcraft::Chunk::GetBlockEntityData | ( | const Position & | pos | ) | const |
Definition at line 496 of file Chunk.cpp.
References block_entities_data.
unsigned char Botcraft::Chunk::GetBlockLight | ( | const Position & | pos | ) | const |
Definition at line 582 of file Chunk.cpp.
References Botcraft::Section::CoordsToLightIndex(), IsInsideChunk(), min_y, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
size_t Botcraft::Chunk::GetDimensionIndex | ( | ) | const |
Definition at line 675 of file Chunk.cpp.
References dimension_index.
bool Botcraft::Chunk::GetHasSkyLight | ( | ) | const |
Definition at line 680 of file Chunk.cpp.
References has_sky_light.
int Botcraft::Chunk::GetHeight | ( | ) | const |
bool Botcraft::Chunk::GetModifiedSinceLastRender | ( | ) | const |
Definition at line 93 of file Chunk.cpp.
References modified_since_last_rendered.
unsigned char Botcraft::Chunk::GetSkyLight | ( | const Position & | pos | ) | const |
Definition at line 628 of file Chunk.cpp.
References Botcraft::Section::CoordsToLightIndex(), has_sky_light, IsInsideChunk(), min_y, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
bool Botcraft::Chunk::HasSection | ( | const int | y | ) | const |
|
private |
Definition at line 955 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH, height, min_y, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by GetBlock(), GetBlockLight(), GetSkyLight(), SetBlock(), SetBlockEntityData(), SetBlockLight(), and SetSkyLight().
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.
void Botcraft::Chunk::LoadChunkBlockEntitiesData | ( | const std::vector< ProtocolCraft::BlockEntityInfo > & | block_entities | ) |
Definition at line 443 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH.
void Botcraft::Chunk::LoadChunkData | ( | const std::vector< unsigned char > & | data | ) |
Definition at line 314 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH, Botcraft::GlobalPalette, height, LoadSectionBiomeData(), LOG_WARNING, min_y, modified_since_last_rendered, Botcraft::SECTION_HEIGHT, Botcraft::SectionPalette, sections, SetBlock(), Botcraft::SingleValue, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by Botcraft::World::LoadDataInChunk().
|
private |
Definition at line 975 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH, Botcraft::GlobalPalette, Botcraft::SECTION_HEIGHT, Botcraft::SectionPalette, and Botcraft::SingleValue.
Referenced by LoadChunkData().
void Botcraft::Chunk::RemoveBlockEntityData | ( | const Position & | pos | ) |
Definition at line 491 of file Chunk.cpp.
References block_entities_data.
size_t Botcraft::Chunk::RemoveLoader | ( | const std::thread::id & | thread_id | ) |
Remove a thread from the loaders list.
thread_id | Id of the thread |
Definition at line 949 of file Chunk.cpp.
References loaded_from.
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.
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().
void Botcraft::Chunk::SetBiomes | ( | const std::vector< int > & | new_biomes | ) |
Definition at line 736 of file Chunk.cpp.
References biomes, height, LOG_ERROR, modified_since_last_rendered, and Botcraft::SECTION_HEIGHT.
void Botcraft::Chunk::SetBlock | ( | const Position & | pos, |
const Blockstate * | block | ||
) |
Definition at line 530 of file Chunk.cpp.
References Botcraft::Blockstate::GetId(), and SetBlock().
Referenced by LoadChunkData(), SetBlock(), Botcraft::World::UpdateChunk(), and UpdateNeighbour().
void Botcraft::Chunk::SetBlock | ( | const Position & | pos, |
const BlockstateId | id | ||
) |
Definition at line 546 of file Chunk.cpp.
References AddSection(), Botcraft::Section::CoordsToBlockIndex(), IsInsideChunk(), min_y, modified_since_last_rendered, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
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.
void Botcraft::Chunk::SetBlockLight | ( | const Position & | pos, |
const unsigned char | v | ||
) |
Definition at line 598 of file Chunk.cpp.
References AddSection(), Botcraft::Section::CoordsToLightIndex(), IsInsideChunk(), min_y, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
void Botcraft::Chunk::SetModifiedSinceLastRender | ( | const bool | b | ) |
Definition at line 98 of file Chunk.cpp.
References modified_since_last_rendered.
void Botcraft::Chunk::SetSkyLight | ( | const Position & | pos, |
const unsigned char | v | ||
) |
Definition at line 644 of file Chunk.cpp.
References AddSection(), Botcraft::Section::CoordsToLightIndex(), has_sky_light, IsInsideChunk(), min_y, Botcraft::SECTION_HEIGHT, sections, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
void Botcraft::Chunk::UpdateNeighbour | ( | Chunk *const | neighbour, |
const Orientation | direction | ||
) |
Definition at line 793 of file Chunk.cpp.
References Botcraft::CHUNK_WIDTH, Botcraft::East, GetBlock(), height, min_y, Botcraft::North, SetBlock(), Botcraft::South, Botcraft::West, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by Botcraft::World::UpdateChunk().
|
private |
Definition at line 109 of file Chunk.hpp.
Referenced by Chunk(), GetBiome(), SetBiome(), and SetBiomes().
|
private |
Definition at line 111 of file Chunk.hpp.
Referenced by Chunk(), GetBlockEntityData(), RemoveBlockEntityData(), and SetBlockEntityData().
|
private |
Definition at line 113 of file Chunk.hpp.
Referenced by Chunk(), and GetDimensionIndex().
|
private |
Definition at line 114 of file Chunk.hpp.
Referenced by AddSection(), Chunk(), GetHasSkyLight(), GetSkyLight(), and SetSkyLight().
|
private |
Definition at line 121 of file Chunk.hpp.
Referenced by Chunk(), GetHeight(), IsInsideChunk(), LoadChunkData(), SetBiomes(), and UpdateNeighbour().
|
private |
Definition at line 126 of file Chunk.hpp.
Referenced by AddLoader(), Chunk(), and RemoveLoader().
|
private |
Definition at line 120 of file Chunk.hpp.
Referenced by Chunk(), GetBiome(), GetBlock(), GetBlockLight(), GetMinY(), GetSkyLight(), IsInsideChunk(), LoadChunkData(), SetBiome(), SetBlock(), SetBlockLight(), SetSkyLight(), and UpdateNeighbour().
|
private |
Definition at line 124 of file Chunk.hpp.
Referenced by GetModifiedSinceLastRender(), LoadChunkData(), SetBiome(), SetBiomes(), SetBlock(), SetBlockEntityData(), and SetModifiedSinceLastRender().
|
private |
Definition at line 108 of file Chunk.hpp.
Referenced by AddSection(), Chunk(), GetBlock(), GetBlockLight(), GetSkyLight(), HasSection(), LoadChunkData(), SetBlock(), SetBlockLight(), and SetSkyLight().