public function readMacro($name)
{
if (!is_file($path = $this->getFile($name))) {
return null;
}
$string = file_get_contents($path);
$nbt = new NBT();
$type = ord(substr($string, 0, 1));
$string = substr($string, 1);
if ($type === 0) {
$nbt->read($string);
} else {
$nbt->readCompressed($string, $type);
}
$tag = $nbt->getData();
$author = $tag["author"];
$description = $tag["description"];
/** @var tag\Enum $tags */
$tags = $tag["ops"];
$ops = [];
/** @var tag\Compound $t */
foreach ($tags as $t) {
$type = $tag["type"];
if ($type === 1) {
$ops[] = new MacroOperation($t["delta"]);
} else {
$vectors = $t["vectors"];
/** @noinspection PhpParamsInspection */
$ops[] = new MacroOperation(new Vector3($vectors[0], $vectors[1], $vectors[2]), Block::get($t["blockID"], $t["blockDamage"]));
}
}
return new Macro(false, $ops, $author, $description);
}