PHP code example of aternos / thanos

1. Go to this page and download the library: Download aternos/thanos library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aternos / thanos example snippets


$thanos = new \Aternos\Thanos\Thanos([
    new \Aternos\Thanos\Pattern\RangePattern(0, 0, 16, 16), //keep chunks in range x:0 z:0 to x:16 z:16
]);


$world = \Aternos\Thanos\World\World::open("/path/to/world/");
$destination = new \Aternos\IO\System\Directory\Directory("/path/to/output/");
$removedChunks = $thanos->snap($world, $destination);
echo "Removed " . $removedChunks . " chunks\n";

$thanos = new \Aternos\Thanos\Thanos([
    new \Aternos\Thanos\Pattern\Factory\ForceLoadedChunkPatternFactory()
]);

$reader = \Aternos\Thanos\Mca\McaReader::open("/path/to/world/region/r.0.0.mca");
$chunk = $reader->getChunk(123); //Get at index 123 in region file
$chunk = $reader->getChunkAt(12, 23); //Get chunk at chunk coordinates x:12 z:23

// Iterate over all chunks in the region file
foreach ($reader->getChunks() as $chunk) {
    //Do something with chunk
}

$reader->close();

$writer = \Aternos\Thanos\Mca\McaWriter::open("/path/to/world/region/r.0.0.mca");
$writer->writeEntry($chunk); // Write a chunk to the MCA file

$writer->close(); // Finalize and close the MCA file