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

Using /trigger first time on player gives score of 0 but not displayed on scoreboard

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.5, Minecraft 1.8.6, Minecraft 15w45a, Minecraft 15w46a, Minecraft 15w49b, Minecraft 15w50a, Minecraft 15w51b, Minecraft 16w03a, Minecraft 16w04a, Minecraft 16w05a, Minecraft 16w05b, Minecraft 16w06a, Minecraft 16w07a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 1.9.4, Minecraft 16w21a, Minecraft 1.10 Pre-Release 2, Minecraft 1.10, Minecraft 16w35a, Minecraft 16w39c, Minecraft 1.11, Minecraft 1.11.2, Minecraft 17w15a, Minecraft 17w16a, Minecraft 1.12 Pre-Release 2, Minecraft 1.12, Minecraft 1.12.2, Minecraft 17w46a
    • Fix Version/s: Minecraft 17w47a
    • Confirmation Status:
      Confirmed

      Description

      The bug

      Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but does not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.

      How to reproduce

      1. Add scoreboard objective
        /scoreboard objectives add test trigger
      2. Set sidebar display
        /scoreboard objectives setdisplay sidebar test
      3. Enable trigger
        /scoreboard players enable @a test
      4. Notice score does not display on side bar but player has score of 0
        /say @a[score_test_min=0]
      5. Remove scoreboard display
        /scoreboard objectives setdisplay sidebar
      6. Put back display
        /scoreboard objectives setdisplay sidebar test
      7. Notice score is now displaying as 0 for player

      Code analysis

      The problem is that the game creates a Score object when enabling a trigger for a player who has no score. As the score value inside the Score object is stored as an int, its default value is 0 (see MC-107049). Creating a Score object does not send a packet to the player. Changing this would cause the server to send a packet twice is you set a value for a player who had no Score object before, which could cause problems. A solution might be to store the score as an Integer. Then the default value would be null. Some methods would need to be changed then to test if the player has a Score object and the score value is not null instead of testing if the Score object is null.

      A problem which should appear already is that using /scoreboard players reset also disables the trigger as it removes the Score object. With the suggested change a parameter like resetScore could be added which only sets the score of the Score object to null and by that remains the trigger state.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dinnerbone [Mojang] Nathan Adams
                Reporter:
                onnowhere Onnowhere
              • Votes:
                7 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: