Allow the /data modify to do math, similar to the /scoreboard players operation.
For example:
/data modify entity @s Items[0].Count math += value 10
The structure of the command would be the same, except instead of specifying "set", "append", "insert" etc... you specify "math" instead.
This would then be followed by the math operation, similar to the scoreboard operations.
- +=, -=, *=, /=, %=, <, >
I would also suggest a couple others:
- ^= Power
- |= Root
The final part of the command would be the value, which similar to the other parameters, can be "value" or "from".
Why would this be useful?
Currently in order to modify data values, you need to store in a score, do operations, and then store back into data.
However, this limitation has 2 major problems:
- Doubles, floats and Longs lose precision.
- Three commands are executed for each operation
The /data modify math parameter would be only 1 command, and you can work directly with doubles, floats and Longs.
Working with arrays
The biggest advantage would be able to modify all values in an array, with only 1 command.
You can use a command such as /data modify block ~ ~ ~ Items[{id:"minecraft:dirt"].Count set value 10 to set all stack sizes, for dirt, in a chest to 10. This means that all values in an array are modified.
You cannot add or subtract to all values. A command like /data modify block ~ ~ ~ Items[{id:"minecraft:dirt"].Count math += value 1 would allow you to alter all the values.
Please sign in to leave a comment.
3 Comments