- check_circle Functions
Published May 7th, 2020, 5/7/20 9:11 pm
- 4,900 views, 1 today
- 220 downloads, 0 today
48
=========Track Player=========
Simple player tracking
Simple player tracking
/trigger TrackSwitch
To switch tracking on and off
Trail updates every 5 ticks
Trail last for 30 seconds
============================
Trail last for 30 seconds
============================
Compatibility | Minecraft 1.15 |
to | Minecraft 1.16 |
Tags |
4588121
119
Create an account or sign in to comment.
summon minecraft:area_effect_cloud ~ ~.1 ~ {Particle:"dust 1 0 0 .5"Radius:.5f,Duration:600,Tags:["trackbot"]}
this is the summoning code, I'll break it down:
summon minecraft:area_effect_cloud ~ ~.1 ~ {} the command to summon the cloud at the location of the target, in this case i want it to be at a target with the score of 1 (meaning on for this datapack) for TrackSwitch, so you would add this to the begining:
/execute at @p[scores={TrackSwitch=1}] run summon minecraft:area_effect_cloud ~ ~.1 ~ {Particle:"dust 1 0 0 .5"Radius:.5f,Duration:600,Tags:["trackbot"]}
Particle: Any kind of particle in the game can be used, in this case I used the Dust particle (note, unlike the other types of particles, the Dust particle needs to be told extra information which is why I put "dust 1 0 0 .5" the first 3 numbers represent RGB color, in this case I made it red, the fourth number is the size, normal is 1 so I made it 1/2 smaller, or .5)
Radius: how big the cloud would appear, normally at size 1 it is a 2x2 area, so I made it size .5 so it could be 1x1 matching the block's size
Duration: Is the amount of time (in ticks) that the entity will stay alive, this case 600 ticks will last for 30 seconds (20 ticks = 1 second). After when time is up, the area effect cloud will despawn
Tags: This part isn't that all important, I mainly use tags so I can locate that type of entity I created for commands like /kill @e[tag=trackbot]
After that its just a matter of putting this command on a timer, I used the scoreboard command to put mine on a 5 tick timer (every 1/4 of a second) with commands like this:
/execute as @p[scores={TrackSwitch=1}] run
scoreboard players add @s TrackPlayer 1
/execute as @p[scores={TrackPlayer=5}] run
function track:on
/execute as @p[scores={TrackPlayer=6..}] run
scoreboard players set @s TrackPlayer 1
The first command is to make the score TrackPlayer increase by 1 every tick if the TrackSwitch is on (at 1)
The Second command is to run a function, in this case the summon command, every time the scoreboard for TrackPlayer is at 5 (meaning 5 ticks have passed)
The Third command is to reset the score TrackPlayer to 1 whenever it passes 6, so an infinite loop happens
hope this was helpful!
https://textcraft.net/