#NBT strip

10 messages · Page 1 of 1 (latest)

lyric cape
#

Seems like this should be simple and I am just stupid. I need to take an item and check the nbt, then strip that nbt. and provide the item back with damage etc, just stripping specific nbt.

fallen moonBOT
#

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

autumn lodge
#

so removing a specific nbt tag from an item in a crafting table recipe?

lyric cape
#

that would be a fine solution, I was actually going to use the create mill and grinder, but crafting table would be almost the same code.

autumn lodge
#

whould it also work, for your specific usecase, if your nbt to remove wouldn't necessary need to be on the item?

lyric cape
#

not sure what you mean? The item being used could have the nbt, if it does I need to remove the nbt and then give back an item that is the same minus the nbt. In particular I am imitating the effect of nbt removal from apotheosis mod when it strips off stones and additional function nbt.

autumn lodge
#

Try this

event.shapeless("minecraft:diamond_sword", [Item.of("minecraft:diamond_sword").ignoreNBT())])
  .modifyResult((inventory, itemstack) => {
    item = inventory.find(Item.of("minecraft:diamond_sword").ignoreNBT())
    if (item.nbt == null) return itemstack
    nbt = item.nbt
    nbt.remove('your_nbt_tag_here')
    if (nbt.size() == 0) nbt = null
    return itemstack.withNBT(nbt)
})
#

would need to adjust your input and output item + the one in inventory.find

lyric cape
#

ooohhh I'll try it!

#

I don't know that I understand, but it worked. return exits the modifyresult call with the current variables?