Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-61765

tellraw/books (json-stuff) doesn't work with @e[...] and displaying its score

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 14w28b, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.2-pre1, Minecraft 1.8.2-pre3, Minecraft 1.8.2-pre4, Minecraft 1.8.2-pre6, Minecraft 1.8.2-pre7, Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.7, Minecraft 1.8.8, Minecraft 15w39c, Minecraft 15w44b, Minecraft 15w47c, Minecraft 15w49a, Minecraft 15w49b, Minecraft 15w50a, Minecraft 15w51b, Minecraft 16w02a, Minecraft 16w04a, Minecraft 16w06a
    • Fix Version/s: Minecraft 16w07a
    • Labels:
      None
    • Environment:

      Mac OSX Mavericks 10.9.4 Java 8

    • Confirmation Status:
      Community Consensus

      Description

      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 [Helper] 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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                searge [Mojang] Searge (Michael Stoyke)
                Reporter:
                lennartVH01 lennart van hirtum
              • Votes:
                44 Vote for this issue
                Watchers:
                19 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: