I'm using 1.12.2 and I want to make a stick give the levitation effect to a player when I smack them, can you help me figure this out? I have no coding knowledge so I can't make datapacks
The code checks if the player has been hurt by any entity (including other players), and checks if that entity was holding a stick with the 'levitation:1' tag. If this is all true it runs the function 'hurt_by_stick' from your datapack. Now you can add some code in that function:
effect give @s levitation 5 2
advancement revoke @s only myepicdatapack:hurt_test
This function (ran when the advancement checking for damage with the stick is dealt) gives the effect for 5 seconds with an amplifier of 2 (can be changed between 0-255) and it removes the testing advancement from the player so that the method can be used again.
I didn't have time to test all this myself, but everything should work. The only things that I'm uncertain about are the custom tags and the advancement.
I'm using 1.12.2 and I want to make a stick give the levitation effect to a player when I smack them, can you help me figure this out? I have no coding knowledge so I can't make datapacks
You can give the player a stick to use for this with a custom tag like so:
Then you can add a custom advancement to a datapack (.json) with any name you want, I chose 'hurt_test.json'. The code is this:
The code checks if the player has been hurt by any entity (including other players), and checks if that entity was holding a stick with the 'levitation:1' tag. If this is all true it runs the function 'hurt_by_stick' from your datapack. Now you can add some code in that function:
This function (ran when the advancement checking for damage with the stick is dealt) gives the effect for 5 seconds with an amplifier of 2 (can be changed between 0-255) and it removes the testing advancement from the player so that the method can be used again.
I didn't have time to test all this myself, but everything should work. The only things that I'm uncertain about are the custom tags and the advancement.
Command FAQ
Minecraft Randomizer DataPack (by Me)