Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ore generation #242

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cubic-server/generation/features/underground/OreVein.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ void OreVein::createBlob(const BlockId &blockID, const int spawnSize, const Posi
customSkipRate =
abs((((blobCenter.x - x) % SECTION_WIDTH) ^ 2) + (((blobCenter.y - y) % SECTION_WIDTH) ^ 2) + (((blobCenter.z - z) % SECTION_WIDTH) ^ 2) % SECTION_WIDTH);
auto block = _chunk.getBlock({x, y, z});
if ((x - pos.x < r && z - pos.z < r) && r / 2 > customSkipRate && nb < nbOfBlocksInBlob &&
(block != Blocks::Air::toProtocol() && block != Blocks::Bedrock::toProtocol()) && y > CHUNK_HEIGHT_MIN) {
// TODO: When the generation will support decoration, block = stone has to be changed so every "stone" block is taken into account
if ((x - pos.x < r && z - pos.z < r) && r / 2 > customSkipRate && nb < nbOfBlocksInBlob && (block == Blocks::Stone::toProtocol()) &&
(y > CHUNK_HEIGHT_MIN && y < CHUNK_HEIGHT_MAX)) {
_chunk.updateBlock({x, y, z}, blockID);
nb++;
}
Expand Down
20 changes: 10 additions & 10 deletions cubic-server/world_storage/ChunkColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,19 @@ void ChunkColumn::_generateRawGeneration(generation::Generator &generator)
void ChunkColumn::_generateLakes(UNUSED generation::Generator &generator)
{
std::lock_guard<std::mutex> _(this->_generationLock);
// int waterLevel = 86;
int waterLevel = 86;

// TODO: improve this to fill caves
// generate water
// for (int z = 0; z < SECTION_WIDTH; z++) {
// for (int x = 0; x < SECTION_WIDTH; x++) {
// for (int y = waterLevel; 0 < y; y--) {
// if (getBlock({x, y, z}) == 1)
// break;
// updateBlock({x, y, z}, Blocks::Water::toProtocol(Blocks::Water::Properties::Level::ZERO));
// }
// }
// }
for (int z = 0; z < SECTION_WIDTH; z++) {
for (int x = 0; x < SECTION_WIDTH; x++) {
for (int y = waterLevel; 0 < y; y--) {
if (getBlock({x, y, z}) == 1)
break;
updateBlock({x, y, z}, Blocks::Water::toProtocol(Blocks::Water::Properties::Level::ZERO));
}
}
}
_currentState = GenerationState::LAKES;
}

Expand Down