how to attach nbt tags to using some spells on item

Started by chelchelovich on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how to attach nbt tags to using some spells on item
Thu, 11/06/2025 - 15:15 (edited)

I'm making semi-magical mod and i dont know how to make arrays of magic spells and bind this spells with nbt tags. Can someone help with it pls?

Are there any other options to do this?

how must it work:

Edited by chelchelovich on Thu, 11/06/2025 - 15:15
Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you precise wich kind of…
Mon, 11/03/2025 - 23:08

Can you precise wich kind of magic you try do make?

 

If not, I recommend you to stock your nbt tags in the player ;)

Joined Nov 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have many types of magic…
Tue, 11/04/2025 - 16:41

I have many types of magic planned, but I don't want to check what type of magic it is and what kind(like if else). I want to create some kind of data array with the names of each spell that will be associated with tags. I added my bad drawing how should it work, hope you will understand that

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The images do not show up, I…
Thu, 11/06/2025 - 05:26

The images do not show up, I recommend you use a site like imgur instead.

Joined Nov 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
¯\_(ツ)_/¯
Thu, 11/06/2025 - 21:40

¯\_(ツ)_/¯

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This works for limited…
Mon, 11/10/2025 - 15:51

This works for limited scroll slots:
If you are gonna have custom keybinds to activate, then on the button press, check if the item in main hand is (your magic box) then check what nbt is in that slot (example would be scrollSlot1, to scrollSlot6) and each has it's own bind, if you see that nbt value for scrollSlot3 is fireball, call a new procedure that is what your fireball will do

This works for unlimited scroll slots:
Have 3 binds (back, select, forward).
Give your box a counter to keep track of the number of spells, an int nbt.
And another string nbt called selectedSpell.
When you add a scroll to the box add +1 to that counter nbt and then create the nbt using create text with (scrollSlot + counter ) would come out as scrollSlot1 for the first spell. but also when the counter is 1 also set the selectedSpell to be 1, so that you have a starting point
Then when you click the either forward or back it will move from the nbt value and set that spell as the selectedSpell nbt, make sure to check if there is an nbt that exists first before setting it as the selectedSpell as it could set it to nothing or crash. 
Now when you click the select keybind you can run the same procedure check what spell is in the selectedSpell nbt, and call a new new procedure that is what your "spell" will do.
If selectedSpell = fireball
call Procedure FireballProcedure
else if selectedSpell = firewall
call Procedure FirewallProcedure

I hope this is readable and useful and if not let me know and I'll show you the procedures when I can.