KubeJS (Old)

KubeJS (Old)

3M Downloads

Tooltip addition doesn't take item nbt into account

Yarden-zamir opened this issue ยท 2 comments

commented
    event.addAdvanced(Item.of('botania:blood_pendant', '{brewKey:"botania:strength"}'), (s, adv, text) => {
        text.add("should be only on the strength one")
    })

expected behavior : only add this tooltip to the specified item with that nbt
existing behavior:
existing behavior

commented

) :

commented

I can't tell if this is a bug or intentional, however:

Using addAdvanced, you can check item NBT within the handler.

Ex using an arrow. If you enchant the arrow in creative, the tooltip will change.

onEvent('item.tooltip', event=> {
    event.addAdvanced(Item.of('minecraft:arrow'), (s, adv, text) => {
        if(s.hasNBT()){ // Check if the item has NBT
            // Add further logic here if you'd like.
            text.add("This item has NBT Data!");
        }else{
            text.add("This item has no NBT Data!");
        }
    })
})