#(Neoforge 1.21) Need help with searching for items and saving them to a file

9 messages · Page 1 of 1 (latest)

lyric atlas
#

Quite embarassing, but wanted to do something simple, and i have no idea what's wrong....
My objective is getting all the bees from ProductiveBees mod, and write to a file, so i can have the bees currently in the pack on a file.
The problem is when saving, not sure whats wrong.... Sorry for what seems to be a simple to do thing, but thanks
https://pastebin.com/dqsgQ4Fm

chrome gobletBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

lyric atlas
#
    if (event.message.trim().toLowerCase() != 'getbees') {
        return;
    }
    try {
        // Get entries with "bee" in their name and etc
        let beeItems = Ingredient.all.itemIds.filter(item => item.includes("productivebees") && !item.includes("hive") && !item.includes("spawn") && !item.includes("expansion") && !item.includes("upgrade"));
        
        // Log the filtered items to the server console
        beeItems.forEach(item => {
            console.log(item);
        });
        console.log(beeItems.length);
        
        console.log("before write");
        JsonIO.write('kubejs/bees.json', beeItems);
        let bees = JsonIO.read('kubejs/bees.json');
        console.log(bees);

    } catch (error) {
        console.log('Error during server load event:', error);
    }
})
#

thats better

cerulean parcel
#

you are trying to write an array to a json file.

#

you need to write a json object to a json file.

#

so this:

{
  "bees": [
    "bee1",
    "bee2"
  ]
}
potent smelt
#

#1254790121807548437 pain

lyric atlas