hey
I've been mucking around with command blocks and I'm having an issue
I know that when executing a coordinate dependant command you can use tildes (~) to use a relative position instead of finding and using the absolute coordinates (eg /summon Zombie ~-23 ~14 ~-6 instead of /summon Zombie bignumber bignumbers bignumbers) which is helpful when you want to use the same command in different command blocks or don't want to find the actual exact coordinates.
However, when using the target selector arguments, there doesn't seem to be a way to do that. For example, I can specify a player detection at precise coordinates using " testfor @p[r=3,x=number,y=number,z=number] " but I can't seem to use relative coordinates instead (so something like testfor @p[r=3,x~-23,7~14,z~-6]).
Is there a way to do this? I've tried using tildes in various ways but to no avail. And if not... why the hell not?
hey
I've been mucking around with command blocks and I'm having an issue
I know that when executing a coordinate dependant command you can use tildes (~) to use a relative position instead of finding and using the absolute coordinates (eg /summon Zombie ~-23 ~14 ~-6 instead of /summon Zombie bignumber bignumbers bignumbers) which is helpful when you want to use the same command in different command blocks or don't want to find the actual exact coordinates.
However, when using the target selector arguments, there doesn't seem to be a way to do that. For example, I can specify a player detection at precise coordinates using " testfor @p[r=3,x=number,y=number,z=number] " but I can't seem to use relative coordinates instead (so something like testfor @p[r=3,x~-23,7~14,z~-6]).
Is there a way to do this? I've tried using tildes in various ways but to no avail. And if not... why the hell not?
I know that this is old, but I have the same problem. I need something like
/testfor @p[x=~,y=~10,z=~,r=1]
some help please!
Unfortuantely, not even for the current (14w03a) 1.8 snapshots, can tildes be used in selector parameters. You currently have no choice but to use exact coordinates (no decimals).
In the 14w03b you can set
/tp @p[x=0,y=0,z=0,dx=10,dy=10,dz=10] 20 20 20
This command wil tp all players in a 10x10x10 squere to that coordinates. Can something like this be done in testfor? Something like:
/testfor @a[x=0,y=0,z=0,dx=10,dy=10,dz=10]
In the 14w03b you can set
/tp @p[x=0,y=0,z=0,dx=10,dy=10,dz=10] 20 20 20
This command wil tp all players in a 10x10x10 squere to that coordinates. Can something like this be done in testfor? Something like:
/testfor @a[x=0,y=0,z=0,dx=10,dy=10,dz=10]
Thanks for answering!
Player selectors (@a, @p, @r) are not exclusive to commands. So yes, you can use that in all other commands that can use a player selector.
In the 14w03b you can set /tp @p[x=0,y=0,z=0,dx=10,dy=10,dz=10] 20 20 20
This command wil tp all players in a 10x10x10 squere to that coordinates. Can something like this be done in testfor? Something like: /testfor @a[x=0,y=0,z=0,dx=10,dy=10,dz=10]
Thanks for answering!
Yes. The way this works is that the x, y, and z selectors designate a static starting point (at one corner of the selection) and the dx, dy, and dz selectors choose an offset from that point (the other corner).
This allows you to make a squared off search area instead of a round area whenever you use a player selector.
However, it still doesn't solve the problem of relative coordinates in player selectors. :/
hi. i have a solution that just might work. In java ( Minecrafts primary element), you can use -= and += when modifying a variable. Mabye it might work with += and
-= instead of~ and -~. also, you mist get rid of the range=3, because that offste is not in a 3 block radius.
so instead of testfor @p[r=3,x~-23,7~14,z~-6], try testfor @p[x-=23,7+=14,z-=6] or mabye @p[x~-=23,7~+=14,z~-=6]. im sorry if im wrong.
ps there is a very easy way to get coordinates (when there is a x y or z selector, like /tp @p tab tab tab nad thhe command will showup as /tp @p <your x coords> <your y coords> <your z coords>).
Can someone help? I typed in /execute ThrownEnderpearl ~ ~ ~ /tp @p ~ ~ ~, but it doesn't seems to work. Also, how can I add range, like /execute ThrownEnderpearl ~ ~ ~ r=100 /tp @p ~ ~ ~.
Can someone help? I typed in /execute ThrownEnderpearl ~ ~ ~ /tp @p ~ ~ ~[/b], but it doesn't seems to work. Also, how can I add range, like /execute ThrownEnderpearl ~ ~ ~ r=100[/i] /tp @p ~ ~ ~.[/b]
Problem is with the usage. Take a closer look at it
/tp @p ~ ~ ~
You specified the target coordinates - for the player @p!
This command will teleport that player to his current coordinates - basically nosthing happens.
You execute from entity of type ThrownEnderpearl - this will ensure that selector r=100 will be searching from enderpearl's position and not the command block's/player's who executes the command.
Next you teleport that player to the entity ThrownEnderpearl.
Also, if there are more entities of type ThrownEnderpearl present, the command may do some pesky stuff, so don't forget to tag your target entity with /scoreboard players tag
You execute from entity of type ThrownEnderpearl - this will ensure that selector r=100 will be searching from enderpearl's position and not the command block's/player's who executes the command.
Next you teleport that player to the entity ThrownEnderpearl.
Also, if there are more entities of type ThrownEnderpearl present, the command may do some pesky stuff, so don't forget to tag your target entity with /scoreboard players tag
I've been mucking around with command blocks and I'm having an issue
I know that when executing a coordinate dependant command you can use tildes (~) to use a relative position instead of finding and using the absolute coordinates (eg /summon Zombie ~-23 ~14 ~-6 instead of /summon Zombie bignumber bignumbers bignumbers) which is helpful when you want to use the same command in different command blocks or don't want to find the actual exact coordinates.
However, when using the target selector arguments, there doesn't seem to be a way to do that. For example, I can specify a player detection at precise coordinates using " testfor @p[r=3,x=number,y=number,z=number] " but I can't seem to use relative coordinates instead (so something like testfor @p[r=3,x~-23,7~14,z~-6]).
Is there a way to do this? I've tried using tildes in various ways but to no avail. And if not... why the hell not?
/testfor @p[x=~,y=~10,z=~,r=1]
some help please!
Unfortuantely, not even for the current (14w03a) 1.8 snapshots, can tildes be used in selector parameters. You currently have no choice but to use exact coordinates (no decimals).
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
/tp @p[x=0,y=0,z=0,dx=10,dy=10,dz=10] 20 20 20
This command wil tp all players in a 10x10x10 squere to that coordinates. Can something like this be done in testfor? Something like:
/testfor @a[x=0,y=0,z=0,dx=10,dy=10,dz=10]
Thanks for answering!
Player selectors (@a, @p, @r) are not exclusive to commands. So yes, you can use that in all other commands that can use a player selector.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Yes. The way this works is that the x, y, and z selectors designate a static starting point (at one corner of the selection) and the dx, dy, and dz selectors choose an offset from that point (the other corner).
This allows you to make a squared off search area instead of a round area whenever you use a player selector.
However, it still doesn't solve the problem of relative coordinates in player selectors. :/
Has anybody added this into a suggestion thread? If not I can.
EDIT: I put in a bug report
https://bugs.mojang.com/browse/MC-58966
Amazingly, this still hasn't been fixed…
But here's a suggestion post: Post
Vote it up, and this may be solved.
So am I wrong or can you add a selector using scoreboard teams? Like tp @p [Team=Team1] or something like that?
ya I was just giving an example
hi. i have a solution that just might work. In java ( Minecrafts primary element), you can use -= and += when modifying a variable. Mabye it might work with += and
-= instead of~ and -~. also, you mist get rid of the range=3, because that offste is not in a 3 block radius.
so instead of testfor @p[r=3,x~-23,7~14,z~-6], try testfor @p[x-=23,7+=14,z-=6] or mabye @p[x~-=23,7~+=14,z~-=6]. im sorry if im wrong.
ps there is a very easy way to get coordinates (when there is a x y or z selector, like /tp @p tab tab tab nad thhe command will showup as /tp @p <your x coords> <your y coords> <your z coords>).
I think the easies solution is to use /execute
Here is an example:Link
My recent creation
- Apocalyptic Disasters - Command block mod
My best Minigame
- Hangman
My best one command creation
- 1.9 Jetpack in minecraft
Can someone help? I typed in /execute ThrownEnderpearl ~ ~ ~ /tp @p ~ ~ ~, but it doesn't seems to work. Also, how can I add range, like /execute ThrownEnderpearl ~ ~ ~ r=100 /tp @p ~ ~ ~.
tp is always relative to the player
also you can only execute a player or @p, @a, @r or @e
@e is a entity so use this instead of ThrownEnderpearl:
@e[type=ThrownEnderpearl]
Last is you want a radius the you need to add it to the thing or person you want to do something to so change @p to:
@p[r=100]
so you would need run this on a clock:
/execute @e[type=ThrownEnderpearl] ~ ~ ~ /tp @p[r=100] @e[type=ThrownEnderpearl,c=1]
This will tp the nearest player in a radius of 100 of a enderpearl to the enderpearl.
My recent creation
- Apocalyptic Disasters - Command block mod
My best Minigame
- Hangman
My best one command creation
- 1.9 Jetpack in minecraft
Problem is with the usage. Take a closer look at it
/tp @p ~ ~ ~
You specified the target coordinates - for the player @p!
This command will teleport that player to his current coordinates - basically nosthing happens.
Correct way of doing it is
/execute @e[type=ThrownEnderpearl] ~ ~ ~ /tp @p[r=100] @e[type=ThrownEnderpearl]
You execute from entity of type ThrownEnderpearl - this will ensure that selector r=100 will be searching from enderpearl's position and not the command block's/player's who executes the command.
Next you teleport that player to the entity ThrownEnderpearl.
Also, if there are more entities of type ThrownEnderpearl present, the command may do some pesky stuff, so don't forget to tag your target entity with /scoreboard players tag
(1.12) Command 1: /summon armor_stand ~-23 ~14 ~-6 {CustomName:"AS",NoGravity:1b,Invisible:1b,Marker:1b}
Command 2: execute @e[name=AS] ~ ~ ~ testfor @p[r=3]
will execute the position of the armor_stand and testfor @p at the position of the armorstand
SOLVED!
*I know this is 5yeazrs to late xD*
/execute @p[r=100] ~ ~ ~ /tp @e[c=1] @e[type=ThrownEnderpearl]