Skip to content
Discussion options

You must be logged in to vote

Only loaded blocks are available, if you get null it's probably that they're not loaded yet.

However, I can see in your code that your world_guard lockking the world mutex is in the same scope than your sleep. So you wait for more blocks to be loaded but you also block (pun not intended) any chunk data to be loaded in the world during this time.

A simple thing you could do is something like that (you could add a while loop to be sure you get all blocks):

std::shared_ptr<Blockstate> blockstate;
{
    std::lock_guard<std::mutex> world_guard(world->GetMutex());

    const Block *block = world->GetBlock(v);

    if (block) 
    {
        blockstate = block->GetBlockstate();
    }
}

if (!bloc…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@folkertvanheusden
Comment options

Answer selected by folkertvanheusden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants