@@ -705,15 +705,19 @@ dir <%export_namespace%> {
705705 function *global/errors/function_not_executed_as_root_entity \
706706 {'export_namespace': '<%export_namespace%>', 'function_path': '<%arguments[1].functions.at(-1)%>'}
707707 }
708- $data modify storage aj:temp args.command set value '$(command)'
708+ data remove storage aj:temp args
709+ $data modify storage aj:temp args merge value {name:'$(name)', command:'$(command)'}
709710 $execute \
710711 on passengers \
711712 if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \
712713 run block zzz/as_locator/as_data { {name: $(name)}
713714 $data modify storage aj:temp args.uuid set from entity @s data.uuids.locator_$(name)
715+ scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
714716 block execute_as_uuid { with storage aj:temp args
715- $execute as $(uuid) run $(command)
717+ $execute as $(uuid) at @s run $(command)
718+ scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
716719 }
720+ execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND_ENTITY()%>
717721 }
718722 }
719723
@@ -731,7 +735,57 @@ dir <%export_namespace%> {
731735 REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
732736 data modify storage aj:temp args.uuid set from entity @s data.uuids.<%locator.type + '_' + locator.name%>
733737 block execute_as_uuid { with storage aj:temp args
734- $execute as $(uuid) run $(command)
738+ $execute as $(uuid) at @s run $(command)
739+ }
740+ }
741+ }
742+ }
743+ }
744+
745+ IF (has_locators) {
746+ function at_locator {
747+ #ARGS: {name: string, command: string}
748+ IF (show_function_errors) {
749+ # Assert that the function is being run as the root entity.
750+ execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
751+ function *global/errors/function_not_executed_as_root_entity \
752+ {'export_namespace': '<%export_namespace%>', 'function_path': '<%arguments[1].functions.at(-1)%>'}
753+ }
754+ data remove storage aj:temp args
755+ $data modify storage aj:temp args merge value {name:'$(name)', command:'$(command)'}
756+ $execute \
757+ on passengers \
758+ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \
759+ run block zzz/at_locator/as_data { {name: $(name)}
760+ $execute unless data entity @s {data:{locators:{$(name):{}}}} run return run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND()%>
761+ $data modify storage aj:temp args merge from entity @s data.locators.$(name)
762+ block execute_at_transform { with storage aj:temp args
763+ $execute \
764+ positioned ^$(posx) ^$(posy) ^$(posz) \
765+ rotated ~$(roty) ~$(rotx) \
766+ run $(command)
767+ }
768+ }
769+ }
770+
771+ function at_all_locators {
772+ #ARGS: {command: string}
773+ IF (show_function_errors) {
774+ # Assert that the function is being run as the root entity.
775+ execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
776+ function *global/errors/function_not_executed_as_root_entity \
777+ {'export_namespace': '<%export_namespace%>', 'function_path': '<%arguments[1].functions.at(-1)%>'}
778+ }
779+ data remove storage aj:temp args
780+ $data modify storage aj:temp args.command set value '$(command)'
781+ execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block zzz/at_all_locators/as_data {
782+ REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
783+ data modify storage aj:temp args merge from entity @s data.locators.<%locator.name%>
784+ block execute_at_transform { with storage aj:temp args
785+ $execute \
786+ positioned ^$(posx) ^$(posy) ^$(posz) \
787+ rotated ~$(roty) ~$(rotx) \
788+ run $(command)
735789 }
736790 }
737791 }
0 commit comments