UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

39 lines (37 loc) 1.37 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); const Log_1 = require("../core/Log"); const Block_1 = require("./Block"); const NbtBinary_1 = require("./NbtBinary"); class BlockPalette { constructor() { this.blocks = []; } parseFromBytes(bytes, index, paletteCount) { for (let i = 0; i < paletteCount; i++) { const nbt = new NbtBinary_1.default(); index += nbt.fromBinary(bytes, true, false, index, true); Log_1.default.assert(index <= bytes.length, "Unexpected expansion of bytes processed."); if (nbt.singleRoot === null) { return index; } const children = nbt.singleRoot.getTagChildren(); let block = null; for (let i = 0; i < children.length; i++) { const child = children[i]; if (child.name === "name") { block = new Block_1.default(); block.typeName = child.valueAsString; this.blocks.push(block); } else if (child.name === "type") { } } } return index; } } exports.default = BlockPalette; //# sourceMappingURL=../maps/minecraft/BlockPalette.js.map