-
Bug
-
Resolution: Unresolved
-
None
-
1.21.4, 25w02a
-
Community Consensus
-
Commands
The bug
Some commands, such as /data get, will round decimals down as their result. Other commands, such as /attribute ... get, will truncate decimals to a whole number, resulting in an inconsistency for handling negative numbers.
Affected commands
Commands that truncate decimals:
- /attribute ... get ...
- /execute store ... (byte|short|int|long) <decimal_scale>
- /worldborder add <distance>
Commands that round decimals down:
- /data get ...
The results for inserting decimals into integer arrays are also inconsistent, which has been reported in MC-276879, so I will skip them.
Ways to reproduce
To reproduce, you can either:
- Install the attached data pack, and run /function mc-279197:test to see whether -7.3 is rounded to -7 or -8
- Follow the steps below to test the specific cases between /data and /attribute
Steps to reproduce
- Summon a cow with a maximum health of 7.3
/summon cow ~ ~ ~ {attributes: [{id: "minecraft:max_health", base: 7.3d}]}
- Create a scoreboard
/scoreboard objectives add MC-279197 dummy /scoreboard objectives setdisplay sidebar MC-279197
- Attempt to store the maximum health via /data and /attribute
/execute store result score data_get MC-279197 run data get entity @n[type=cow] attributes[{id: "minecraft:max_health"}].base -1 /execute store result score attribute_get MC-279197 run attribute @n[type=cow] minecraft:max_health get -1
- Take note as to whether these two commands have consistent behavior for rounding negative numbers.
Observed results
/data rounds the result down to -8, while /attribute truncates the result to -7.
Expected results
The results of /data and /attribute should be the same, both being -7 or -8.
- relates to
-
MC-276879 Floats are truncated when cast to longs with /data, all other cases round down
- Open