#How to give an item with NBT value:

13 messages · Page 1 of 1 (latest)

steel basin
#

I'm trying to provide a player with a patchouli guide book on first time login but I can't seem to work out how to set the NBT data

What the patchouli talks about:

{
  "function": "set_nbt",
  "tag": "{\"patchouli:book\": \"YOURBOOKIDHERE\"}"
}

What I'm doing in KubeJS

PlayerEvents.loggedIn(event => {
  if (!event.player.stages.has('starting_items')) {
    event.player.stages.add('starting_items')
    event.player.give('minecraft:stone_sword')
    event.player.give(Item.of('patchouli:guide_book', 1))
  }
})
austere stirrupBOT
#

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

pseudo axle
#

After the 1 you put a comma then add the nbt data

#

That's {"patchouli:book":"YOURBOOKIDHERE"}

#

obviously with your guide book I'd substituted in

steel basin
#

If I enter it as a string such as
event.player.give(Item.of('patchouli:guide_book', 1, "{\"patchouli:book\":\"egcraft_light_handbook\"}"))
I get:

[KubeJS Server/]: main.js#8: Error in 'PlayerEvents.loggedIn': dev.latvian.mods.rhino.EvaluatorException: Can't find method dev.latvian.mods.rhino.CachedClassInfo.of(string,number,object).
[KubeJS Server/]: …rhino.EvaluatorException: Can't find method …rhino.CachedClassInfo.of(string,number,object). (server_scripts:main.js#8)
[KubeJS Server/]:   at …rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67)

If I enter it as an object such as
event.player.give(Item.of('patchouli:guide_book', 1, {"patchouli:book":"egcraft_light_handbook"}))
I get:

[KubeJS Server/]: main.js#8: Error in 'PlayerEvents.loggedIn': dev.latvian.mods.rhino.EvaluatorException: Can't find method dev.latvian.mods.rhino.CachedClassInfo.of(string,number,object).
[KubeJS Server/]: …rhino.EvaluatorException: Can't find method …rhino.CachedClassInfo.of(string,number,object). (server_scripts:main.js#8)
[KubeJS Server/]:   at …rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67)

I'm running mincraft 1.21.1 if that makes any difference.

pseudo axle
#

Don't enter it as a string

steel basin
#

What should I enter it as? As you can see from the second block. If I provide it as an object I get a similar error.

unreal fog
#
event.player.give('patchouli:guide_book[patchouli:book="bigreactors:erguide"]')
steel basin
#

You legend

unreal fog
#

so just for the future if your holding the item you can use /kjs hand and it will tell you exactly what the item is

steel basin
#

Oh, I got that bit. I just couldn't work out how to give the item. I didn't realise you could just literally provide the string to the give function.

unreal fog
#

ah ok