mojira.dev
MC-126523

Selectors in "with" save their value for that specific command

Steps to Reproduce:
1. Create a function tagged in "minecraft:tick".
2. Write in the created function:

execute as @a[tag=bug] run title @a title {"translate":"death.attack.generic","with":[{"selector":"@s"}]}

What I expected to happen was...:
For 1st selector: "(1) died"
For 2nd selector: "(2) died"

What actually happened was...:
For 1st selector: "(1) died"
For 2nd selector: "(1) died"

The video showing this:
https://youtu.be/4OqGOJprpGA

If you don't use the function tagged in "minecraft:tick", it will work fine:
https://youtu.be/YOSgsir7AJw

Linked issues

Comments 7

You have to do:

title @a title {"translate":"death.attack.generic","with":[{"selector":"@a[tag=bug]"}]}

for the command to work as expected. The @a selector changes the executing entity, basically overwriting the previous "as @a[tag=bug]". @s uses the currently selected entity, which in this case is now @a and not @a[tag=bug]. Doing:

execute as @a[tag=bug] run title @s title {"translate":"death.attack.generic","with":[{"selector":"@s"}]}

will not work since I'm assuming you want all players to see a title with the name of another player that died.

«The @a selector changes the executing entity»
It should not work like this.

If you don't use the function tagged in "minecraft:tick", it will work fine:
https://youtu.be/YOSgsir7AJw

Confirmed for 18w14b.

No need to comment with new versions if you can just update it yourself.

I ran

/execute as @e[type=armor_stand] run tellraw @a {"translate":"death.attack.generic","with":[{"selector":"@s"}]}

in chat with 2 armor stands in loaded chunks, both with a different name. Both messages used the same entity.

This tickets is invalid; sorry for the very late realization.

If there’s 2 players selected by tag=bug, the second player will send their title to everyone, overwriting previous titles.

For the valid cases, see the related ticket.

Jerozgen

(Unassigned)

Confirmed

selector, tags, text-component, tick

Minecraft 18w09a, Minecraft 18w14b, Minecraft 18w15a

Retrieved