mojira.dev
MC-124717

'execute store' ignores value validation

The bug

/execute store ignores value validation, allowing you to set values which would be considered invalid when used in the respective command.

Partially relevant /r/Mojira discussion

Affected situations

  • bossbar max

  • bossbar value

  • read-only scoreboard objectives

How to reproduce

bossbar max
  1. Create a bossbar

    /bossbar add custom:test "test"
  2. Try setting a negative maximum

    /bossbar set custom:test max -1

    → ✔ It fails as expected

  3. Create a scoreboard objective and set a negative score

    /scoreboard objectives add test dummy
    /scoreboard players set value test -1
  4. Try storing the score as bossbar max

    /execute store result bossbar custom:test max run scoreboard players get value test
  5. Get the bossbar max

    /bossbar get custom:test max

    → ❌ It shows -1

Read only scoreboard objectives
  1. Create a read only scoreboard objective and have it displayed on the sidebar

    /scoreboard objectives add health health
    /scoreboard objectives setdisplay sidebar health
  2. Take damage or heal to update the score (see MC-111729)

  3. Try setting a value for the health objective

    /scoreboard players set @s health -1

    → ✔ It fails as expected

  4. Create a scoreboard objective and set a negative score

    /scoreboard objectives add test dummy
    /scoreboard players set value test -1
  5. Try storing the score as value for the read-only objective

    /execute store result score @s health run scoreboard players get value test

    → ❌ Your health score changed to -1

Linked issues

Comments

migrated

Confirm for 18w22c

 I tried to do some tests directly with NBT tags with the following commands in minecraft:repeating_command_block:

/execute store result bossbar foo:bar value run data get entity @e[type=minecraft:pig,limit=1,sort=nearest] Health
/execute store result bossbar foo:bar max run data get entity @e[type=minecraft:pig,limit=1,sort=nearest] Attributes[0].Base

When you create bossbar before executing previous commands and after you execute commands, no problems, it works.

But when the targeted entity dies, it broken.

After that, I tried another test with only "set value" of bossbar and no problems even if the targeted entity die and after yo summon another entity.

I think the problem is when you set the max value in the same time you set the value of the bossbar.

the only way I found to solve this problem is to remove the bossbar and recreate it.

migrated

New fact, it's only a visual bug, when you test with the "get" command, these are the expected values.
And when you quit the world et reopen it, the problem is solved.

migrated

Confirm for 1.13-pre1
 I found the best way to fix it, just set the visibility to false, and after reset to true, it works but not as expected by the game ...

migrated

Confirm for 1.13-pre2

migrated

Confirmed for 1.13.1.

Avoma

Can confirm in 21w03a.

Avoma

Can confirm in 21w06a.

marcono1234

(Unassigned)

Confirmed

Platform

Low

Commands

/bossbar, /execute-store, read-only-scoreboard-objectives

Minecraft 18w05a, Minecraft 18w20c, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, ..., 20w09a, 21w03a, 1.16.5, 21w06a, 1.21.5

Retrieved