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

I need cut a circle map

Discussion in 'Facepalm' started by gistrec, Jun 29, 2017.

  1. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    I have a big map. And I would like to make this map circle.
    What I need do?
    I think, that I need create function, witch will delete excess chunks, and after that, I need delete other unnecessary block. Is it true?)
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    assuming so,
    you would need the radius of the circle, and remove everything outside of it
    one problem, anything outside of the circle is infinitely big
    which can be countered by not actually removing everything, but just from your sight
    creating a circular strip of void
     
    gistrec likes this.
  3. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    I am trying
    I will write the results later :)
     
  4. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    Now i have this, but chunks don't change :c
    PHP:
        public function cuteCircleMap($level) {
            
    # Map radius, in block's
            
    $radius 1000;
            
    # Chunk count
            
    $mapChunks = array('x' => 128,
                               
    'y' => 128);
            
    # Дальше все будет вычисляться само
            
    $spawnPoint = array('x' => $mapChunks['x'] * 8// Умножаем на 16, делим на 2
                                
    'y' => $mapChunks['y'] * 8);
            for (
    $chunkX 0$chunkX $mapChunks['x']; $chunkX++) {
                for (
    $chunkY 0$chunkY $mapChunks['y']; $chunkY++) {

                    
    $level->loadChunk($chunkX$chunkYfalse);
                    
    // Позиция центра чанка
                    
    $fixedChunkPosition = array('x' => $chunkX 16 8,
                                                
    'y' => $chunkY 16 8);
                    
    $distance sqrt(pow($spawnPoint['x'] - $fixedChunkPosition['x'],2) +
                                     
    pow($spawnPoint['y'] - $fixedChunkPosition['y'],2));
                    echo(
    "Chunk ".$chunkX .":"$chunkY." distance:".round($distance)." ".
                         
    "progress:".(round(($chunkY $chunkX*$mapChunks['x'])*100/($mapChunks['x']*$mapChunks['y'])))."%\n");
                    if (
    $distance $radius) {
                        
    $newChunk Chunk::getEmptyChunk($chunkX$chunkY);
                        
    $level->setChunk($chunkX$chunkY$newChunk);
                    }
                    
    $level->unloadChunk($chunkX$chunkYtrue);
                }
            }
        }
    Can I delete chunks? I don't find how can I do this in pmmp :c
     
  5. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    SUCCESSFULLY!!!
    2048 * 2048 for 30 seconds :3
    Yeea

    PHP:
        public function cuteCircleMap($level) {
            
    # Радиус вырезаемой карты, в блоках
            
    $radius 1024;
            
    # Количество чанков
            
    $mapChunks = array('x' => 128,
                               
    'y' => 128);
            
    # Дальше все будет вычисляться само
            
    $spawnPoint = array('x' => $mapChunks['x'] * 8// Умножаем на 16, делим на 2
                                
    'y' => $mapChunks['y'] * 8);
            for (
    $chunkX 0$chunkX $mapChunks['x']; $chunkX++) {
                for (
    $chunkY 0$chunkY $mapChunks['y']; $chunkY++) {
                    
    // Позиция центра чанка
                    
    $fixedChunkPosition = array('x' => $chunkX 16 8,
                                                
    'y' => $chunkY 16 8);
                    
    $distance sqrt(pow($spawnPoint['x'] - $fixedChunkPosition['x'],2) +
                                     
    pow($spawnPoint['y'] - $fixedChunkPosition['y'],2));
                    echo(
    "Chunk ".$chunkX .":"$chunkY." distance:".round($distance)." ".
                         
    "progress:".(round(($chunkY $chunkX*$mapChunks['x'])*100/($mapChunks['x']*$mapChunks['y'])))."%\n");

                    if (
    $distance 12 $radius) {
                        
    $newChunk Chunk::getEmptyChunk($chunkX$chunkY);
                        
    $newChunk->setGenerated(true);
                        
    $level->getProvider()->setChunk($chunkX$chunkY$newChunk);
                        
    $level->getProvider()->saveChunk($chunkX$chunkY);
                    }
                    if (
    abs($distance $radius) < 12) {
                        
    $chunk $level->getChunk($chunkX$chunkY);
                        for (
    $x $chunkX 16$x $chunkX 16 16$x++) {
                            for (
    $y $chunkY 16$y $chunkY 16 16$y++) {
                                
    $distance sqrt(pow($spawnPoint['x'] - $x,2) + pow($spawnPoint['y'] - $y,2));
                                if (
    $distance $radius) {
                                    for (
    $z 0$z 256$z++) {
                                        
    $chunk->setBlockId($x $chunkX 16$z$y $chunkY 160);
                                    }
                                }
                            }
                        }
                        
    $level->unloadChunk($chunkX$chunkY);
                    }
                }
            }
        }
    [​IMG]
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Consider modifying the world generator. That would work better.
    Just extend the normal generator but override if the chunk is beyond your radius, setting everything as 0:0.
     
    gistrec and Jack Noordhuis like this.
  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.