Skip to content

Commit 9e8125a

Browse files
committed
🛠️ Fix "safe_name" export crash
1 parent 197a43c commit 9e8125a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/systems/datapackCompiler/index.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
5353
const parentNames: Array<{ name: string; type: string }> = []
5454

5555
function recurseParents(node: AnyRenderedNode) {
56-
if (node.parent) {
56+
if (node.parent === 'root') {
57+
// Root is ignored
58+
} else if (node.parent) {
5759
parentNames.push({
5860
name: rig.nodes[node.parent].safe_name,
5961
type: rig.nodes[node.parent].type,
@@ -63,6 +65,8 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
6365
}
6466
recurseParents(node)
6567

68+
const hasParent = node.parent && node.parent !== 'root'
69+
6670
tags.push(
6771
// Global
6872
TAGS.GLOBAL_ENTITY(),
@@ -74,7 +78,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
7478
TAGS.PROJECT_NODE_NAMED(Project!.animated_java.export_namespace, node.safe_name)
7579
)
7680

77-
if (!node.parent) {
81+
if (!hasParent) {
7882
tags.push(TAGS.GLOBAL_ROOT_CHILD())
7983
}
8084
switch (node.type) {
@@ -95,7 +99,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
9599
TAGS.PROJECT_BONE_TREE(Project!.animated_java.export_namespace, node.safe_name), // Tree includes self
96100
TAGS.PROJECT_BONE_TREE_BONE(Project!.animated_java.export_namespace, node.safe_name) // Tree includes self
97101
)
98-
if (!node.parent) {
102+
if (!hasParent) {
99103
// Nodes without parents are assumed to be root nodes
100104
tags.push(TAGS.GLOBAL_ROOT_CHILD_BONE())
101105
} else {
@@ -146,7 +150,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
146150
node.safe_name
147151
)
148152
)
149-
if (!node.parent) {
153+
if (!hasParent) {
150154
// Nodes without parents are assumed to be root nodes
151155
tags.push(TAGS.GLOBAL_ROOT_CHILD_ITEM_DISPLAY())
152156
} else {
@@ -198,7 +202,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
198202
node.safe_name
199203
)
200204
)
201-
if (!node.parent) {
205+
if (!hasParent) {
202206
// Nodes without parents are assumed to be root nodes
203207
tags.push(TAGS.GLOBAL_ROOT_CHILD_BLOCK_DISPLAY())
204208
} else {
@@ -250,7 +254,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
250254
node.safe_name
251255
)
252256
)
253-
if (!node.parent) {
257+
if (!hasParent) {
254258
// Nodes without parents are assumed to be root nodes
255259
tags.push(TAGS.GLOBAL_ROOT_CHILD_TEXT_DISPLAY())
256260
} else {
@@ -294,7 +298,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
294298
TAGS.PROJECT_LOCATOR(Project!.animated_java.export_namespace),
295299
TAGS.PROJECT_LOCATOR_NAMED(Project!.animated_java.export_namespace, node.safe_name)
296300
)
297-
if (!node.parent) {
301+
if (!hasParent) {
298302
// Nodes without parents are assumed to be root nodes
299303
tags.push(TAGS.GLOBAL_ROOT_CHILD_LOCATOR())
300304
} else {
@@ -338,7 +342,7 @@ function getNodeTags(node: AnyRenderedNode, rig: IRenderedRig): NbtList {
338342
TAGS.PROJECT_CAMERA(Project!.animated_java.export_namespace),
339343
TAGS.PROJECT_CAMERA_NAMED(Project!.animated_java.export_namespace, node.safe_name)
340344
)
341-
if (!node.parent) {
345+
if (!hasParent) {
342346
// Nodes without parents are assumed to be root nodes
343347
tags.push(TAGS.GLOBAL_ROOT_CHILD_CAMERA())
344348
} else {

0 commit comments

Comments
 (0)