Skip to content

Commit f40e5d5

Browse files
committed
🩹 Fix inconsistencies between animation and static mcb files
1 parent 920cb80 commit f40e5d5

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

src/systems/datapackCompiler/1.21.4/animation.mcb

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,17 +432,26 @@ dir <%export_namespace%> {
432432
execute store result score @s <%OBJECTIVES.ID()%> run scoreboard players add aj.last_id <%OBJECTIVES.ID()%> 1
433433

434434
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
435-
436435
function *global/internal/gu/convert_uuid_array_to_string with entity @s
437436
data modify entity @s data.bones.data_data set from storage aj:uuid main.out
438437

439438
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator')) as locator {
440439
IF (locator.config && locator.config.use_entity) {
441-
summon <%locator.config.entity_type%> ~ ~ ~ {Tags:<%getNodeTags(locator, rig)%>}
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)%>}
442445
execute as @e[type=<%locator.config.entity_type%>,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_LOCATOR()%>,limit=1,distance=..0.01] run {
443446
tag @s remove <%TAGS.NEW()%>
444447

445448
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)%>
446455
<%%
447456
if (locator.config.summon_commands) {
448457
emit.mcb(locator.config.summon_commands)
@@ -454,10 +463,20 @@ dir <%export_namespace%> {
454463
}
455464

456465
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'camera')) as camera {
457-
summon item_display ~ ~ ~ {Tags:<%getNodeTags(camera, rig)%>, 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}
458471
execute as @e[type=item_display,tag=<%TAGS.NEW()%>,tag=<%TAGS.GLOBAL_CAMERA()%>,limit=1,distance=..0.01] run {
459472
tag @s remove <%TAGS.NEW()%>
460473
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)%>
461480
}
462481
data modify entity @s data.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
463482
}
@@ -609,9 +628,11 @@ dir <%export_namespace%> {
609628
REPEAT (Object.values(rig.variants)) as variant {
610629
dir <%variant.name%> {
611630
function apply {
612-
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
613-
function *global/errors/function_not_executed_as_root_entity \
614-
{'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+
}
615636
REPEAT (Object.values(rig.nodes)) as node {
616637
IF (node.type === 'bone' && !variant.excluded_nodes.includes(node.uuid) && (variant.models[node.uuid] !== undefined || node.configs.variants[variant.uuid] !== undefined)) {
617638
execute on passengers if entity @s[tag=aj.<%export_namespace%>.bone.<%node.safe_name%>] run {

src/systems/datapackCompiler/1.21.4/static.mcb

Lines changed: 23 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%>, \
@@ -116,7 +122,11 @@ dir <%export_namespace%> {
116122

117123
REPEAT (Object.values(rig.nodes).filter(v => v.type === 'locator')) as locator {
118124
IF (locator.config && locator.config.use_entity) {
119-
summon <%locator.config.entity_type%> ^<%locator.default_transform.pos[0]%> ^<%locator.default_transform.pos[1]%> ^<%locator.default_transform.pos[2]%> {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,10 +148,13 @@ 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()%>
144-
145158
function *global/internal/gu/convert_uuid_array_to_string with entity @s
146159
tp @s \
147160
^<%roundTo(camera.default_transform.pos[0], 10)%> \
@@ -153,15 +166,13 @@ dir <%export_namespace%> {
153166
data modify entity @s data.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
154167
}
155168

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 \
169+
REPEAT (Object.values(rig.nodes).filter(v => ['bone', 'text_display', 'item_display', 'block_display'].includes(v.type))) as node {
170+
execute on vehicle on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.name)%>] run \
158171
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
172+
data modify entity @s data.bones.<%node.type + '_' + node.name%> set from storage aj:uuid main.out
160173
}
161174
}
162175

163-
tag @s remove <%TAGS.NEW()%>
164-
165176
# Variant Arguement
166177
IF (Object.keys(rig.variants).length > 1) {
167178
execute if data storage aj:temp args.variant run { with storage aj:temp args
@@ -199,6 +210,9 @@ dir <%export_namespace%> {
199210
%%>
200211
# Custom Summon Commands
201212

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

0 commit comments

Comments
 (0)