Skip to content

Prepend

PeerHeer edited this page Dec 31, 2019 · 14 revisions

Usage

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

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>

Return values

execute store result returns the amount of lists that were modified using this operation.

Example

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"].

External links

Clone this wiki locally