The NBT moving command enables us to move an NBT to another location without deep copying it. It increases the efficiency and flexibility of algorithms involving NBT.
Currently, to move an NBT from α to β, we have to deep copy it from α to β, and then remove it from α. This method is inefficient as the cost of deep copying an NBT is proportional to its tree size. If we can move an NBT in constant time, more algorithms could be implemented efficiently.
In general, shallow copying an NBT causes problematic NBT sharing. However, this problem can be avoided by removing the NBT from the source. Therefore, moving an NBT can be done efficiently by shallow copying.
The following command moves the NBT at <sourcePath> in the storage <source> to <targetPath> in the storage <target>:
/data move storage <target> <targetPath> storage <source> <sourcePath>
As an alternative, we can share the syntax with /data modify under the condition that the value case is disallowed:
/data modify storage <target> <targetPath> move from storage <source> <sourcePath>
Please sign in to leave a comment.
0 Comments