#I need some help setting up recipes that include nbt data

47 messages · Page 1 of 1 (latest)

ocean cave
#

We're playing on a server with 10-15 people and ancient tomes from the quark mod are too hard to get with this many people looting. We decided we wanted to add a recipe for them. I would've done this with a datapack because that's what I know how to make but regular recipes don't support nbt and both my input items and result need nbt data to be functional items. I was told using kubejs could do the trick but I honestly have no idea how to work with javascript. What I'm trying to do (if even possible) is have a recipe that looks like this https://cdn.discordapp.com/attachments/796383470686699554/1138216338045816912/u3dNHcO.png where the enchanted books have to be vanilla max level versions of the tome you placed the middle and it should give you two tomes of the one you put in, essentially doubling your tome at the cost of 4 enchanted books.

neat wingBOT
#

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

ocean cave
#

and I guess an additional question is if this works server side only or if everyone has to install it.

true marshBOT
#

Send your code here instead of a screenshot

It makes it easier to diagnose your code and help you fix it or make the required changes/additions.

loud python
#

For items with nbt you can do /kjs_hand with your item in your main hand, you will get a chat massage copy the first Line (should start with Item.of(), this you then place instead of the string.

true marshBOT
loud python
#

if you want to know how to add recipes at all:

true marshBOT
#

You can add, remove, and modify recipes with KubeJS. The wiki has a page on that!
If you want to learn how to add recipes to any mod, click the Custom button.

ocean cave
#

Am I missing a dependancy?

#
ServerEvents.recipes(event => {
      event.shaped(
        Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}', 2), // arg 1: output
        [ 
          'ABA', 
          'BCB', // arg 2: the shape (array of strings)
          'ABA'  
        ],
        {
          A: 'minecraft:experience_bottle', 
          B: ('minecraft:enchanted_book').enchant('minecraft:power', 5),  //arg 3: the mapping object
          C: ('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}')
        }
      )
  console.log('Hello! The recipe event has fired!')
})
#

this is what I have

#

still have the log thing in

#

till it's working I'll keep it in

covert glacier
#

that's not how you do it...

ocean cave
#

FeelsDankMan what am I doing wrong then?

bronze tangle
#
{

  A: 'minecraft:experience_bottle', 

  B: Item.of('minecraft:enchanted_book').enchant('minecraft:power', 5),  //arg 3: the mapping object

  C: Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}')

}
#

u already did it as output

covert glacier
#
ServerEvents.recipes(event => {
    event.shaped(Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}', 2), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: 'minecraft:experience_bottle',
        B: Item.of('minecraft:enchanted_book').enchant('minecraft:power', 5),
        C: Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}')
    })
})
covert glacier
#

??basics

true marshBOT
# covert glacier ??basics

To create KubeJS scripts, you'll need:

  • a proper code editor,
  • some programming (more specifically, javascript) knowledge,
  • common sense.
ocean cave
#

Oh I forgot the shaped

covert glacier
bronze tangle
#

no, u forgot the Item.of

ocean cave
#

wait no I didnt

covert glacier
#

you didn't forget "the shaped"

#

you forgot the Item.of in some inputs

covert glacier
ocean cave
covert glacier
#

ohh waitr

#
ServerEvents.recipes(event => {
    event.shaped(Item.of('quark:ancient_tome', 2, '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}'), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: 'minecraft:experience_bottle',
        B: Item.of('minecraft:enchanted_book').enchant('minecraft:power', 5),
        C: Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"minecraft:power",lvl:5s}]}')
    })
})
ocean cave
#

It works now thank you

#

so the two had to be the second argument

#

got it

covert glacier
#

also, I recommend getting probejs

#

??kjsaddons

true marshBOT
# covert glacier ??kjsaddons

ProbeJS is an addon mod for KubeJS that generates typings files for VSCode, allowing VSCode to offer autocompletions for a ton of things!

Mod by @sacred panther

covert glacier
#

helps a lot

neat wingBOT
#

Ticket re-opened!

ocean cave
#

So it's not working yet apparently, the recipe doesn't respect the input nbt, I tried using sharpness books and it still gave me power

covert glacier
#

item are ignore nbt on 1.19 by default

#

so you will have to add .strongNBT() at the end of the Item.ofs, like this:

#
ServerEvents.recipes(event => {
    event.shaped(Item.of('quark:ancient_tome', 2, '{StoredEnchantments:[{id:"power",lvl:5s}]}'), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: 'experience_bottle',
        B: Item.of('enchanted_book').enchant('power', 5).strongNBT(),
        C: Item.of('quark:ancient_tome', '{StoredEnchantments:[{id:"power",lvl:5s}]}').strongNBT()
    })
})
ocean cave
#

thanks