Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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];
});
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))
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;
}