Started by
Tom45
on
Topic category: Help with Minecraft modding (Java Edition)
Hello I’ve been making some commands however I haven’t been able to work out how to target other players. For example, if I use /speed it will give speed to the player that executes the command. I would like to be able to target a different player for example /speed <player>, but I do not know how to do this. Any help is appreciated.
Thanks
I'm sure the target selector isn't added to MCreator.
I want that function because I'm making a short version of /gamemode, and in Minecraft I can use the target selector to change game mode of a player.
Hello Tom. I would be happy if this feature would be added, but not it's does not exist. Instead, I found a way how to make a selector parameter that allows you to choose a player or an entity. let's make a /speed command!
so we are going to create two commands. one of them will be without an entity parameter, It will give speed to the entity that executed it. we will call it givespeed. the second one is going to execute givespeed on an entity. it's going to run the /execute command on the target entity. we will call this command speed.
our execute command looks like this: execute at (our entity) as @s run givespeed
when we will run speed i'ts going to generate our execute command. it's going to put the target entity command parameter instead of "(our entity)"
let's do this!
step 1
create 2 new commands:
step 2
add the "When command executed" trigger procedure in givespeed:
It will add a speed potion to the entity that executed this command.
step 3
add the "When command executed" trigger procedure in speed:
we are generating an execute command by joining the command parts with command parameter index 0. pay attention! command parameters must have a space between them so write "execute as " and " at @s run givespeed"
this procedure will simulate running givespeed on entities.
step 4
now test it! summon some pigs and some sheeps.
write /speed @e[type=sheep]. watch the particles! only sheep now will have speed effect.
I hope it helped you!
I made the speed command:
https://ibb.co/LJdtfHw
Download link:
https://www.mediafire.com/file/tc1abntqbs0hfx6/speed_command_executed.p…
/execute at @e[type=player,sort=nearest] run effect give @s speed 999 255 true
It worked well for me.
I think it should work for 1.12 and before like this
At <input> its command parameter for selector (player)
/execute <input> ~~~ speed
to the player.