Mojira Archive
MCPE-184867

addExperience() method does not remove XP levels

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.

 

Awaiting Response

Tony Lysander

2024-08-02, 07:48 PM

2024-12-03, 11:11 AM

2024-12-03, 11:11 AM

0

1

Confirmed

1.21.20.24 Preview, 1.21.30.22 Preview

-