@@ -524,7 +524,9 @@ function summon {
524524 function *global/gu/get_entity_uuid_string
525525 execute at @s on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block as_data_entity {
526526 # Rig Root UUID
527+ data modify storage <%temp_storage%> root_uuid set from storage <%gu_storage%> out
527528 data modify entity @s data.uuids append from storage <%gu_storage%> out
529+ data modify entity @s data.root_uuid set from storage <%gu_storage%> out
528530 # Data Entity UUID
529531 function *global/gu/get_entity_uuid_string
530532 data modify entity @s data.uuids append from storage <%gu_storage%> out
@@ -547,6 +549,7 @@ function summon {
547549 # run block ../as_locator/<%locator.storage_name%> {
548550 tag @s remove <%TAGS.NEW()%>
549551 function *global/gu/get_entity_uuid_string
552+ data modify entity @s data.root_uuid set from storage <%temp_storage%> root_uuid
550553 }
551554 data modify entity @s data.uuids append from storage <%gu_storage%> out
552555 data modify entity @s data.uuids_by_name.<%locator.storage_name%> set from storage <%gu_storage%> out
@@ -570,6 +573,7 @@ function summon {
570573 # run block ../as_camera/<%camera.storage_name%> {
571574 tag @s remove <%TAGS.NEW()%>
572575 function *global/gu/get_entity_uuid_string
576+ data modify entity @s data.root_uuid set from storage <%temp_storage%> root_uuid
573577 }
574578 data modify entity @s data.uuids append from storage <%gu_storage%> out
575579 data modify entity @s data.uuids_by_name.<%camera.storage_name%> set from storage <%gu_storage%> out
@@ -581,8 +585,10 @@ function summon {
581585 on vehicle \
582586 on passengers \
583587 if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
584- run \
588+ run block as_node/<%node.storage_name%> {
585589 function *global/gu/get_entity_uuid_string
590+ data modify entity @s data.root_uuid set from storage <%temp_storage%> root_uuid
591+ }
586592
587593 data modify entity @s data.uuids append from storage <%gu_storage%> out
588594 data modify entity @s data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
@@ -1030,6 +1036,29 @@ IF (has_cameras) {
10301036 }
10311037}
10321038
1039+ function as_root {
1040+ #ARGS: {command: string}
1041+ debug assert executed_as_entity_with_root_uuid_data
1042+
1043+ $data modify storage <%temp_storage%> args.command set value '$(command)'
1044+ data modify storage <%temp_storage%> args.root_uuid set from entity @s data.root_uuid
1045+
1046+ IF (debug_mode) {
1047+ scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
1048+ }
1049+ block as_root_entity { with storage <%temp_storage%> args
1050+ $execute as $(root_uuid) run $(command)
1051+ IF (debug_mode) {
1052+ # If the function successfully instantiated, the provided command is valid.
1053+ scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
1054+ }
1055+ }
1056+ IF (debug_mode) {
1057+ execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.ROOT_COMMAND_FAILED_TO_EXECUTE()%>
1058+ }
1059+
1060+ }
1061+
10331062dir remove {
10341063 function all {
10351064 # Removes all instances of this rig from the world.
0 commit comments