Skip to content

Commit 26e960f

Browse files
committed
✨ Remove node name type prefix in NBT
1 parent c12deb6 commit 26e960f

11 files changed

Lines changed: 364 additions & 62 deletions

File tree

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ dir animations {
308308
IF (BONE_TYPES.includes(node.type)) {
309309
$execute on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] run \
310310
data modify entity @s {} merge from \
311-
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.type.charAt(0) + '_' + node.storage_name%>
311+
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.storage_name%>
312312
} ELSE IF (node.type === 'locator' || node.type === 'camera') {
313313
$execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run \
314-
$data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> merge from \
315-
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.type.charAt(0) + '_' + node.storage_name%>
314+
$data modify entity @s data.uuids_by_name.<%node.storage_name%> merge from \
315+
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.storage_name%>
316316
}
317317
}
318318

@@ -376,19 +376,20 @@ dir animations {
376376

377377
if (transform.interpolation === 'pre-post' || isStepInterpolation) {
378378
frameFunc +=
379-
`\n$data merge entity $(${node.type + '_' + node.storage_name})%NEWLINE_PATCH%{`
379+
`\n$data merge entity $(${node.storage_name})%NEWLINE_PATCH%{`
380380
+ `transformation: ${matrixToNbtFloatArray(transform.matrix).toString()},`
381381
+ `start_interpolation: ${isStepInterpolation ? -1 : 0},`
382382
+ `interpolation_duration: ${isStepInterpolation ? 0 : interpolation_duration}`
383383
+ `}`
384384
} else {
385385
frameFunc +=
386-
`\n$data merge entity $(${node.type + '_' + node.storage_name})%NEWLINE_PATCH%{`
386+
`\n$data merge entity $(${node.storage_name})%NEWLINE_PATCH%{`
387387
+ `transformation: ${matrixToNbtFloatArray(transform.matrix).toString()},`
388388
+ `start_interpolation: 0,`
389389
+ `interpolation_duration: ${interpolation_duration}`
390390
+ `}`
391391
}
392+
392393
;hasFunction = true
393394
break
394395
}
@@ -408,7 +409,7 @@ dir animations {
408409
if (transform.function) {
409410
if (node.config?.use_entity) {
410411
frameFunc +=
411-
`\n$execute on vehicle unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] as $(${node.type + '_' + node.storage_name}) `
412+
`\n$execute on vehicle unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] as $(${node.storage_name}) `
412413
+ `positioned ^${roundTo(transform.pos[0], 10)} ^${roundTo(transform.pos[1], 10)} ^${roundTo(transform.pos[2], 10)} `
413414
+ `rotated ~${roundTo(transform.head_rot[1], 10)} ~${roundTo(transform.head_rot[0], 10)} `
414415
+ `${transform.function_execute_condition ? transform.function_execute_condition + ' ' : ''}run `
@@ -548,7 +549,7 @@ function summon {
548549
function *global/gu/get_entity_uuid_string
549550
}
550551
data modify entity @s data.uuids append from storage <%gu_storage%> out
551-
data modify entity @s data.uuids_by_name.<%locator.type + '_' + locator.storage_name%> set from storage <%gu_storage%> out
552+
data modify entity @s data.uuids_by_name.<%locator.storage_name%> set from storage <%gu_storage%> out
552553
data modify entity @s data.locators.<%locator.storage_name%>.uuid set from storage <%gu_storage%> out
553554
}
554555

@@ -571,7 +572,7 @@ function summon {
571572
function *global/gu/get_entity_uuid_string
572573
}
573574
data modify entity @s data.uuids append from storage <%gu_storage%> out
574-
data modify entity @s data.uuids_by_name.<%camera.type + '_' + camera.storage_name%> set from storage <%gu_storage%> out
575+
data modify entity @s data.uuids_by_name.<%camera.storage_name%> set from storage <%gu_storage%> out
575576
data modify entity @s data.cameras.<%camera.storage_name%>.uuid set from storage <%gu_storage%> out
576577
}
577578

@@ -584,7 +585,7 @@ function summon {
584585
function *global/gu/get_entity_uuid_string
585586

586587
data modify entity @s data.uuids append from storage <%gu_storage%> out
587-
data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> set from storage <%gu_storage%> out
588+
data modify entity @s data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
588589
}
589590
}
590591

@@ -724,6 +725,39 @@ function summon {
724725
}
725726
}
726727

