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

Generating Chunks

Discussion in 'Development' started by DiamondGamer30, Sep 15, 2018.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    How do I generate certain chunks with blocks? I want to know an efficient way without doing too many checks.
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    chunk load event or custom generator
     
  3. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I mean as in like the math. What x and z do I start with? I want to generate blocks only in certain chunks. So I'm asking how I figure out if I'm in the chunk that I want to generate a block in. I want an efficient way. The one in my mind didn't seem to efficient to me
     
    Last edited: Sep 16, 2018
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
    $chunkX $player->>> 4;
    $chunkZ $player->>> 4;
    if(
    $wantedChunk->getX() === $chunkX and $wantedChunk->getZ() === $chunkZ)
        
    // chunk found
     
  5. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I'm doing this on generateChunk() in the Generator class.
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    If you're doing it in a generator, then it really depends on the pattern of how frequently you want those blocks to be generated. Without knowing exactly what you want, the best I can say is to look at some other world generators and figure out how you want to set your pattern yourself.
    https://github.com/jasonwynn10/MyPlot/blob/master/src/MyPlot/MyPlotGenerator.php
    https://github.com/jasonwynn10/Othe...rc/jasonwynn10/GlowGen/GlowstoneGenerator.php
     
  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.