-
Notifications
You must be signed in to change notification settings - Fork 0
Prepend
PeerHeer edited this page Dec 31, 2019
·
14 revisions
Prepending to a list can be done using the data modify command, which is built-in and not used by Dynamic NBT Lists. For dynamic uses, you can use data modify storage|block|entity <identifier> <path> prepend from storage|block|entity <identifier> <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 list ExampleList: ["foo", "Hello World!", "foo", "bar"] in the listutils:examples storage. We want to prepend the string "baz" to it:
data modify storage listutils:examples ExampleList prepend value "baz"This will result in the list ExampleList: ["baz", "foo", "Hello World!", "foo", "bar"].