Skip to content

Commit da2c9d0

Browse files
SnaveSutitgitbutler-client
authored andcommitted
🐛 Misc exported Data Pack bugfixes
1 parent 868455a commit da2c9d0

12 files changed

Lines changed: 546 additions & 266 deletions

File tree

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ dir root {
6363

6464
IF (auto_update_rig_orientation) {
6565
IF (has_locators || has_cameras) {
66-
function ./on_tick/transform_floating_entities
66+
function *<%export_namespace%>/root/on_tick/transform_floating_entities
6767
}
6868
execute on passengers run tp @s ~ ~ ~ ~ ~
6969
} ELSE IF (has_ticking_locators) {
70-
function ./on_tick/transform_locators
70+
function *<%export_namespace%>/root/on_tick/transform_locators
7171
}
7272

7373
# Custom post-tick function
@@ -140,7 +140,7 @@ IF (!auto_update_rig_orientation) {
140140

141141
IF (has_locators || has_cameras) {
142142
data_manager prep read
143-
function ./on_tick/transform_floating_entities
143+
function *<%export_namespace%>/root/on_tick/transform_floating_entities
144144
}
145145
execute at @s on passengers run tp @s ~ ~ ~ ~ ~
146146
}
@@ -373,7 +373,7 @@ dir animations {
373373
<%global.transform.function_execute_condition ? global.transform.function_execute_condition + ' ' : ''%>run \
374374
function ./<%animation.duration%>_locator_<%node.storage_name%>
375375
} ELSE {
376-
$execute \
376+
execute \
377377
positioned \
378378
^<%roundTo(global.transform.pos[0], 10)%> \
379379
^<%roundTo(global.transform.pos[1], 10)%> \
@@ -468,7 +468,7 @@ dir animations {
468468
+ `\n}`
469469
} else {
470470
frameFunc +=
471-
`\n$execute unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] `
471+
`\nexecute unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] `
472472
+ `positioned ^${roundTo(transform.pos[0], 10)} ^${roundTo(transform.pos[1], 10)} ^${roundTo(transform.pos[2], 10)} `
473473
+ `rotated ~${roundTo(transform.head_rot[1], 10)} ~${roundTo(transform.head_rot[0], 10)} `
474474
+ `${transform.function_execute_condition ? transform.function_execute_condition + ' ' : ''}run `
@@ -500,7 +500,7 @@ dir animations {
500500
frameFunc += `\ndata modify storage <%temp_storage%> entry.data merge value ${JSON.stringify(to_merge)}`
501501
frameFunc += `\ndata_manager write`
502502
if (!auto_update_rig_orientation) {
503-
frameFunc += `\nfunction ./on_tick/transform_floating_entities`
503+
frameFunc += `\nfunction *${export_namespace}/root/on_tick/transform_floating_entities`
504504
}
505505
hasFunction = true
506506
}
@@ -646,6 +646,20 @@ function summon {
646646
data modify storage <%temp_storage%> entry.data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
647647
}
648648

649+
IF (has_entity_locators) {
650+
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity)) as locator {
651+
block { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
652+
# Track any custom entities on the locator.
653+
$execute at @s as $(uuid) at @s run function *global/util/get_entity_stack_uuids
654+
}
655+
data modify storage <%temp_storage%> entry.data.uuids append from storage <%temp_storage%> uuids
656+
}
657+
}
658+
659+
function *<%export_namespace%>/zzz/set_default_pose
660+
661+
data_manager write
662+
649663
# Variant Arguement
650664
IF (Object.keys(rig.variants).length > 1) {
651665
execute if data storage <%temp_storage%> args.variant run block variant_arg/process { with storage <%temp_storage%> args
@@ -680,8 +694,6 @@ function summon {
680694
}
681695
execute if score #success <%OBJECTIVES.I()%> matches 0 run return fail
682696

683-
function *<%export_namespace%>/zzz/set_default_pose
684-
685697
# Animation Argument
686698
# If the animation argument is provided, attempt to apply the animation.
687699
execute if data storage <%temp_storage%> args.animation run block animation_arg/process { with storage <%temp_storage%> args
@@ -730,7 +742,7 @@ function summon {
730742
execute if score #success <%OBJECTIVES.I()%> matches 0 run return fail
731743

732744
IF (has_locators || has_cameras) {
733-
function ./on_tick/transform_floating_entities
745+
function *<%export_namespace%>/root/on_tick/transform_floating_entities
734746
}
735747
execute on passengers run tp @s ~ ~ ~ ~ ~
736748

@@ -741,15 +753,12 @@ function summon {
741753
IF (has_entity_locators) {
742754
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity && node.config.on_summon_function)) as locator {
743755
block { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
744-
$execute at @s as $(uuid) at @s run block on_summon/<%locator.type + '_' + locator.storage_name%> {
756+
$execute at @s as $(uuid) at @s run block on_summon/custom_<%locator.type + '_' + locator.storage_name%> {
745757
<%%
746758
emit.mcb(locator.config.on_summon_function)
747759
%%>
748-
# Track any custom entities on the locator.
749-
function *global/util/get_entity_stack_uuids
750760
}
751761
}
752-
data modify storage <%temp_storage%> entry.data.uuids append from storage <%temp_storage%> uuids
753762
}
754763
}
755764

@@ -771,7 +780,6 @@ function summon {
771780
}
772781
}
773782

774-
data_manager write
775783
# Remove the NEW tag from the root entity, and it's passengers.
776784
tag @s remove <%TAGS.NEW()%>
777785
execute on passengers run tag @s remove <%TAGS.NEW()%>
@@ -980,7 +988,7 @@ IF (has_locators) {
980988
$data modify storage <%temp_storage%> args merge from storage <%temp_storage%> entry.data.locators.$(name)
981989

982990
IF (debug_mode) {
983-
execute unless data storage <%temp_storage%> args.uuid run return run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND()%>
991+
execute unless data storage <%temp_storage%> args.px run return run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND()%>
984992
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
985993
}
986994

@@ -1166,8 +1174,9 @@ dir remove {
11661174
function without_on_remove_function {
11671175
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
11681176

1177+
data_manager prep read
1178+
11691179
IF (has_entity_locators || has_cameras) {
1170-
data_manager prep read
11711180
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity)) as locator {
11721181
function animated_java:global/remove/entity_stack_by_uuid with entity @s data.locators.<%locator.storage_name%>
11731182
}
@@ -1181,6 +1190,12 @@ dir remove {
11811190
unless data storage <%temp_storage%> {entry:{data:{rig_hash: '<%rig_hash%>'}}} \
11821191
run function animated_java:global/remove/outdated_rig
11831192

1193+
block { with storage <%temp_storage%> entry.data.uuids_by_name
1194+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
1195+
$kill $(<%node.storage_name%>)
1196+
}
1197+
}
1198+
11841199
function animated_java:global/remove/entity_stack
11851200
}
11861201
}
@@ -1254,16 +1269,24 @@ IF (has_locators || has_cameras) {
12541269
function reset_floating_entities {
12551270
IF (has_locators) {
12561271
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator')) as locator {
1257-
execute at @s run block zzz/set_default_pose/as_locator_<%locator.storage_name%> { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
1258-
IF (locator.config?.use_entity) {
1272+
IF (locator.config?.use_entity) {
1273+
execute at @s run block set_default_pose/as_locator_<%locator.storage_name%> { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
12591274
$tp $(uuid) \
12601275
^<%roundTo(locator.default_transform.pos[0], 10)%> \
12611276
^<%roundTo(locator.default_transform.pos[1], 10)%> \
12621277
^<%roundTo(locator.default_transform.pos[2], 10)%> \
12631278
~<%roundTo(locator.default_transform.head_rot[1], 10)%> \
12641279
~<%roundTo(locator.default_transform.head_rot[0], 10)%>
1265-
}
12661280

1281+
data modify storage <%temp_storage%> entry.data.locators.<%locator.storage_name%> merge value { \
1282+
px: <%roundTo(locator.default_transform.pos[0], 10)%>, \
1283+
py: <%roundTo(locator.default_transform.pos[1], 10)%>, \
1284+
pz: <%roundTo(locator.default_transform.pos[2], 10)%>, \
1285+
ry: <%roundTo(locator.default_transform.head_rot[1], 10)%>, \
1286+
rx: <%roundTo(locator.default_transform.head_rot[0], 10)%> \
1287+
}
1288+
}
1289+
} ELSE {
12671290
data modify storage <%temp_storage%> entry.data.locators.<%locator.storage_name%> merge value { \
12681291
px: <%roundTo(locator.default_transform.pos[0], 10)%>, \
12691292
py: <%roundTo(locator.default_transform.pos[1], 10)%>, \
@@ -1277,7 +1300,7 @@ IF (has_locators || has_cameras) {
12771300

12781301
IF (has_cameras) {
12791302
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'camera')) as camera {
1280-
execute at @s run block zzz/set_default_pose/as_camera_<%camera.storage_name%> { with storage <%temp_storage%> entry.data.cameras.<%camera.storage_name%>
1303+
execute at @s run block set_default_pose/as_camera_<%camera.storage_name%> { with storage <%temp_storage%> entry.data.cameras.<%camera.storage_name%>
12811304
$tp $(uuid) \
12821305
^<%roundTo(camera.default_transform.pos[0], 10)%> \
12831306
^<%roundTo(camera.default_transform.pos[1], 10)%> \
@@ -1302,7 +1325,7 @@ IF (has_locators || has_cameras) {
13021325
dir zzz {
13031326
function apply_default_pose {
13041327
IF (has_locators || has_cameras) {
1305-
function ./zzz/reset_floating_entities
1328+
function ../zzz/reset_floating_entities
13061329
}
13071330

13081331
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
@@ -1319,7 +1342,7 @@ dir zzz {
13191342

13201343
function set_default_pose {
13211344
IF (has_locators || has_cameras) {
1322-
function ./zzz/reset_floating_entities
1345+
function ../zzz/reset_floating_entities
13231346
}
13241347

13251348
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {

src/systems/datapackCompiler/1.20.4/static.mcb

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ dir root {
2020

2121
IF (auto_update_rig_orientation) {
2222
IF (has_locators || has_cameras) {
23-
function ./on_tick/transform_floating_entities
23+
function *<%export_namespace%>/root/on_tick/transform_floating_entities
2424
}
2525
execute on passengers run tp @s ~ ~ ~ ~ ~
2626
} ELSE IF (has_ticking_locators) {
27-
function ./on_tick/transform_locators
27+
function *<%export_namespace%>/root/on_tick/transform_locators
2828
}
2929

3030
# Custom post-tick function
@@ -210,6 +210,25 @@ function summon {
210210
data modify storage <%temp_storage%> entry.data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
211211
}
212212

213+
IF (has_entity_locators) {
214+
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity && node.config.on_summon_function)) as locator {
215+
block { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
216+
$execute at @s as $(uuid) at @s run block on_summon/<%locator.type + '_' + locator.storage_name%> {
217+
# Track any custom entities on the locator.
218+
function *global/util/get_entity_stack_uuids
219+
<%%
220+
emit.mcb(locator.config.on_summon_function)
221+
%%>
222+
}
223+
}
224+
data modify storage <%temp_storage%> entry.data.uuids append from storage <%temp_storage%> uuids
225+
}
226+
}
227+
228+
function *<%export_namespace%>/zzz/set_default_pose
229+
230+
data_manager write
231+
213232
# Variant Arguement
214233
IF (Object.keys(rig.variants).length > 1) {
215234
execute if data storage <%temp_storage%> args.variant run block variant_arg/process { with storage <%temp_storage%> args
@@ -244,9 +263,8 @@ function summon {
244263
}
245264
execute if score #success <%OBJECTIVES.I()%> matches 0 run return fail
246265

247-
function *<%export_namespace%>/zzz/set_default_pose
248266
IF (has_locators || has_cameras) {
249-
function ./on_tick/transform_floating_entities
267+
function *<%export_namespace%>/root/on_tick/transform_floating_entities
250268
}
251269
execute on passengers run tp @s ~ ~ ~ ~ ~
252270

@@ -257,15 +275,12 @@ function summon {
257275
IF (has_entity_locators) {
258276
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity && node.config.on_summon_function)) as locator {
259277
block { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
260-
$execute at @s as $(uuid) at @s run block on_summon/<%locator.type + '_' + locator.storage_name%> {
278+
$execute at @s as $(uuid) at @s run block on_summon/custom_<%locator.type + '_' + locator.storage_name%> {
261279
<%%
262280
emit.mcb(locator.config.on_summon_function)
263281
%%>
264-
# Track any custom entities on the locator.
265-
function *global/util/get_entity_stack_uuids
266282
}
267283
}
268-
data modify storage <%temp_storage%> entry.data.uuids append from storage <%temp_storage%> uuids
269284
}
270285
}
271286

@@ -287,7 +302,6 @@ function summon {
287302
}
288303
}
289304

290-
data_manager write
291305
# Remove the NEW tag from the root entity, and it's passengers.
292306
tag @s remove <%TAGS.NEW()%>
293307
execute on passengers run tag @s remove <%TAGS.NEW()%>
@@ -496,7 +510,7 @@ IF (has_locators) {
496510
$data modify storage <%temp_storage%> args merge from storage <%temp_storage%> entry.data.locators.$(name)
497511

498512
IF (debug_mode) {
499-
execute unless data storage <%temp_storage%> args.uuid run return run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND()%>
513+
execute unless data storage <%temp_storage%> args.px run return run tellraw @a <%TELLRAW.LOCATOR_NOT_FOUND()%>
500514
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
501515
}
502516

@@ -682,8 +696,9 @@ dir remove {
682696
function without_on_remove_function {
683697
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
684698

699+
data_manager prep read
700+
685701
IF (has_entity_locators || has_cameras) {
686-
data_manager prep read
687702
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator' && node.config?.use_entity)) as locator {
688703
function animated_java:global/remove/entity_stack_by_uuid with entity @s data.locators.<%locator.storage_name%>
689704
}
@@ -697,6 +712,12 @@ dir remove {
697712
unless data storage <%temp_storage%> {entry:{data:{rig_hash: '<%rig_hash%>'}}} \
698713
run function animated_java:global/remove/outdated_rig
699714

715+
block { with storage <%temp_storage%> entry.data.uuids_by_name
716+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
717+
$kill $(<%node.storage_name%>)
718+
}
719+
}
720+
700721
function animated_java:global/remove/entity_stack
701722
}
702723
}
@@ -770,16 +791,24 @@ IF (has_locators || has_cameras) {
770791
function reset_floating_entities {
771792
IF (has_locators) {
772793
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'locator')) as locator {
773-
execute at @s run block zzz/set_default_pose/as_locator_<%locator.storage_name%> { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
774-
IF (locator.config?.use_entity) {
794+
IF (locator.config?.use_entity) {
795+
execute at @s run block set_default_pose/as_locator_<%locator.storage_name%> { with storage <%temp_storage%> entry.data.locators.<%locator.storage_name%>
775796
$tp $(uuid) \
776797
^<%roundTo(locator.default_transform.pos[0], 10)%> \
777798
^<%roundTo(locator.default_transform.pos[1], 10)%> \
778799
^<%roundTo(locator.default_transform.pos[2], 10)%> \
779800
~<%roundTo(locator.default_transform.head_rot[1], 10)%> \
780801
~<%roundTo(locator.default_transform.head_rot[0], 10)%>
781-
}
782802

803+
data modify storage <%temp_storage%> entry.data.locators.<%locator.storage_name%> merge value { \
804+
px: <%roundTo(locator.default_transform.pos[0], 10)%>, \
805+
py: <%roundTo(locator.default_transform.pos[1], 10)%>, \
806+
pz: <%roundTo(locator.default_transform.pos[2], 10)%>, \
807+
ry: <%roundTo(locator.default_transform.head_rot[1], 10)%>, \
808+
rx: <%roundTo(locator.default_transform.head_rot[0], 10)%> \
809+
}
810+
}
811+
} ELSE {
783812
data modify storage <%temp_storage%> entry.data.locators.<%locator.storage_name%> merge value { \
784813
px: <%roundTo(locator.default_transform.pos[0], 10)%>, \
785814
py: <%roundTo(locator.default_transform.pos[1], 10)%>, \
@@ -793,7 +822,7 @@ IF (has_locators || has_cameras) {
793822

794823
IF (has_cameras) {
795824
REPEAT (Object.values(rig.nodes).filter(node => node.type === 'camera')) as camera {
796-
execute at @s run block zzz/set_default_pose/as_camera_<%camera.storage_name%> { with storage <%temp_storage%> entry.data.cameras.<%camera.storage_name%>
825+
execute at @s run block set_default_pose/as_camera_<%camera.storage_name%> { with storage <%temp_storage%> entry.data.cameras.<%camera.storage_name%>
797826
$tp $(uuid) \
798827
^<%roundTo(camera.default_transform.pos[0], 10)%> \
799828
^<%roundTo(camera.default_transform.pos[1], 10)%> \
@@ -818,7 +847,7 @@ IF (has_locators || has_cameras) {
818847
dir zzz {
819848
function set_default_pose {
820849
IF (has_locators || has_cameras) {
821-
function ./zzz/reset_floating_entities
850+
function ../zzz/reset_floating_entities
822851
}
823852

824853
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {

0 commit comments

Comments
 (0)