The bug
When I use /data get
with a path of an array with a negative index, it says An unexpected error occurred trying to execute that command
. There isn't any further information in the logs.
How to reproduce
Type in that command for example:
/data get entity @s Inventory[-1]
Comments 5
I will also make one comment: with an increasing number of id's withing the game becoming strings instead of values, I feel like it might be a good idea to add filter expressions to use within /date get and /execute store. It's currently impossible to specifically select an entry from an array based on string ids. Previously you could just use /execute store and identify the entry based on the value, but now it's impossible to do this as string ids can have the same character lengths.
Here's what a basic filter expression might look like:
/data get entity @s SelectedItem.tag.Enchantments[?(@.id == "minecraft:looting")].lvl
Which would search for entries in the array containing "id":"minecraft:looting" with the filter and return 3. (I just used the logic from JsonPath).
affects 1.13-pre5
I enchanted a sword with tag:
/data get entity @s SelectedItem.tag.Enchantments[-1].lvl
Command should result in 3 but gives an error.