-
Notifications
You must be signed in to change notification settings - Fork 4
/
getBlock.php
57 lines (45 loc) · 1.33 KB
/
getBlock.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once __DIR__ . "/../vendor/autoload.php";
use Aternos\Hawk\File;
use Aternos\Hawk\Hawk;
use Aternos\Hawk\McCoordinates3D;
use Aternos\Hawk\Region;
if (!isset($argc)) {
echo "argc and argv disabled. check php.ini " . PHP_EOL;
return;
}
$yes = ["Y", "y", false];
$no = ["N", "n"];
switch ($argc) {
case 1:
case 2:
echo "too few params given.
\targument 1: path of input file " . PHP_EOL . "
\targument 2: block coordinates(x,y,z) " . PHP_EOL;
return;
case 3:
if (!file_exists($argv[1])) {
echo "directory does not exist. " . PHP_EOL;
return;
}
break;
default:
echo "too many params given. choose: " . PHP_EOL . "
\targument 1: path of input file " . PHP_EOL . "
\targument 2: block coordinates(x,y,z) " . PHP_EOL;
return;
}
$inputPath = $argv[1];
$coordinates = explode(",", $argv[2]);
if(count($coordinates) !== 3){
echo "Wrong coordinates " . PHP_EOL;
return;
}
$blockPos = new McCoordinates3D($coordinates[0], $coordinates[1], $coordinates[2]);
// Could be more than one
$files[] = new File($inputPath . "/" . Region::getRegionFileNameFromBlock($blockPos));
$hawk = new Hawk(blockFiles: $files);
echo strval($hawk->getBlock($blockPos));
foreach ($files as $file) {
$file->close();
}