Skip to content

Commit d1814d7

Browse files
authored
🔀 Merge #487: ✨ Add as_root function
2 parents f6ed15f + c3beb06 commit d1814d7

12 files changed

Lines changed: 299 additions & 5 deletions

File tree

‎src/systems/datapackCompiler/1.20.4/animation.mcb‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
10331062
dir remove {
10341063
function all {
10351064
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.20.4/global.mcbt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ template debug {
55
tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR(context.functions.at(-1), root_tag)%>
66
}
77
}
8+
with assert:literal executed_as_entity_with_root_uuid_data:literal {
9+
IF (debug_mode) {
10+
execute unless data entity @s data.root_uuid run return run \
11+
tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ENTITY_WITH_ROOT_UUID_ERROR(context.functions.at(-1))%>
12+
}
13+
}
814
}

‎src/systems/datapackCompiler/1.20.4/static.mcb‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,29 @@ IF (has_cameras) {
605605
}
606606
}
607607

608+
function as_root {
609+
#ARGS: {command: string}
610+
debug assert executed_as_entity_with_root_uuid_data
611+
612+
$data modify storage <%temp_storage%> args.command set value '$(command)'
613+
data modify storage <%temp_storage%> args.root_uuid set from entity @s data.root_uuid
614+
615+
IF (debug_mode) {
616+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
617+
}
618+
block as_root_entity { with storage <%temp_storage%> args
619+
$execute as $(root_uuid) run $(command)
620+
IF (debug_mode) {
621+
# If the function successfully instantiated, the provided command is valid.
622+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
623+
}
624+
}
625+
IF (debug_mode) {
626+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.ROOT_COMMAND_FAILED_TO_EXECUTE()%>
627+
}
628+
629+
}
630+
608631
dir remove {
609632
function all {
610633
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.20.5/animation.mcb‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
10331062
dir remove {
10341063
function all {
10351064
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.20.5/static.mcb‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,29 @@ IF (has_cameras) {
605605
}
606606
}
607607

608+
function as_root {
609+
#ARGS: {command: string}
610+
debug assert executed_as_entity_with_root_uuid_data
611+
612+
$data modify storage <%temp_storage%> args.command set value '$(command)'
613+
data modify storage <%temp_storage%> args.root_uuid set from entity @s data.root_uuid
614+
615+
IF (debug_mode) {
616+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
617+
}
618+
block as_root_entity { with storage <%temp_storage%> args
619+
$execute as $(root_uuid) run $(command)
620+
IF (debug_mode) {
621+
# If the function successfully instantiated, the provided command is valid.
622+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
623+
}
624+
}
625+
IF (debug_mode) {
626+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.ROOT_COMMAND_FAILED_TO_EXECUTE()%>
627+
}
628+
629+
}
630+
608631
dir remove {
609632
function all {
610633
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.21.0/animation.mcb‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
10331062
dir remove {
10341063
function all {
10351064
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.21.0/static.mcb‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,29 @@ IF (has_cameras) {
605605
}
606606
}
607607

608+
function as_root {
609+
#ARGS: {command: string}
610+
debug assert executed_as_entity_with_root_uuid_data
611+
612+
$data modify storage <%temp_storage%> args.command set value '$(command)'
613+
data modify storage <%temp_storage%> args.root_uuid set from entity @s data.root_uuid
614+
615+
IF (debug_mode) {
616+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
617+
}
618+
block as_root_entity { with storage <%temp_storage%> args
619+
$execute as $(root_uuid) run $(command)
620+
IF (debug_mode) {
621+
# If the function successfully instantiated, the provided command is valid.
622+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
623+
}
624+
}
625+
IF (debug_mode) {
626+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.ROOT_COMMAND_FAILED_TO_EXECUTE()%>
627+
}
628+
629+
}
630+
608631
dir remove {
609632
function all {
610633
# Removes all instances of this rig from the world.

‎src/systems/datapackCompiler/1.21.2/animation.mcb‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
10331062
dir remove {
10341063
function all {
10351064
# Removes all instances of this rig from the world.

0 commit comments

Comments
 (0)