tellraw/books (json-stuff) doesn't work with @e[...] and displaying its score
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player and the entity
What actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectors
Steps to reproduce:
Create a new flat world type "redstoneready", to make sure no mobs spawn
Spawn a Pig
/scoreboard objectives add test dummy /scoreboard objectives setdisplay sidebar test /scoreboard players set @e test 1
Now you should have two players in the sidebar that have a score of 1 for objective test
After this, do the following tellraws:
/tellraw @a {"score":{"name":"@p","objective":"test"}}
/tellraw @a {"score":{"name":"@e[type=Pig]","objective":"test"}}
This displays "1" for the first tellraw, but displays a blank line for the second tellraw
You can do another tellraw to test if the @e selector specifically is broken:
/tellraw @a {"score":{"name":"@e[type=Player]","objective":"test"}}
Displays "1" aswell, showing that this is actually a problem with entity's specifically.
From Marcono1234's comment:
I used MCP to decompile Minecraft and had a look in the corresponding class and I think I found the problem.
For some reason the game creates two net.minecraft.util.ChatComponentScore, one that contains the raw input and then one that contains the parsed name and then uses the second one to display the score.However for the parsed one it uses the getName() method. This means for an ArmorStand for example it will return "Armor Stand" which is of course neither a valid player name nor a valid UUID.
To fix this some code would be needed to make the game use the UUID instead of the name when an entity is selected.
Possible fix (1.8)List var6 = PlayerSelector.func_179656_b(p_179985_0_, var5, Entity.class); if (var6.size() != 1) { throw new EntityNotFoundException(); } Entity selectorEntity = ((Entity)var6.get(0)); if (selectorEntity instanceof EntityPlayerMP) { var5 = selectorEntity.getName(); } else { var5 = selectorEntity.getUniqueID().toString(); }This is the only code change needed. The wildcard parsing will work the way it currently is (if I understand it correctly), as the recipient can currenlty only be a player (for entities it fails as it would then use the name again). However for the future it might be a good idea to change this as well.
Environment
Mac OSX Mavericks 10.9.4 Java 8
Linked Issues
is duplicated by5
Created Issue:
tellraw/books (json-stuff) doesn't work with @e[...] and displaying its score
I want to display a score of an entity via /tellraw but it doesn't show up in the chat.
How to reproduce:
1. I made a scoreboard objective (wood) and set the score for an entity with a custom name to 7 (for example).
2. via/say @e[score_wood_min=7]i get back the Custom name of the entity. Everything ok.
3. Now i wanted to display its score (used commandblock because its to long for the chat):/tellraw @a {"text":"","extra":[{"score":{"name":"@e[score_wood_min=7]","objective":"wood"}}]}In the chat appears a "blank" line.
Also doesn't work with books and other json-related stuff where something is stored in entities and not in (Fake)Playernames.
Environment
Mac OSX Mavericks 10.9.4 Java 8
is duplicated by
I want to display a score of an entity via /tellraw but it doesn't show up in the chat.
How to reproduce:
1. I made a scoreboard objective (wood) and set the score for an entity with a custom name to 7 (for example).
2. via/say @e[score_wood_min=7]
i get back the Custom name of the entity. Everything ok.
3. Now i wanted to display its score (used commandblock because its to long for the chat):/tellraw @a {"text":"","extra":[{"score":{"name":"@e[score_wood_min=7]","objective":"wood"}}]}In the chat appears a "blank" line.
Also doesn't work with books and other json-related stuff where something is stored in entities and not in (Fake)Playernames.
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player, the fake player and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectors
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for theplayer, the fakeplayer and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectorsWhen displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectorsSteps to reproduce:
Create a new flat world type "redstoneready", to make sure no mobs spawn
Spawn a Pig/scoreboard objectives add test dummy /scoreboard objectives setdisplay sidebar test /scoreboard players set @e test 1Now you should have two players in the sidebar that have a score of 1 for objective test
After this, do the following tellraws:/tellraw @a {score:{name:'@p',objective:test}} /tellraw @a {score:{name:'@e[type=Pig]',objective:test}}This displays "1" for the first tellraw, but displays a blank line for the second tellraw
You can do another tellraw to test if the @e selector specifically is broken:/tellraw @a {score:{name:'@e[type=Player]',objective:test}}Displays "1" aswell, showing that this is actually a problem with entity's specifically.
is duplicated by
is duplicated by
relates to
is duplicated by
relates to
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectorsSteps to reproduce:
Create a new flat world type "redstoneready", to make sure no mobs spawn
Spawn a Pig/scoreboard objectives add test dummy /scoreboard objectives setdisplay sidebar test /scoreboard players set @e test 1Now you should have two players in the sidebar that have a score of 1 for objective test
After this, do the following tellraws:/tellraw @a {score:{name:'@p',objective:test}} /tellraw @a {score:{name:'@e[type=Pig]',objective:test}}This displays "1" for the first tellraw, but displays a blank line for the second tellraw
You can do another tellraw to test if the @e selector specifically is broken:/tellraw @a {score:{name:'@e[type=Player]',objective:test}}Displays "1" aswell, showing that this is actually a problem with entity's specifically.
From Marcono1234's comment:
I used MCP to decompile Minecraft and had a look in the corresponding class and I think I found the problem.
For some reason the game creates two net.minecraft.util.ChatComponentScore, one that contains the raw input and then one that contains the parsed name and then uses the second one to display the score.However for the parsed one it uses the getName() method. This means for an ArmorStand for example it will return "Armor Stand" which is of course neither a valid player name nor a valid UUID.
To fix this some code would be needed to make the game use the UUID instead of the name when an entity is selected.
Possible fix (1.8)List var6 = PlayerSelector.func_179656_b(p_179985_0_, var5, Entity.class); if (var6.size() != 1) { throw new EntityNotFoundException(); } Entity selectorEntity = ((Entity)var6.get(0)); if (selectorEntity instanceof EntityPlayerMP) { var5 = selectorEntity.getName(); } else { var5 = selectorEntity.getUniqueID().toString(); }This is the only code change needed. The wildcard parsing will work the way it currently is (if I understand it correctly), as the recipient can currenlty only be a player (for entities it fails as it would then use the name again). However for the future it might be a good idea to change this as well.
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectorsSteps to reproduce:
Create a new flat world type "redstoneready", to make sure no mobs spawn
Spawn a Pig/scoreboard objectives add test dummy /scoreboard objectives setdisplay sidebar test /scoreboard players set @e test 1Now you should have two players in the sidebar that have a score of 1 for objective test
After this, do the following tellraws:/tellraw @a {score:{name:'@p',objective:test}} /tellraw @a {score:{name:'@e[type=Pig]',objective:test}}This displays "1" for the first tellraw, but displays a blank line for the second tellraw
You can do another tellraw to test if the @e selector specifically is broken:/tellraw @a {score:{name:'@e[type=Player]',objective:test}}Displays "1" aswell, showing that this is actually a problem with entity's specifically.
From Marcono1234's comment:
I used MCP to decompile Minecraft and had a look in the corresponding class and I think I found the problem.
For some reason the game creates two net.minecraft.util.ChatComponentScore, one that contains the raw input and then one that contains the parsed name and then uses the second one to display the score.However for the parsed one it uses the getName() method. This means for an ArmorStand for example it will return "Armor Stand" which is of course neither a valid player name nor a valid UUID.
To fix this some code would be needed to make the game use the UUID instead of the name when an entity is selected.
Possible fix (1.8)List var6 = PlayerSelector.func_179656_b(p_179985_0_, var5, Entity.class); if (var6.size() != 1) { throw new EntityNotFoundException(); } Entity selectorEntity = ((Entity)var6.get(0)); if (selectorEntity instanceof EntityPlayerMP) { var5 = selectorEntity.getName(); } else { var5 = selectorEntity.getUniqueID().toString(); }This is the only code change needed. The wildcard parsing will work the way it currently is (if I understand it correctly), as the recipient can currenlty only be a player (for entities it fails as it would then use the name again). However for the future it might be a good idea to change this as well.
When displaying an entity's score in chat, it will not display.
However, when using a player or a fake player, it works just fine.
What I expected to happen:
The chat would display "1" for the player and the entityWhat actually happened:
The chat displays a "1" for the player and any fake player, but doesn't with selectorsSteps to reproduce:
Create a new flat world type "redstoneready", to make sure no mobs spawn
Spawn a Pig/scoreboard objectives add test dummy /scoreboard objectives setdisplay sidebar test /scoreboard players set @e test 1Now you should have two players in the sidebar that have a score of 1 for objective test
After this, do the following tellraws:/tellraw @a {"score":{"name":"@p","objective":"test"}} /tellraw @a {"score":{"name":"@e[type=Pig]","objective":"test"}}This displays "1" for the first tellraw, but displays a blank line for the second tellraw
You can do another tellraw to test if the @e selector specifically is broken:/tellraw @a {"score":{"name":"@e[type=Player]","objective":"test"}}Displays "1" aswell, showing that this is actually a problem with entity's specifically.
From Marcono1234's comment:
I used MCP to decompile Minecraft and had a look in the corresponding class and I think I found the problem.
For some reason the game creates two net.minecraft.util.ChatComponentScore, one that contains the raw input and then one that contains the parsed name and then uses the second one to display the score.However for the parsed one it uses the getName() method. This means for an ArmorStand for example it will return "Armor Stand" which is of course neither a valid player name nor a valid UUID.
To fix this some code would be needed to make the game use the UUID instead of the name when an entity is selected.
Possible fix (1.8)List var6 = PlayerSelector.func_179656_b(p_179985_0_, var5, Entity.class); if (var6.size() != 1) { throw new EntityNotFoundException(); } Entity selectorEntity = ((Entity)var6.get(0)); if (selectorEntity instanceof EntityPlayerMP) { var5 = selectorEntity.getName(); } else { var5 = selectorEntity.getUniqueID().toString(); }This is the only code change needed. The wildcard parsing will work the way it currently is (if I understand it correctly), as the recipient can currenlty only be a player (for entities it fails as it would then use the name again). However for the future it might be a good idea to change this as well.
Still doesnt work in 14w29b.
But now it returns that the entity cant be found. What i did to test it:
Note:
9is a WitherSkull with a Custom Name./tellraw @a {"text":"","extra":[{"score":{"name":"@e[score_wood_min=1]","objective":"wood"}}]}Result: Chat says "That entity cannot be found"
yo yo yo, doesn't work in 1.8 confirmedamundo. Tried to use it on a sign and no dice.
cannot confirm.
That
/scoreboard objective add test dummy /scoreboard players set @p test 1 /tellraw @a {"text":"","extra":[{"score":{"name":"@e[score_test_min=1]","objective":"test"}}]}displays "1"
The How to reproduce is incorrect, it should be:
Create a flat world, preferably redstoneready so that no animals can spawn
Spawn a Pig
/scoreboard objectives add temp dummy /scoreboard players set @e[type=Pig] temp 5 /scoreboard players set @p temp 5 /tellraw @a {score:{name:'@p',objective:'temp'}} /tellraw @a {score:{name:'@e[type=Pig,c=1]',objective:'temp'}}The first tellraw outputs the number 5
The second tellraw outputs an empty line
As you can see it works with selectors, but it just works for players and not for other entity's
Also, this is still an issue in the latest version of minecraft: (Minecraft-1.8.1)
Please reopen as this is still an issue in the current version of minecraft: 1.8.1
Still an issue in the current version of minecraft: Minecraft 1.8.2-pre1
@lennart van hirtum: I made you the reporter of this ticket, so you may update the version and edit the description.
@Sebastian K: Please complain, if you have a problem with that.
Still an issue in the current version of minecraft: 1.8.2-pre4
Still an issue in the current version of minecraft: 1.8.2-pre6
Can confirm that this affects 1.8.2-pre7 too.
Still an issue in minecraft 1.8.3
Confirmed for
Confirmed for 1.8.7 as well.
Confirmed for
Confirmed for 15w39c. Also, it indeed works correctly when evaluating entity UUIDs typed directly. It seems to be only a problem with the selectors.
I used MCP to decompile Minecraft and had a look in the corresponding class and I think I found the problem.
Please add the following to the description:
For some reason the game creates two net.minecraft.util.ChatComponentScore, one that contains the raw input and then one that contains the parsed name and then uses the second one to display the score. However for the parsed one it uses the getName() method. This means for an ArmorStand for example it will return "Armor Stand" which is of course neither a valid player name nor a valid UUID.
To fix this some code would be needed to make the game use the UUID instead of the name when an entity is selected.
This is the only code change needed. The wildcard parsing will work the way it currently is (if I understand it correctly), as the recipient can currenlty only be a player (for entities it fails as it would then use the name again). However for the future it might be a good idea to change this as well.
Confirmed in 15w44b. The workaround for now is to use /scoreboard players operation to copy the value over to a #fake player and then use that, but it's a bit cumbersome; this bug is worth fixing.
Updated for 15w47c & updated tellraws to strict JSON
Confirmed for 16w04a.
Confirmed for
Confirmed fixed for 16w07a