From 980065cb40fad14bc0f17c5669433fdcdd986d01 Mon Sep 17 00:00:00 2001 From: WisW <78122384+winsrewu@users.noreply.github.com> Date: Sat, 14 Jun 2025 17:01:57 +0800 Subject: [PATCH] fix: function as_camera does not work & enhance error handling for it --- src/systems/datapackCompiler/1.20.4/animation.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.20.4/static.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.20.5/animation.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.20.5/static.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.2/animation.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.2/static.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.4/animation.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.4/static.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.5/animation.mcb | 10 ++++++++-- src/systems/datapackCompiler/1.21.5/static.mcb | 10 ++++++++-- src/systems/datapackCompiler/index.ts | 8 ++++++++ 11 files changed, 88 insertions(+), 20 deletions(-) diff --git a/src/systems/datapackCompiler/1.20.4/animation.mcb b/src/systems/datapackCompiler/1.20.4/animation.mcb index a22298b5..a8a2ca9d 100644 --- a/src/systems/datapackCompiler/1.20.4/animation.mcb +++ b/src/systems/datapackCompiler/1.20.4/animation.mcb @@ -808,13 +808,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.20.4/static.mcb b/src/systems/datapackCompiler/1.20.4/static.mcb index a68f25e6..cf053d2c 100644 --- a/src/systems/datapackCompiler/1.20.4/static.mcb +++ b/src/systems/datapackCompiler/1.20.4/static.mcb @@ -361,13 +361,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.20.5/animation.mcb b/src/systems/datapackCompiler/1.20.5/animation.mcb index 987d6c35..556d9b69 100644 --- a/src/systems/datapackCompiler/1.20.5/animation.mcb +++ b/src/systems/datapackCompiler/1.20.5/animation.mcb @@ -808,13 +808,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.20.5/static.mcb b/src/systems/datapackCompiler/1.20.5/static.mcb index 6b474dd2..e6d4d079 100644 --- a/src/systems/datapackCompiler/1.20.5/static.mcb +++ b/src/systems/datapackCompiler/1.20.5/static.mcb @@ -361,13 +361,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.2/animation.mcb b/src/systems/datapackCompiler/1.21.2/animation.mcb index 1e89a4fc..455988f5 100644 --- a/src/systems/datapackCompiler/1.21.2/animation.mcb +++ b/src/systems/datapackCompiler/1.21.2/animation.mcb @@ -808,13 +808,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.2/static.mcb b/src/systems/datapackCompiler/1.21.2/static.mcb index 5e93d120..c9dc5c8a 100644 --- a/src/systems/datapackCompiler/1.21.2/static.mcb +++ b/src/systems/datapackCompiler/1.21.2/static.mcb @@ -361,13 +361,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.4/animation.mcb b/src/systems/datapackCompiler/1.21.4/animation.mcb index 81b14b60..a088912d 100644 --- a/src/systems/datapackCompiler/1.21.4/animation.mcb +++ b/src/systems/datapackCompiler/1.21.4/animation.mcb @@ -808,13 +808,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.4/static.mcb b/src/systems/datapackCompiler/1.21.4/static.mcb index b611a990..ee45fba4 100644 --- a/src/systems/datapackCompiler/1.21.4/static.mcb +++ b/src/systems/datapackCompiler/1.21.4/static.mcb @@ -361,13 +361,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.5/animation.mcb b/src/systems/datapackCompiler/1.21.5/animation.mcb index 237b9e88..afb4ea0a 100644 --- a/src/systems/datapackCompiler/1.21.5/animation.mcb +++ b/src/systems/datapackCompiler/1.21.5/animation.mcb @@ -808,13 +808,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/1.21.5/static.mcb b/src/systems/datapackCompiler/1.21.5/static.mcb index b611a990..ee45fba4 100644 --- a/src/systems/datapackCompiler/1.21.5/static.mcb +++ b/src/systems/datapackCompiler/1.21.5/static.mcb @@ -361,13 +361,19 @@ dir <%export_namespace%> { on passengers \ if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] \ run block zzz/as_camera/as_data { {name: $(name)} - data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name) + $data modify storage aj:temp args.uuid set from entity @s data.cameras.$(name).uuid scoreboard players set #aj.check <%OBJECTIVES.I()%> 0 block execute_as_uuid { with storage aj:temp args $execute as $(uuid) at @s run $(command) scoreboard players set #aj.check <%OBJECTIVES.I()%> 1 } - execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run block if_failed { + block check_existence { with storage aj:temp args + $execute at $(uuid) run scoreboard players set #aj.check <%OBJECTIVES.I()%> 2 + } + execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.CAMERA_NOT_FOUND_ENTITY()%> + execute if score #aj.check <%OBJECTIVES.I()%> matches 2 run tellraw @a <%TELLRAW.COMMAND_RUN_FAILED()%> + } } } } diff --git a/src/systems/datapackCompiler/index.ts b/src/systems/datapackCompiler/index.ts index 7765baa1..b926e9cf 100644 --- a/src/systems/datapackCompiler/index.ts +++ b/src/systems/datapackCompiler/index.ts @@ -647,6 +647,14 @@ namespace TELLRAW { }, TELLRAW_SUFFIX(), ]) + export const COMMAND_RUN_FAILED = () => + new JsonText([ + TELLRAW_PREFIX(), + { text: 'Command ', color: 'red' }, + { nbt: 'args.command', storage: 'aj:temp', color: 'aqua' }, + { text: ' run failed!', color: 'red' }, + TELLRAW_SUFFIX(), + ]) } async function generateRootEntityPassengers(