1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Generating World then SetBlock

Discussion in 'Development' started by DaRealPandaz, Aug 19, 2019.

  1. DaRealPandaz

    DaRealPandaz Silverfish

    Messages:
    24
    GitHub:
    mrpandaz
    Hello, I am currently trying to generate a world then set a block. I have it where when a new player joins It generates the world, but It does not setBlock (Not supposed to). Now when the new player does /is go for the first time it is supposed to setBlock, yet it doesnt. Here is my Code

    PHP:
    /* Generate one Bedrock Block */
    $level->setBlock(new Vector3(01000), BlockFactory::get(Block::BEDROCK));

     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Is the world loaded?
     
  3. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Create custom generator with populator insteadof placing block after generating.
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The problem is when you create a new world, the world is surely "loaded" but not "generated".
    The generation task runs asynchronously and will override your setBlocks.
    Code:
    $level->generateLevel(...);
    // ^ will also call $level->populateChunk(all spawn chunks);
    $level->setBlock(...); // run by you
    // an uncertain amount of time later
    // pmmp $level->setChunk(populated chunks); <-- this overrides the blocks
    
    You could do what @GamakCZ said, that's the simplest way to go with this. Or you could create an async event which calls back once all loaded chunks of the level are populated.
     
    HimbeersaftLP likes this.
  5. DaRealPandaz

    DaRealPandaz Silverfish

    Messages:
    24
    GitHub:
    mrpandaz
    ive never worked with populating levels. Do you know any examples maybe i can look at?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.