728+
function as_node {
729+
#ARGS: {name: string, command: string}
730+
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
731+
data remove storage <%temp_storage%> args
732+
$data modify storage <%temp_storage%> args merge value {name:'$(name)', command:'$(command)', uuid:'+MISSING_UUID+'}
733+
734+
IF (debug_mode) {
735+
execute if data storage <%temp_storage%> {args:{name:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('name')%>
736+
execute if data storage <%temp_storage%> {args:{command:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('command')%>
737+
}
738+
739+
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block zzz/as_node/as_data { with storage <%temp_storage%> args
740+
$data modify storage <%temp_storage%> args.uuid set from entity @s data.uuids_by_name.$(name)
741+
IF (debug_mode) {
742+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
743+
}
744+
block execute_as_uuid { with storage <%temp_storage%> args
745+
IF (debug_mode) {
746+
# If the function successfully instantiated, the provided command is valid.
747+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
748+
}
749+
$execute as $(uuid) run return run $(command)
750+
IF (debug_mode) {
751+
# If the entity with the provided UUID doesn't exist, the node wasn't found.
752+
tellraw @a <%TELLRAW.NODE_ENTITY_NOT_FOUND()%>
753+
}
754+
}
755+
IF (debug_mode) {
756+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.NODE_COMMAND_FAILED_TO_EXECUTE()%>
757+
}
758+
}
759+
}
760+
727761
IF (has_entity_locators) {
728762
function as_locator {
729763
#ARGS: {name: string, command: string}

src/systems/datapackCompiler/1.20.4/static.mcb

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function summon {
172172
function *global/gu/get_entity_uuid_string
173173
}
174174
data modify entity @s data.uuids append from storage <%gu_storage%> out
175-
data modify entity @s data.uuids_by_name.<%locator.type + '_' + locator.storage_name%> set from storage <%gu_storage%> out
175+
data modify entity @s data.uuids_by_name.<%locator.storage_name%> set from storage <%gu_storage%> out
176176
data modify entity @s data.locators.<%locator.storage_name%>.uuid set from storage <%gu_storage%> out
177177
}
178178

@@ -195,7 +195,7 @@ function summon {
195195
function *global/gu/get_entity_uuid_string
196196
}
197197
data modify entity @s data.uuids append from storage <%gu_storage%> out
198-
data modify entity @s data.uuids_by_name.<%camera.type + '_' + camera.storage_name%> set from storage <%gu_storage%> out
198+
data modify entity @s data.uuids_by_name.<%camera.storage_name%> set from storage <%gu_storage%> out
199199
data modify entity @s data.cameras.<%camera.storage_name%>.uuid set from storage <%gu_storage%> out
200200
}
201201

@@ -208,7 +208,7 @@ function summon {
208208
function *global/gu/get_entity_uuid_string
209209

210210
data modify entity @s data.uuids append from storage <%gu_storage%> out
211-
data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> set from storage <%gu_storage%> out
211+
data modify entity @s data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
212212
}
213213
}
214214

@@ -300,6 +300,39 @@ function summon {
300300
}
301301
}
302302

303+
function as_node {
304+
#ARGS: {name: string, command: string}
305+
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
306+
data remove storage <%temp_storage%> args
307+
$data modify storage <%temp_storage%> args merge value {name:'$(name)', command:'$(command)', uuid:'+MISSING_UUID+'}
308+
309+
IF (debug_mode) {
310+
execute if data storage <%temp_storage%> {args:{name:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('name')%>
311+
execute if data storage <%temp_storage%> {args:{command:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('command')%>
312+
}
313+
314+
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block zzz/as_node/as_data { with storage <%temp_storage%> args
315+
$data modify storage <%temp_storage%> args.uuid set from entity @s data.uuids_by_name.$(name)
316+
IF (debug_mode) {
317+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
318+
}
319+
block execute_as_uuid { with storage <%temp_storage%> args
320+
IF (debug_mode) {
321+
# If the function successfully instantiated, the provided command is valid.
322+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
323+
}
324+
$execute as $(uuid) run return run $(command)
325+
IF (debug_mode) {
326+
# If the entity with the provided UUID doesn't exist, the node wasn't found.
327+
tellraw @a <%TELLRAW.NODE_ENTITY_NOT_FOUND()%>
328+
}
329+
}
330+
IF (debug_mode) {
331+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.NODE_COMMAND_FAILED_TO_EXECUTE()%>
332+
}
333+
}
334+
}
335+
303336
IF (has_entity_locators) {
304337
function as_locator {
305338
#ARGS: {name: string, command: string}

src/systems/datapackCompiler/1.20.5/animation.mcb

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ dir animations {
308308
IF (BONE_TYPES.includes(node.type)) {
309309
$execute on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] run \
310310
data modify entity @s {} merge from \
311-
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.type.charAt(0) + '_' + node.storage_name%>
311+
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.storage_name%>
312312
} ELSE IF (node.type === 'locator' || node.type === 'camera') {
313313
$execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run \
314-
$data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> merge from \
315-
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.type.charAt(0) + '_' + node.storage_name%>
314+
$data modify entity @s data.uuids_by_name.<%node.storage_name%> merge from \
315+
storage <%project_storage%>/animations <%animation.storage_name%>.$(frame).<%node.storage_name%>
316316
}
317317
}
318318

@@ -376,19 +376,20 @@ dir animations {
376376

377377
if (transform.interpolation === 'pre-post' || isStepInterpolation) {
378378
frameFunc +=
379-
`\n$data merge entity $(${node.type + '_' + node.storage_name})%NEWLINE_PATCH%{`
379+
`\n$data merge entity $(${node.storage_name})%NEWLINE_PATCH%{`
380380
+ `transformation: ${matrixToNbtFloatArray(transform.matrix).toString()},`
381381
+ `start_interpolation: ${isStepInterpolation ? -1 : 0},`
382382
+ `interpolation_duration: ${isStepInterpolation ? 0 : interpolation_duration}`
383383
+ `}`
384384
} else {
385385
frameFunc +=
386-
`\n$data merge entity $(${node.type + '_' + node.storage_name})%NEWLINE_PATCH%{`
386+
`\n$data merge entity $(${node.storage_name})%NEWLINE_PATCH%{`
387387
+ `transformation: ${matrixToNbtFloatArray(transform.matrix).toString()},`
388388
+ `start_interpolation: 0,`
389389
+ `interpolation_duration: ${interpolation_duration}`
390390
+ `}`
391391
}
392+
392393
;hasFunction = true
393394
break
394395
}
@@ -408,7 +409,7 @@ dir animations {
408409
if (transform.function) {
409410
if (node.config?.use_entity) {
410411
frameFunc +=
411-
`\n$execute on vehicle unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] as $(${node.type + '_' + node.storage_name}) `
412+
`\n$execute on vehicle unless entity @s[tag=${TAGS.TRANSFORMS_ONLY()}] as $(${node.storage_name}) `
412413
+ `positioned ^${roundTo(transform.pos[0], 10)} ^${roundTo(transform.pos[1], 10)} ^${roundTo(transform.pos[2], 10)} `
413414
+ `rotated ~${roundTo(transform.head_rot[1], 10)} ~${roundTo(transform.head_rot[0], 10)} `
414415
+ `${transform.function_execute_condition ? transform.function_execute_condition + ' ' : ''}run `
@@ -548,7 +549,7 @@ function summon {
548549
function *global/gu/get_entity_uuid_string
549550
}
550551
data modify entity @s data.uuids append from storage <%gu_storage%> out
551-
data modify entity @s data.uuids_by_name.<%locator.type + '_' + locator.storage_name%> set from storage <%gu_storage%> out
552+
data modify entity @s data.uuids_by_name.<%locator.storage_name%> set from storage <%gu_storage%> out
552553
data modify entity @s data.locators.<%locator.storage_name%>.uuid set from storage <%gu_storage%> out
553554
}
554555

@@ -571,7 +572,7 @@ function summon {
571572
function *global/gu/get_entity_uuid_string
572573
}
573574
data modify entity @s data.uuids append from storage <%gu_storage%> out
574-
data modify entity @s data.uuids_by_name.<%camera.type + '_' + camera.storage_name%> set from storage <%gu_storage%> out
575+
data modify entity @s data.uuids_by_name.<%camera.storage_name%> set from storage <%gu_storage%> out
575576
data modify entity @s data.cameras.<%camera.storage_name%>.uuid set from storage <%gu_storage%> out
576577
}
577578

@@ -584,7 +585,7 @@ function summon {
584585
function *global/gu/get_entity_uuid_string
585586

586587
data modify entity @s data.uuids append from storage <%gu_storage%> out
587-
data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> set from storage <%gu_storage%> out
588+
data modify entity @s data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
588589
}
589590
}
590591

@@ -724,6 +725,39 @@ function summon {
724725
}
725726
}
726727

728+
function as_node {
729+
#ARGS: {name: string, command: string}
730+
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
731+
data remove storage <%temp_storage%> args
732+
$data modify storage <%temp_storage%> args merge value {name:'$(name)', command:'$(command)', uuid:'+MISSING_UUID+'}
733+
734+
IF (debug_mode) {
735+
execute if data storage <%temp_storage%> {args:{name:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('name')%>
736+
execute if data storage <%temp_storage%> {args:{command:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('command')%>
737+
}
738+
739+
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block zzz/as_node/as_data { with storage <%temp_storage%> args
740+
$data modify storage <%temp_storage%> args.uuid set from entity @s data.uuids_by_name.$(name)
741+
IF (debug_mode) {
742+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
743+
}
744+
block execute_as_uuid { with storage <%temp_storage%> args
745+
IF (debug_mode) {
746+
# If the function successfully instantiated, the provided command is valid.
747+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
748+
}
749+
$execute as $(uuid) run return run $(command)
750+
IF (debug_mode) {
751+
# If the entity with the provided UUID doesn't exist, the node wasn't found.
752+
tellraw @a <%TELLRAW.NODE_ENTITY_NOT_FOUND()%>
753+
}
754+
}
755+
IF (debug_mode) {
756+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.NODE_COMMAND_FAILED_TO_EXECUTE()%>
757+
}
758+
}
759+
}
760+
727761
IF (has_entity_locators) {
728762
function as_locator {
729763
#ARGS: {name: string, command: string}

src/systems/datapackCompiler/1.20.5/static.mcb

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function summon {
172172
function *global/gu/get_entity_uuid_string
173173
}
174174
data modify entity @s data.uuids append from storage <%gu_storage%> out
175-
data modify entity @s data.uuids_by_name.<%locator.type + '_' + locator.storage_name%> set from storage <%gu_storage%> out
175+
data modify entity @s data.uuids_by_name.<%locator.storage_name%> set from storage <%gu_storage%> out
176176
data modify entity @s data.locators.<%locator.storage_name%>.uuid set from storage <%gu_storage%> out
177177
}
178178

@@ -195,7 +195,7 @@ function summon {
195195
function *global/gu/get_entity_uuid_string
196196
}
197197
data modify entity @s data.uuids append from storage <%gu_storage%> out
198-
data modify entity @s data.uuids_by_name.<%camera.type + '_' + camera.storage_name%> set from storage <%gu_storage%> out
198+
data modify entity @s data.uuids_by_name.<%camera.storage_name%> set from storage <%gu_storage%> out
199199
data modify entity @s data.cameras.<%camera.storage_name%>.uuid set from storage <%gu_storage%> out
200200
}
201201

@@ -208,7 +208,7 @@ function summon {
208208
function *global/gu/get_entity_uuid_string
209209

210210
data modify entity @s data.uuids append from storage <%gu_storage%> out
211-
data modify entity @s data.uuids_by_name.<%node.type + '_' + node.storage_name%> set from storage <%gu_storage%> out
211+
data modify entity @s data.uuids_by_name.<%node.storage_name%> set from storage <%gu_storage%> out
212212
}
213213
}
214214

@@ -300,6 +300,39 @@ function summon {
300300
}
301301
}
302302

303+
function as_node {
304+
#ARGS: {name: string, command: string}
305+
debug assert executed_as_root_entity <%TAGS.PROJECT_ROOT(export_namespace)%>
306+
data remove storage <%temp_storage%> args
307+
$data modify storage <%temp_storage%> args merge value {name:'$(name)', command:'$(command)', uuid:'+MISSING_UUID+'}
308+
309+
IF (debug_mode) {
310+
execute if data storage <%temp_storage%> {args:{name:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('name')%>
311+
execute if data storage <%temp_storage%> {args:{command:''}} run return run tellraw @a <%TELLRAW.ARGUMENT_CANNOT_BE_EMPTY('command')%>
312+
}
313+
314+
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block zzz/as_node/as_data { with storage <%temp_storage%> args
315+
$data modify storage <%temp_storage%> args.uuid set from entity @s data.uuids_by_name.$(name)
316+
IF (debug_mode) {
317+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 0
318+
}
319+
block execute_as_uuid { with storage <%temp_storage%> args
320+
IF (debug_mode) {
321+
# If the function successfully instantiated, the provided command is valid.
322+
scoreboard players set #aj.check <%OBJECTIVES.I()%> 1
323+
}
324+
$execute as $(uuid) run return run $(command)
325+
IF (debug_mode) {
326+
# If the entity with the provided UUID doesn't exist, the node wasn't found.
327+
tellraw @a <%TELLRAW.NODE_ENTITY_NOT_FOUND()%>
328+
}
329+
}
330+
IF (debug_mode) {
331+
execute if score #aj.check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.NODE_COMMAND_FAILED_TO_EXECUTE()%>
332+
}
333+
}
334+
}
335+
303336
IF (has_entity_locators) {
304337
function as_locator {
305338
#ARGS: {name: string, command: string}

0 commit comments

Comments
 (0)