Skip to content

Commit 800a907

Browse files
committed
🐛 Fix display entity config not respecting on-summon and on-apply functions
1 parent b6571c5 commit 800a907

File tree

10 files changed

+140
-7
lines changed

10 files changed

+140
-7
lines changed

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ function summon {
695695
}
696696
}
697697

698+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
699+
execute \
700+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
701+
run block node_on_summon_<%node.storage_name%> {
702+
<%%
703+
emit.mcb(node.on_summon_function.trim())
704+
%%>
705+
}
706+
}
707+
698708
IF (on_summon_function) {
699709
execute at @s run block rig_on_summon {
700710
<%%
@@ -989,6 +999,7 @@ IF (Object.keys(rig.variants).length > 1) {
989999
execute \
9901000
on passengers \
9911001
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
1002+
at @s \
9921003
run \
9931004
block zzz/apply_to_node_<%node.storage_name%> {
9941005
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -1006,6 +1017,11 @@ IF (Object.keys(rig.variants).length > 1) {
10061017
IF (!global.config.isDefault()) {
10071018
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
10081019
}
1020+
IF (global.config.onApplyFunction) {
1021+
<%%
1022+
emit.mcb(global.config.onApplyFunction)
1023+
%%>
1024+
}
10091025
}
10101026
}
10111027
}

src/systems/datapackCompiler/1.20.4/static.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ function summon {
276276
}
277277
}
278278

279+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
280+
execute \
281+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
282+
run block node_on_summon_<%node.storage_name%> {
283+
<%%
284+
emit.mcb(node.on_summon_function.trim())
285+
%%>
286+
}
287+
}
288+
279289
IF (on_summon_function) {
280290
execute at @s run block rig_on_summon {
281291
<%%
@@ -570,6 +580,7 @@ IF (Object.keys(rig.variants).length > 1) {
570580
execute \
571581
on passengers \
572582
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
583+
at @s \
573584
run \
574585
block zzz/apply_to_node_<%node.storage_name%> {
575586
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -587,6 +598,11 @@ IF (Object.keys(rig.variants).length > 1) {
587598
IF (!global.config.isDefault()) {
588599
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
589600
}
601+
IF (global.config.onApplyFunction) {
602+
<%%
603+
emit.mcb(global.config.onApplyFunction)
604+
%%>
605+
}
590606
}
591607
}
592608
}

src/systems/datapackCompiler/1.20.5/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ function summon {
695695
}
696696
}
697697

698+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
699+
execute \
700+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
701+
run block node_on_summon_<%node.storage_name%> {
702+
<%%
703+
emit.mcb(node.on_summon_function.trim())
704+
%%>
705+
}
706+
}
707+
698708
IF (on_summon_function) {
699709
execute at @s run block rig_on_summon {
700710
<%%
@@ -989,6 +999,7 @@ IF (Object.keys(rig.variants).length > 1) {
989999
execute \
9901000
on passengers \
9911001
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
1002+
at @s \
9921003
run \
9931004
block zzz/apply_to_node_<%node.storage_name%> {
9941005
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -1006,6 +1017,11 @@ IF (Object.keys(rig.variants).length > 1) {
10061017
IF (!global.config.isDefault()) {
10071018
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
10081019
}
1020+
IF (global.config.onApplyFunction) {
1021+
<%%
1022+
emit.mcb(global.config.onApplyFunction)
1023+
%%>
1024+
}
10091025
}
10101026
}
10111027
}

src/systems/datapackCompiler/1.20.5/static.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ function summon {
276276
}
277277
}
278278

279+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
280+
execute \
281+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
282+
run block node_on_summon_<%node.storage_name%> {
283+
<%%
284+
emit.mcb(node.on_summon_function.trim())
285+
%%>
286+
}
287+
}
288+
279289
IF (on_summon_function) {
280290
execute at @s run block rig_on_summon {
281291
<%%
@@ -570,6 +580,7 @@ IF (Object.keys(rig.variants).length > 1) {
570580
execute \
571581
on passengers \
572582
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
583+
at @s \
573584
run \
574585
block zzz/apply_to_node_<%node.storage_name%> {
575586
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -587,6 +598,11 @@ IF (Object.keys(rig.variants).length > 1) {
587598
IF (!global.config.isDefault()) {
588599
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
589600
}
601+
IF (global.config.onApplyFunction) {
602+
<%%
603+
emit.mcb(global.config.onApplyFunction)
604+
%%>
605+
}
590606
}
591607
}
592608
}

src/systems/datapackCompiler/1.21.2/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ function summon {
695695
}
696696
}
697697

698+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
699+
execute \
700+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
701+
run block node_on_summon_<%node.storage_name%> {
702+
<%%
703+
emit.mcb(node.on_summon_function.trim())
704+
%%>
705+
}
706+
}
707+
698708
IF (on_summon_function) {
699709
execute at @s run block rig_on_summon {
700710
<%%
@@ -989,6 +999,7 @@ IF (Object.keys(rig.variants).length > 1) {
989999
execute \
9901000
on passengers \
9911001
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
1002+
at @s \
9921003
run \
9931004
block zzz/apply_to_node_<%node.storage_name%> {
9941005
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -1006,6 +1017,11 @@ IF (Object.keys(rig.variants).length > 1) {
10061017
IF (!global.config.isDefault()) {
10071018
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
10081019
}
1020+
IF (global.config.onApplyFunction) {
1021+
<%%
1022+
emit.mcb(global.config.onApplyFunction)
1023+
%%>
1024+
}
10091025
}
10101026
}
10111027
}

src/systems/datapackCompiler/1.21.2/static.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ function summon {
276276
}
277277
}
278278

279+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
280+
execute \
281+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
282+
run block node_on_summon_<%node.storage_name%> {
283+
<%%
284+
emit.mcb(node.on_summon_function.trim())
285+
%%>
286+
}
287+
}
288+
279289
IF (on_summon_function) {
280290
execute at @s run block rig_on_summon {
281291
<%%
@@ -570,6 +580,7 @@ IF (Object.keys(rig.variants).length > 1) {
570580
execute \
571581
on passengers \
572582
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
583+
at @s \
573584
run \
574585
block zzz/apply_to_node_<%node.storage_name%> {
575586
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -587,6 +598,11 @@ IF (Object.keys(rig.variants).length > 1) {
587598
IF (!global.config.isDefault()) {
588599
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
589600
}
601+
IF (global.config.onApplyFunction) {
602+
<%%
603+
emit.mcb(global.config.onApplyFunction)
604+
%%>
605+
}
590606
}
591607
}
592608
}

src/systems/datapackCompiler/1.21.4/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ function summon {
695695
}
696696
}
697697

698+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
699+
execute \
700+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
701+
run block node_on_summon_<%node.storage_name%> {
702+
<%%
703+
emit.mcb(node.on_summon_function.trim())
704+
%%>
705+
}
706+
}
707+
698708
IF (on_summon_function) {
699709
execute at @s run block rig_on_summon {
700710
<%%
@@ -989,6 +999,7 @@ IF (Object.keys(rig.variants).length > 1) {
989999
execute \
9901000
on passengers \
9911001
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
1002+
at @s \
9921003
run \
9931004
block zzz/apply_to_node_<%node.storage_name%> {
9941005
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -1006,6 +1017,11 @@ IF (Object.keys(rig.variants).length > 1) {
10061017
IF (!global.config.isDefault()) {
10071018
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
10081019
}
1020+
IF (global.config.onApplyFunction) {
1021+
<%%
1022+
emit.mcb(global.config.onApplyFunction)
1023+
%%>
1024+
}
10091025
}
10101026
}
10111027
}

src/systems/datapackCompiler/1.21.4/static.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ function summon {
276276
}
277277
}
278278

279+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type) && node.on_summon_function?.trim())) as node {
280+
execute \
281+
on passengers if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
282+
run block node_on_summon_<%node.storage_name%> {
283+
<%%
284+
emit.mcb(node.on_summon_function.trim())
285+
%%>
286+
}
287+
}
288+
279289
IF (on_summon_function) {
280290
execute at @s run block rig_on_summon {
281291
<%%
@@ -570,6 +580,7 @@ IF (Object.keys(rig.variants).length > 1) {
570580
execute \
571581
on passengers \
572582
if entity @s[tag=<%TAGS.PROJECT_NODE_NAMED(export_namespace, node.storage_name)%>] \
583+
at @s \
573584
run \
574585
block zzz/apply_to_node_<%node.storage_name%> {
575586
IF (node.type === 'bone' && variant.models[node.uuid] !== undefined) {
@@ -587,6 +598,11 @@ IF (Object.keys(rig.variants).length > 1) {
587598
IF (!global.config.isDefault()) {
588599
data merge entity @s <%global.config.toNBT(undefined, variant.is_default)%>
589600
}
601+
IF (global.config.onApplyFunction) {
602+
<%%
603+
emit.mcb(global.config.onApplyFunction)
604+
%%>
605+
}
590606
}
591607
}
592608
}

src/systems/rigRenderer.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface IRenderedDisplayEntityNode extends IRenderedNode {
8585
*/
8686
base_scale: number
8787
bounding_box: THREE.Box3
88+
on_summon_function?: string
8889
configs?: IDisplayEntityConfigs
8990
}
9091

@@ -354,7 +355,8 @@ function renderGroup(
354355
parent: parentId,
355356
bounding_box: getNodeBoundingBox(group),
356357
base_scale: 1,
357-
configs: group.configs,
358+
configs: structuredClone(group.configs),
359+
on_summon_function: group.onSummonFunction?.trim(),
358360
// This is a placeholder value that will be updated later once the animation renderer is run.
359361
default_transform: {} as INodeTransform,
360362
}
@@ -464,7 +466,8 @@ function renderItemDisplay(display: VanillaItemDisplay, rig: IRenderedRig) {
464466
item: display.item,
465467
item_display: display.itemDisplay,
466468
base_scale: 1,
467-
configs: display.configs,
469+
configs: structuredClone(display.configs),
470+
on_summon_function: display.onSummonFunction?.trim(),
468471
bounding_box: getNodeBoundingBox(display),
469472
default_transform: {} as INodeTransform,
470473
}
@@ -492,7 +495,8 @@ function renderBlockDisplay(display: VanillaBlockDisplay, rig: IRenderedRig) {
492495
block: display.block,
493496
parent: parentId,
494497
base_scale: 1,
495-
configs: display.configs,
498+
configs: structuredClone(display.configs),
499+
on_summon_function: display.onSummonFunction?.trim(),
496500
bounding_box: getNodeBoundingBox(display),
497501
default_transform: {} as INodeTransform,
498502
}
@@ -527,7 +531,8 @@ function renderTextDisplay(display: TextDisplay, rig: IRenderedRig): INodeStruct
527531
shadow: display.shadow,
528532
see_through: display.seeThrough,
529533
base_scale: 1,
530-
configs: display.configs,
534+
configs: structuredClone(display.configs),
535+
on_summon_function: display.onSummonFunction?.trim(),
531536
bounding_box: getNodeBoundingBox(display),
532537
default_transform: {} as INodeTransform,
533538
}
@@ -549,7 +554,7 @@ function renderLocator(locator: Locator, rig: IRenderedRig) {
549554
storage_name: sanitizeStorageKey(locator.name),
550555
uuid: locator.uuid,
551556
parent: parentId,
552-
config: locator.config,
557+
config: structuredClone(locator.config),
553558
max_distance: 0,
554559
default_transform: {} as INodeTransform,
555560
}

test-packs/1.20.4/blueprints/armor_stand_1.20.4.ajblueprint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@
928928
"export": true,
929929
"item": "minecraft:diamond",
930930
"itemDisplay": "none",
931-
"onSummonFunction": "",
931+
"onSummonFunction": "say I'm a Diamond!",
932932
"configs": {
933933
"default": {
934934
"on_apply_function": "",
@@ -945,7 +945,7 @@
945945
},
946946
"variants": {
947947
"49521f4b-b970-e4bd-b594-2e05d2d46027": {
948-
"on_apply_function": "",
948+
"on_apply_function": "say I'm now a very colorful diamond!",
949949
"billboard": "fixed",
950950
"override_brightness": false,
951951
"brightness_override": 0,

0 commit comments

Comments
 (0)