• Hey! Register here to create your account, engage with the community, and talk about what is new!

An Introductory Guide To Item Tags

General_Mudkip

Retired Moderator
Overlord
Joined
Sep 6, 2020
Messages
362
Reaction score
95
May or may not have nabbed this idea off of RandomBlock123, so check out his tutorial.

Item tags were introduced in 5.0, and have really made soft-coding a lot easier for developers. They basically function like Python(blasphemy I know)Dictionaries, just storing a key and value. In this tutorial I'll talk about how to use item tags effectively and how they can be used to make your life 10x easier.

How do I use Item Tags?
You can set an item's tag by using commands. Here's a list:

/item tag set <key> <value> : Keep in mind that the key has to be all lowercase, whereas the value can be anything.
/item tag remove <key> : This is currently broken, however it would remove a tag normally.
/item tag list : Displays a list of all your item's tags.
/item tag clear : Removes all tags on your item.


Additionally, you can use Set Variable blocks to also modify item tags.
1600379283870.png1600379301326.png1600379314025.png


There are also entity tags, which function basically the same as Item Tags.

What can I use Item Tags for?
Item tags can be used for a very wide array of things, from modifying pet's stats to making custom damage systems to creating a custom car system, the possibilities are virtually endless. In this tutorial I'll show you my custom damage system (Which is available on the Code Vault!) which uses both item and entity tags.

So first of all, we have our buddy here. Dummy. Bit rude if you ask me.
1600379765486.png
Now dummy has 1 tag, "maxhealth". Pretty self explanatory. I just store their max health inside the entity tag, which in this case is 100.
It would look something like this (keep in mind that at the moment you can't get an entity's tags outside of the action):1600379871620.png
Very good. Now to make the actual sword to damage poor dummy. I'll stick to the bare minimum, so we'll just set a tag on a sword "damage" to
5. Which will look like this when you list it: 1600379972897.png
Now we'll just place down a Player Event: Damage Entity, place a Game Action: Cancel Event and do the fun part.







Next up, we'll get the Item Tag of the item the player attacked that entity with, using Set Var: Get Item Tag.
1600380285390.png1600380260945.png1600380327121.png
The first variable is what will be set, the second is the item that's tags we will be checking (in this case the item that the player is currently holding), and what key we will check. Keys basically serve as things that don't change, which are attached to their values. So in this case, the key damage's value is 5, so the "damage" variable will be set to 5. Making sense?
1600381864950.png

Then, all we have to do is just use an Entity Event: Damage and our "damage" variable and voila, a complete custom damage system! Now you can get any item, do /item tag set damage [damage value] and when you hit something it will damage it that much! Wowee!

That's pretty much the end of it. I might add some more stuff/correct any errors that I made if you guys have any feedback. Hope this was helpful!

 
Last edited:

Vulcano

Forum adept
Overlord
Joined
Sep 11, 2020
Messages
243
Reaction score
64
Great tutorial, very informative! This will definitely be very helpful for new players. I like that you have included relevant tutorials, you're tutorials along with those can help a new player very much!
 
  • Like
Reactions: RDM

grobulae

Moderator
Moderator
Joined
Sep 6, 2020
Messages
127
Reaction score
26
what a rollercoaster of emotions

First, i thought it was my thread
Then, i thought mine would just get squashed
Then, mine was in relevant

Good tutorial <3
 

Prox

Moderator
Moderator
Joined
Sep 9, 2020
Messages
384
Reaction score
30
Note:
Unfortunately, due to something we cannot fix, item tags often do not save properly using save and load inventory.
 

RolandMC123

Forum adept
Joined
Sep 9, 2020
Messages
186
Reaction score
50
Other Note:
Item tags are really buggy. Sometimes the actions don't work, text tags don't save properly in saving inventories, etc.

Apparently, number tags weren't implemented properly by S4nders so you can't even use them with most actions.
 

General_Mudkip

Retired Moderator
Overlord
Joined
Sep 6, 2020
Messages
362
Reaction score
95
I haven't had any issues with item tags so far, but I know that the Save/Load inventory bug is definitely a thing. At that point you're just better off implementing your own custom save and load system using lists.
 
Top Bottom