Last active
July 27, 2020 18:45
-
-
Save BalintCsala/4d41869ded5c776f0ff168efe3b331ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool place(BlockSource *blockSource, BlockPos *blockPos, Random *random) { | |
for (int attempt = 0; attempt < 10; attempt++) { | |
int xOff = random->nextGaussianInt(8); // = (_genRandInt32() & 7) - (_genRandInt32() & 7) | |
int yOff = random->nextGaussianInt(4); // = (_genRandInt32() & 3) - (_genRandInt32() & 3) | |
int zOff = random->nextGaussianInt(8); // = (_genRandInt32() & 7) - (_genRandInt32() & 7) | |
BlockPos newBlockPos = blockPos.offset(xOff, yOff, zOff); | |
if (blockSource.isEmptyBlock(newBlockPos.x, newBlockPos.y, newBlockPos.z)) { | |
int height = random->nextInt(random->nextInt(3)) + 1; | |
for (int i = 0; i < height; i++) { | |
if (VanillaBlocks::mCactus.canSurvive(blockSource, newBlockPos)) { | |
BlockPos cactusPos(newBlockPos.x, newBlockPos.y, newBlockPos.z); | |
this->_placeBlock(blockSource, cactusPos, VanillaBlocks::mCactus); | |
} | |
newBlockPos = newBlockPos.above(); | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment