- 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.
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.
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):
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:
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.
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?
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!
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.
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.
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):
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:
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.
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?
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: