@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
42 lines (41 loc) • 1.59 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Log_1 = __importDefault(require("../core/Log"));
const Block_1 = __importDefault(require("./Block"));
const NbtBinary_1 = __importDefault(require("./NbtBinary"));
class BlockPalette {
blocks = [];
parseFromBytes(bytes, index, paletteCount) {
for (let i = 0; i < paletteCount; i++) {
const nbt = new NbtBinary_1.default();
const bytesRead = nbt.fromBinary(bytes, true, false, index, true);
if (bytesRead <= 0) {
return index;
}
index += bytesRead;
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;