#NBT tags (names) in recipes

25 messages · Page 1 of 1 (latest)

feral falcon
#

Hi! I'm a dummy on this coding thing, so this is probably (I'm sure) an extremely stupid question, but is there any way to make crafting only available with a certain item name? I'm using KubeJS Create and press from Create.
I think I've tried everything I can think of and my codes either give an error or stamp everything without distinguishing the name (like this one below).

 event.recipes.createPressing(['numismatics:cog'],
    Item.of('create:brass_sheet', "{display:{Name:'{\"text\":\"123\"}'}}"))
})```
thick orioleBOT
#

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

vast domeBOT
#

You can find your KubeJS server log in /minecraft/logs/kubejs/server.log.
If you are on 1.18 or 1.16 it will be called server.txt.
Please send it if asked, as it contains helpful information.

halcyon gate
#

The declaration for the Item.of function is as follows:

declare interface Item {
    /**
     * Returns an ItemStack of the input
    */
    of(in_: Internal.ItemStack_): Internal.ItemStack;
    /**
     * Returns an ItemStack of the input, with the specified count and NBT data
    */
    of(in_: Internal.ItemStack_, count: number, nbt: Internal.CompoundTag_): Internal.ItemStack;
    /**
     * Returns an ItemStack of the input, with the specified count
    */
    of(in_: Internal.ItemStack_, count: number): Internal.ItemStack;
}

Notice that the second type with the compond tag need the count to be declared first before the tag

haughty halo
#

that is incorrect

#

if that were the case, i wouldve said so

#

im not sure where you got that from

#

this is the one i meant to send

halcyon gate
#

I got it from the types that probeJS generated

haughty halo
halcyon gate
#

My bad, further down in the interface is this:

/**
     * Returns an ItemStack of the input, with the specified NBT data
    */
    of(in_: Internal.ItemStack_, tag: Internal.CompoundTag_): Internal.ItemStack;
haughty halo
#

ah

feral falcon
#

im sorry, but im too dumb to understand it. Could you explain more simply what I should change in the code please?

haughty halo
feral falcon
vast domeBOT
#

Paste version of server.log from @feral falcon

haughty halo
#

It says the recipe is added tho

feral falcon
haughty halo
#

Ah

#

Try adding .weakNBT() at the end of Item.of()

feral falcon
feral falcon
#

Oh, I got it. Thank you very much!