Topic category: Help with modding (Java Edition)
Hi, I'm new here and I'm not sure if this is the right section to post this or not, if not please let me know since I plan to make a couple more tutorials.
I've seen a lot of people asking how to do this in the forums and people saying that it can't be done whithout coding. Well I don't like imposibles, and also I don't know how to code :P , so I found a way to do it without coding, just procedure blocks and minecraft comands, and here it is.
In this tutorial we will be making an item that increases the max health of an entity using minecraft.
So the first thing that you need, as with any procedure, it's a condition or reason for it to be executed. In this case the procedure is tied to de "when right click on entity" trigger and IF you have the especific item in your hand when doing it the procedure runs.
The second line of blocks sets a local STRING variable called "max_health" to the maximum health of the target entity + 0.5. This is done with the help of the "format number to ##.##" wich in english what it does is it translates a numerical value or variable to a text or string. (DO NOT CHANGE THE ##.## simbols! All you have to do for this block to work properly is give it a number to translate. that's it. The ##.## stays as it is)
The third line of blocks asembles the minecraft comand text that will be executed and saves it to another local STRING variable called "max_health_comand". For this, since I wanted to increase the max health by 1 every time the item was used I used the "replace text, with, on" block to always replace the text ""(max health)"" in this text that I used "attribute @s minecraft:generic.max_health base set (max health)" with the STRING variable that we translated from a number in the previous step.
The fourth line takes the text that I saved in the variable "max_health_comand" from before and executes the comand in Minecraft in the name of the entity. Wich increases it's max health by half a heart.
The rest it's just to test if it worked. For this you can translate the current max health of the target entity to text and then save it to another variable called "hp".
Then you send your self a message that includes that new "hp" to make sure the max health of the entity is increasing.
I will link here two pages from where you can get:
How to wirite in the comand the attributes that you can modify
And this one has some useful comands, including a comand to turn on WATER DAMAGE wich is another issue that I've seen in the topics.
but most importantly that last page has this wich is something very important when runing comands:
Target selector shortcuts
@p – nearest player
@r – random player
@a – all players
@e – all entities
@s – the entity executing the command
Target selector variables set a specific target without typing out their full name. Above are the five different shorthand commands.
Well that's the end of this tutorial. If there is something you don't understand or I didn't explain something clearly enough please leave a coment and I'll try to answer your question to the best of my abilities. Good luck ;)
Oh! I almost forgot I will leave this video here too. This video explains how to change attributes in older versions of minecraft as well as the 1.16 version