NBT tag from an enchanted book

Started by Naver789 on Sun, 05/24/2020 - 18:56

Topic category: Help with modding (Java Edition)

Last seen on 17:22, 29. May 2020
Joined Jul 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
NBT tag from an enchanted book
Sun, 05/24/2020 - 18:56

I am trying to get the enchantment id of the enchantment on an enchanted book. For that i need the NBT tag. The name of the tag is "StoredEnchantments" but it has also a two sub-tags "id" and "lvl". So what do i have to write in to the text field to get the right tag? "StoredEnchantments" is not enought, it needs something else.

 

Last seen on 06:41, 5. Jul 2020
Joined May 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
You cannot directly read NBT…
Sun, 05/24/2020 - 21:04

You cannot directly read NBT tags in this way with procedures. There is a procedure block that can get the level of a given enchantment on an item, including Enchanted Books. The only way to know what enchantments it has is to test for every single one (extremely tedious, I know). The ones that don't return level 0 are the ones it has.

Now, if you are curious about the NBT structure of an enchanted book, here is an example of one that has protection 3 and efficiency 2:

{StoredEnchantments:[{id:"minecraft:protection",lvl:3},(id"minecraft:efficiency",lvl:2)]} note that this example is for 1.14 or 1.15. 

Last seen on 17:22, 29. May 2020
Joined Jul 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
thanks for the answer
Mon, 05/25/2020 - 08:24

thanks for the answer