#how do I differentiate between enchanting books
39 messages · Page 1 of 1 (latest)
Paste version of enchantLore.js from @nocturne void
enchantment books are nbt data I believe
Yep they are NBT. So a give command would be:
minecraft:enchanted_book{StoredEnchantments: "minecraft:sharpness", lvl: 10}
The lvl can be a short number I think
well i would work with the /give cmd but it dosent work in kubejs
So it does kind of. The command is just the root of what you would use in KJS
Instead you would use a method:
Item.of('minecraft:enchanted_book').enchant('minecraft:sharpness', 5)
i already found out about that bc of the /kubejs hand cmd but it didnt work either but i will test it again real quick
all it did was giving every enchanted book the tooltip the same as the above ...
Wait, what's the end goal?
i want to give every enchant a different tooltip
you need to use .addAdvanced() for nbt sensitivity at all
event.addAdvanced(Item.of('minecraft:enchanted_book'), (stack, adv, text) => {
stack.nbt.StoredEnchantments.forEach((enchant) => {
if(enchant.id == 'minecraft:mending'){
text.add(Text.of('Quark\'s Mending Nerf is enabled! Items will not repair by absorbing XP!').color('#E66232'))
}
})
})```
here's an example of what i did to add a tooltip to mending
however, this can be done in a *MUCH* more efficient and universal way, by concating strings and using localization
event.addAdvanced(Item.of('minecraft:enchanted_book'), (stack, adv, text) => {
stack.nbt.StoredEnchantments.forEach((enchant) => {
let key = `modpack.enchantment.${enchant}.info`;
if(Text.translate(key) != key) text.add(Text.translate(key));
})
})```
if i'm not being stupid, this should allow you to add new language keys to add tooltips, and it should simply not display them if the language key has no localized version
well previously I used the tooltip event.. should I switch to a client.init , logged or tick event ?
its fine found exactly what i needed in old example scripts
thank u for ur help
but I do wonder... Where can I get Information abaut the methods like addAdvanced() or stack.nbt.StoredEn... ?
Im new to kubejs well js in general so I hope u can help me
kjs wiki(s), reading the source code, or using probejs
You can make custom items with KubeJS, and the wiki has a page on them!
ProbeJS is an addon mod for KubeJS that generates typings files for VSCode, allowing VSCode to offer autocompletions for a ton of things!
https://kubejs.com/ < wikis
i tried using probe but i cant do the /probejs dump cmd
@nocturne void Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!
Ticket closed!
Ticket closed!
@nocturne void Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!
Ticket closed!
Ticket closed!
Why is this post not closing 
Ticket closed!
@fossil isle example of a post not closing, no matter how i try it
manually closing just revives the bot to ping the person instead
ooh I see why
because its super old
and doesnt have tags
it can't have 0 tags
smh @ op who didnt add mc version/loader
lets try now