Skip to content

Commit 0c28448

Browse files
authored
🔀 Merge 🐛 Cameras and locators are missing the majority of their tags (#393)
2 parents b3f9e83 + e9aece3 commit 0c28448

File tree

10 files changed

+300
-151
lines changed

10 files changed

+300
-151
lines changed

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,13 @@ dir <%export_namespace%> {
251251
}
252252
}
253253
IF (animation.frames.some(v => v.variant)) {
254-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data modify storage aj:temp variant set from storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
255-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run function *<%export_namespace%>/animations/<%animation.safe_name%>/zzz/apply_variant with storage aj:temp variant
256-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data remove storage aj:temp variant
254+
$execute \
255+
if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant \
256+
unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] \
257+
run { with storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
258+
#ARGS: {name: string, condition: string}
259+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
260+
}
257261
}
258262
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
259263
}
@@ -269,15 +273,13 @@ dir <%export_namespace%> {
269273
}
270274
}
271275
IF (animation.frames.some(v => v.variant)) {
272-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data modify storage aj:temp variant set from storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
273-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run function *<%export_namespace%>/animations/<%animation.safe_name%>/zzz/apply_variant with storage aj:temp variant
274-
$execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data remove storage aj:temp variant
275-
}
276-
}
277-
IF (animation.frames.some(v => v.variant)) {
278-
function apply_variant {
279-
#ARGS: {name: string, condition: string}
280-
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
276+
$execute \
277+
if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant \
278+
unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] \
279+
run { with storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
280+
#ARGS: {name: string, condition: string}
281+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
282+
}
281283
}
282284
}
283285
} ELSE {
@@ -411,7 +413,7 @@ dir <%export_namespace%> {
411413
#Args: {args:{variant: string, animation: string, frame: int, start_animation: boolean}}
412414
# frame is ignored unless animation is specified.
413415

414-
data modify storage aj:temp args set value {frame: 0}
416+
data modify storage aj:temp args set value {variant:'', animation:'', frame: 0}
415417
$execute store success score #success <%OBJECTIVES.I()%> run data modify storage aj:temp args set value $(args)
416418

417419
summon minecraft:item_display ~ ~ ~ { \
@@ -433,13 +435,23 @@ dir <%export_namespace%> {
433435
function *global/internal/gu/convert_uuid_array_to_string with entity @s
434436
data modify entity @s data.bones.data_data set from storage aj:uuid main.out
435437

436-
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator')) as locator {
438+
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
437439
IF (locator.config && locator.config.use_entity) {
438-
summon <%locator.config.entity_type%> ~ ~ ~ {Tags:['<%TAGS.NEW()%>', '<%TAGS.GLOBAL_LOCATOR()%>', '<%TAGS.PROJECT_LOCATOR(export_namespace)%>', '<%TAGS.PROJECT_LOCATOR_NAMED(export_namespace, locator.name)%>']}
440+
summon <%locator.config.entity_type%> \
441+
^<%locator.default_transform.pos[0]%> \
442+
^<%locator.default_transform.pos[1]%> \
443+
^<%locator.default_transform.pos[2]%> \
444+
{Tags:<%getNodeTags(locator, rig)%>}
439445
execute as @e[type=<%locator.config.entity_type%>,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_LOCATOR()%>,limit=1,distance=..0.01] run {
440446
tag @s remove <%TAGS.NEW()%>
441447

442448
function *global/internal/gu/convert_uuid_array_to_string with entity @s
449+
tp @s \
450+
^<%roundTo(locator.default_transform.pos[0], 10)%> \
451+
^<%roundTo(locator.default_transform.pos[1], 10)%> \
452+
^<%roundTo(locator.default_transform.pos[2], 10)%> \
453+
~<%roundTo(locator.default_transform.head_rot[1], 10)%> \
454+
~<%roundTo(locator.default_transform.head_rot[0], 10)%>
443455
<%%
444456
if (locator.config.summon_commands) {
445457
emit.mcb(locator.config.summon_commands)
@@ -451,24 +463,31 @@ dir <%export_namespace%> {
451463
}
452464

453465
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'camera')) as camera {
454-
summon item_display ~ ~ ~ {Tags:['<%TAGS.NEW()%>', '<%TAGS.GLOBAL_CAMERA()%>', '<%TAGS.PROJECT_CAMERA(export_namespace)%>', '<%TAGS.PROJECT_CAMERA(export_namespace, camera.name)%>'], teleport_duration: 2}
466+
summon item_display \
467+
^<%camera.default_transform.pos[0]%> \
468+
^<%camera.default_transform.pos[1]%> \
469+
^<%camera.default_transform.pos[2]%> \
470+
{Tags:<%getNodeTags(camera, rig)%>, teleport_duration: 2}
455471
execute as @e[type=item_display,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_CAMERA()%>,limit=1,distance=..0.01] run {
456472
tag @s remove <%TAGS.NEW()%>
457-
458473
function *global/internal/gu/convert_uuid_array_to_string with entity @s
474+
tp @s \
475+
^<%roundTo(camera.default_transform.pos[0], 10)%> \
476+
^<%roundTo(camera.default_transform.pos[1], 10)%> \
477+
^<%roundTo(camera.default_transform.pos[2], 10)%> \
478+
~<%roundTo(camera.default_transform.head_rot[1], 10)%> \
479+
~<%roundTo(camera.default_transform.head_rot[0], 10)%>
459480
}
460481
data modify entity @s data.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
461482
}
462483

463-
REPEAT (Object.values(rig.nodes).filter(v => ['bone', 'text_display', 'item_display', 'block_display'].includes(v.type))) as bone {
464-
execute on vehicle on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, bone.name)%>] run \
484+
REPEAT (Object.values(rig.nodes).filter(v => ['bone', 'text_display', 'item_display', 'block_display'].includes(v.type))) as node {
485+
execute on vehicle on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.name)%>] run \
465486
function *global/internal/gu/convert_uuid_array_to_string with entity @s
466-
data modify entity @s data.bones.<%bone.type + '_' + bone.name%> set from storage aj:uuid main.out
487+
data modify entity @s data.bones.<%node.type + '_' + node.name%> set from storage aj:uuid main.out
467488
}
468489
}
469490

470-
tag @s remove <%TAGS.NEW()%>
471-
472491
# Variant Arguement
473492
IF (Object.keys(rig.variants).length > 1) {
474493
execute if data storage aj:temp args.variant run { with storage aj:temp args
@@ -536,6 +555,9 @@ dir <%export_namespace%> {
536555
%%>
537556
# Custom Summon Commands
538557

558+
tag @s remove <%TAGS.NEW()%>
559+
execute on passengers run tag @s remove <%TAGS.NEW()%>
560+
539561
# Run the on_summon function for the root entity.
540562
function #*<%export_namespace%>/as_root/on_summon
541563
}
@@ -551,7 +573,7 @@ dir <%export_namespace%> {
551573
}
552574
$data modify storage aj:temp command set value '$(command)'
553575
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
554-
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator')) as locator {
576+
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
555577
data modify storage aj:temp uuid set from entity @s data.locators.<%locator.name%>.uuid
556578
block zzz/execute { with storage aj:temp
557579
$execute as $(uuid) run $(command)
@@ -606,9 +628,11 @@ dir <%export_namespace%> {
606628
REPEAT (Object.values(rig.variants)) as variant {
607629
dir <%variant.name%> {
608630
function apply {
609-
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
610-
function *global/errors/function_not_executed_as_root_entity \
611-
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/variants/<%variant.name%>/apply'}
631+
IF (show_function_errors) {
632+
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
633+
function *global/errors/function_not_executed_as_root_entity \
634+
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/variants/<%variant.name%>/apply'}
635+
}
612636
REPEAT (Object.values(rig.nodes)) as node {
613637
IF (node.type === 'bone' && !variant.excluded_nodes.includes(node.uuid) && (variant.models[node.uuid] !== undefined || node.configs.variants[variant.uuid] !== undefined)) {
614638
execute on passengers if entity @s[tag=aj.<%export_namespace%>.bone.<%node.safe_name%>] run {

src/systems/datapackCompiler/1.20.4/static.mcb

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ dir <%export_namespace%> {
102102
$execute store success score #success <%OBJECTIVES.I()%> run data modify storage aj:temp args set value $(args)
103103

104104
summon minecraft:item_display ~ ~ ~ { \
105-
Tags:['<%TAGS.NEW()%>','<%TAGS.GLOBAL_ENTITY()%>','<%TAGS.GLOBAL_ROOT()%>','<%TAGS.PROJECT_ROOT(export_namespace)%>'], \
105+
Tags:[ \
106+
'<%TAGS.NEW()%>', \
107+
'<%TAGS.GLOBAL_ENTITY()%>', \
108+
'<%TAGS.GLOBAL_ROOT()%>', \
109+
'<%TAGS.PROJECT_ENTITY(export_namespace)%>', \
110+
'<%TAGS.PROJECT_ROOT(export_namespace)%>' \
111+
], \
106112
teleport_duration: 0, \
107113
interpolation_duration: <%interpolation_duration%>, \
108114
Passengers:<%root_entity_passengers%>, \
@@ -114,9 +120,13 @@ dir <%export_namespace%> {
114120
function *global/internal/gu/convert_uuid_array_to_string with entity @s
115121
data modify entity @s data.bones.data_data set from storage aj:uuid main.out
116122

117-
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator')) as locator {
123+
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
118124
IF (locator.config && locator.config.use_entity) {
119-
summon <%locator.config.entity_type%> ~ ~ ~ {Tags:['<%TAGS.NEW()%>', '<%TAGS.GLOBAL_LOCATOR()%>', '<%TAGS.PROJECT_LOCATOR(export_namespace)%>', '<%TAGS.PROJECT_LOCATOR_NAMED(export_namespace, locator.name)%>']}
125+
summon <%locator.config.entity_type%> \
126+
^<%locator.default_transform.pos[0]%> \
127+
^<%locator.default_transform.pos[1]%> \
128+
^<%locator.default_transform.pos[2]%> \
129+
{Tags:<%getNodeTags(locator, rig)%>}
120130
execute as @e[type=<%locator.config.entity_type%>,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_LOCATOR()%>,limit=1,distance=..0.01] run {
121131
tag @s remove <%TAGS.NEW()%>
122132

@@ -138,7 +148,11 @@ dir <%export_namespace%> {
138148
}
139149

140150
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'camera')) as camera {
141-
summon item_display ~ ~ ~ {Tags:['<%TAGS.NEW()%>', '<%TAGS.GLOBAL_CAMERA()%>', '<%TAGS.PROJECT_CAMERA(export_namespace)%>', '<%TAGS.PROJECT_CAMERA(export_namespace, camera.name)%>'], teleport_duration: 2}
151+
summon item_display \
152+
^<%camera.default_transform.pos[0]%> \
153+
^<%camera.default_transform.pos[1]%> \
154+
^<%camera.default_transform.pos[2]%> \
155+
{Tags:<%getNodeTags(camera, rig)%>, teleport_duration: 2}
142156
execute as @e[type=item_display,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_CAMERA()%>,limit=1,distance=..0.01] run {
143157
tag @s remove <%TAGS.NEW()%>
144158

@@ -153,15 +167,13 @@ dir <%export_namespace%> {
153167
data modify entity @s data.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
154168
}
155169

156-
REPEAT (Object.values(rig.nodes).filter(v => ['bone', 'text_display', 'item_display', 'block_display'].includes(v.type))) as bone {
157-
execute on vehicle on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, bone.name)%>] run \
170+
REPEAT (Object.values(rig.nodes).filter(v => ['bone', 'text_display', 'item_display', 'block_display'].includes(v.type))) as node {
171+
execute on vehicle on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.name)%>] run \
158172
function *global/internal/gu/convert_uuid_array_to_string with entity @s
159-
data modify entity @s data.bones.<%bone.type + '_' + bone.name%> set from storage aj:uuid main.out
173+
data modify entity @s data.bones.<%node.type + '_' + node.name%> set from storage aj:uuid main.out
160174
}
161175
}
162176

163-
tag @s remove <%TAGS.NEW()%>
164-
165177
# Variant Arguement
166178
IF (Object.keys(rig.variants).length > 1) {
167179
execute if data storage aj:temp args.variant run { with storage aj:temp args
@@ -199,6 +211,9 @@ dir <%export_namespace%> {
199211
%%>
200212
# Custom Summon Commands
201213

214+
tag @s remove <%TAGS.NEW()%>
215+
execute on passengers run tag @s remove <%TAGS.NEW()%>
216+
202217
# Run the on_summon function for the root entity.
203218
function #*<%export_namespace%>/as_root/on_summon
204219
}

0 commit comments

Comments
 (0)