How to use the prismarine-nbt.simplify function in prismarine-nbt

To help you get started, we’ve selected a few prismarine-nbt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LeaPhant / skyblock-stats / lib.js View on Github external
async function getItems(base64){
    // API stores data as base64 encoded gzipped Minecraft NBT data
    let buf = Buffer.from(base64, 'base64');

    let data = await parseNbt(buf);
    data = nbt.simplify(data);

    let items = data.i;

    // Check backpack contents and add them to the list of items
    for(let [index, item] of items.entries()){
        if(objectPath.has(item, 'tag.display.Name') && (item.tag.display.Name.endsWith('Backpack') || item.tag.display.Name.endsWith('Itchy New Year Cake Bag'))){

            let keys = Object.keys(item.tag.ExtraAttributes);

            let backpackData;

            keys.forEach(key => {
                if(key.endsWith('backpack_data') || key == 'new_year_cake_bag_data')
                    backpackData = item.tag.ExtraAttributes[key];
            });
github PrismarineJS / mineflayer / lib / plugins / blocks.js View on Github external
function addBlockEntity (nbtData) {
    const blockEntity = nbt.simplify(nbtData)
    const absolutePoint = new Vec3(blockEntity.x, blockEntity.y, blockEntity.z)
    const loc = new Location(absolutePoint)

    // Handle signs
    if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign') {
      const prepareJson = (i) => {
        const json = JSON.parse(blockEntity[`Text${i}`])
        json.text = json.text.replace(/^"|"$/g, '')
        return json
      }

      blockEntity.Text1 = new ChatMessage(prepareJson(1))
      blockEntity.Text2 = new ChatMessage(prepareJson(2))
      blockEntity.Text3 = new ChatMessage(prepareJson(3))
      blockEntity.Text4 = new ChatMessage(prepareJson(4))
github LeaPhant / skyblock-stats / lib.js View on Github external
async function getBackpackContents(arraybuf){
    let buf = Buffer.from(arraybuf);

    let data = await parseNbt(buf);
    data = nbt.simplify(data);

    let items = data.i;

    for(let item of items){
        item.isInactive = true;
        item.inBackpack = true;
    }

    return items;
}

prismarine-nbt

A parser and serializer for NBT archives

MIT
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis