-
Notifications
You must be signed in to change notification settings - Fork 0
Extend
PeerHeer edited this page Dec 31, 2019
·
10 revisions
Extending a list with another list can be done using the data modify command, which is built-in. For dynamic uses, you can use data modify storage|block|entity <identifier> <path> append from storage|block|entity <identifier> <path>[] (note the square brackets in the second path).
Errors that display when executing the command from chat.
| Error | Message |
|---|---|
| Invalid type | Nothing changed, the specified properties already have these values |
| Not a list | Expected list, got: <value> |
execute store result returns the amount of lists that were modified using this operation.
Take the example lists ExampleList: ["foo", "Hello World!", "foo", "bar"] and ExtendList: ["baz", "foo", "bar"] in the listutils:examples storage. We want to extend ExampleList with ExtendList:
data modify storage listutils:examples ExampleList append from storage listutils:examples ExtendList[]This will result in the list ExampleList: ["foo", "Hello World!", "foo", "bar", "baz", "foo", "bar"].