"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseNbt = exports.NON_OCCLUDING_BLOCKS = exports.TRANSPARENT_BLOCKS = exports.INVISIBLE_BLOCKS = exports.faceToFacingVector = void 0;
const gzip_js_1 = require("gzip-js");
const nbt_ts_1 = require("nbt-ts");
const nonOccluding_json_1 = __importDefault(require("./nonOccluding.json"));
const transparent_json_1 = __importDefault(require("./transparent.json"));
function faceToFacingVector(face) {
    switch (face) {
        case 'up':
            return [0, 1, 0];
        case 'down':
        case 'bottom':
            return [0, -1, 0];
        case 'north':
            return [0, 0, -1];
        case 'south':
            return [0, 0, 1];
        case 'east':
            return [1, 0, 0];
        case 'west':
            return [-1, 0, 0];
        default:
            throw new Error(`Unknown face: ${face}`);
    }
}
exports.faceToFacingVector = faceToFacingVector;
exports.INVISIBLE_BLOCKS = new Set([
    'air',
    'cave_air',
    'void_air',
    'structure_void',
    'barrier',
    'light',
]);
exports.TRANSPARENT_BLOCKS = new Set([
    ...exports.INVISIBLE_BLOCKS,
    ...transparent_json_1.default,
]);
exports.NON_OCCLUDING_BLOCKS = new Set([
    ...exports.INVISIBLE_BLOCKS,
    ...nonOccluding_json_1.default,
]);
function parseNbt(nbt) {
    const buff = Buffer.from(nbt, 'base64');
    const deflated = Buffer.from((0, gzip_js_1.unzip)(buff));
    const data = (0, nbt_ts_1.decode)(deflated, {
        unnamed: false,
        useMaps: true,
    });
    return data.value;
}
exports.parseNbt = parseNbt;
//# sourceMappingURL=utils.js.map