Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-184867

addExperience() method does not remove XP levels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.21.20.24 Preview, 1.21.30.22 Preview
    • None
    • Confirmed
    • Windows

      Explanation

      The Player method "addExperience" only removes the player's XP until the level cap is reached. For example, if a player is at XP level 5 and calls the method: :addExperience(-500) It will not change the player's level, instead they will be at level 5 with no extra XP.

      It should also be noted that unlike negative parameters, using positive parameters can increment the player's level. This test is also done using the 1.15-beta scripting version.

       

      Steps to Replicate

      1. Download the add-on
      2. Open Minecraft Preview 1.21.20.24
      3. Create a world using this add-on
      4. Use command: "give @s sky:skulk_battery"
      5. Use the item, which uses a custom component, to run the following line that will increase or decrease XP based on a 50% percent chance.

      Math.random() < 0.5 ? arg.source.addExperience(1000) : arg.source.addExperience(-1000);

      1. Notice how the XP level never decreases for the player.

       

            skywalker756 Tony Lysander
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: