/** * @param Block $block * @param Vector3 $pos * @param Level $level * * @return bool */ public function saveUndo(Block $block, Vector3 $pos = null, Level $level = null) { if ($pos instanceof Position && $pos->getLevel() !== null) { $block->level = $pos->getLevel(); } elseif ($level !== null) { $block->level = $level; } elseif ($block->getLevel() === null) { return false; } if ($pos !== null) { $block->setComponents($pos->x, $pos->y, $pos->z); } $key = "{$block->x}:{$block->y}:{$block->z}"; if (!isset(self::$undo[$key])) { self::$undo[$key] = []; } self::$undo[$key][] = $block; return true; }