#Getting and checking for entityNBT tag values

3 messages · Page 1 of 1 (latest)

dense yacht
#

This is a repost since I accidentally closed the last ticket. Working with MoreJS I want to make it so that villager trades are disabled unless their nbt 'memories: {hearts:#}' is equal to a specific value. For example, trades are disabed unless the merchants nbt is >= 'hearts: 25' I don't know how to get nbt values using KubeJS so if anyone can help, here's a base version of code I have so far:


MoreJSEvents.playerStartTrading(event => {
    // check if the merchant given by the event is an instance of the AbstractVillager class
    if (event.merchant instanceof $AbstractVillager) {
        const { nbt } = event.merchant;
        if (nbt?.memories?.hearts) {
            // MoreJS event to disable trades
            event.forEachOffers((o, i) => {
                o.disabled = true;
            });
        }
    }
});```
devout orbitBOT
#

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

inland monolith
#

Aou know Tickets are automatically reopened once you Post a new Message and that there's also a Button to reopen?