Skip to content

Commit 4f2d9f5

Browse files
committed
Merge 0.3.9a next into experimental
Fixed resource pack root folder being marked as invalid when using special characters. Fixed the DPE creating empty folders. Added function toggle settings to the DPE
1 parent 920274b commit 4f2d9f5

File tree

10 files changed

+246
-97
lines changed

10 files changed

+246
-97
lines changed

exporters/datapackExporter/datapackExporter.ts

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ export function loadExporter() {
4343
defaultValue: true,
4444
docsLink: '/docs/exporters/datapack_exporter/settings#outdated_rig_warning',
4545
}),
46-
include_convenience_functions: new Settings.CheckboxSetting({
47-
id: 'animated_java:datapack_exporter/include_convenience_functions',
48-
displayName: TRANSLATIONS.include_convenience_functions.name,
49-
description: TRANSLATIONS.include_convenience_functions.description,
50-
defaultValue: true,
51-
docsLink:
52-
'/docs/exporters/datapack_exporter/settings#include_convenience_functions',
53-
}),
5446
root_entity_nbt: new Settings.CodeboxSetting(
5547
{
5648
id: 'animated_java:datapack_exporter/root_entity_nbt',
@@ -68,6 +60,55 @@ export function loadExporter() {
6860
}
6961
}
7062
),
63+
// Function Toggles
64+
include_variant_summon_functions: new Settings.CheckboxSetting({
65+
id: 'animated_java:datapack_exporter/include_variant_summon_functions',
66+
displayName: TRANSLATIONS.include_variant_summon_functions.name,
67+
description: TRANSLATIONS.include_variant_summon_functions.description,
68+
defaultValue: true,
69+
docsLink:
70+
'/docs/exporters/datapack_exporter/settings#include_variant_summon_functions',
71+
}),
72+
include_apply_variant_functions: new Settings.CheckboxSetting({
73+
id: 'animated_java:datapack_exporter/include_apply_variant_functions',
74+
displayName: TRANSLATIONS.include_apply_variant_functions.name,
75+
description: TRANSLATIONS.include_apply_variant_functions.description,
76+
defaultValue: true,
77+
docsLink:
78+
'/docs/exporters/datapack_exporter/settings#include_apply_variant_functions',
79+
}),
80+
include_uninstall_function: new Settings.CheckboxSetting({
81+
id: 'animated_java:datapack_exporter/include_uninstall_function',
82+
displayName: TRANSLATIONS.include_uninstall_function.name,
83+
description: TRANSLATIONS.include_uninstall_function.description,
84+
defaultValue: true,
85+
docsLink:
86+
'/docs/exporters/datapack_exporter/settings#include_uninstall_function',
87+
}),
88+
include_pause_all_animations_function: new Settings.CheckboxSetting({
89+
id: 'animated_java:datapack_exporter/include_pause_all_animations_function',
90+
displayName: TRANSLATIONS.include_pause_all_animations_function.name,
91+
description: TRANSLATIONS.include_pause_all_animations_function.description,
92+
defaultValue: true,
93+
docsLink:
94+
'/docs/exporters/datapack_exporter/settings#include_pause_all_animations_function',
95+
}),
96+
include_remove_rigs_function: new Settings.CheckboxSetting({
97+
id: 'animated_java:datapack_exporter/include_remove_rigs_function',
98+
displayName: TRANSLATIONS.include_remove_rigs_function.name,
99+
description: TRANSLATIONS.include_remove_rigs_function.description,
100+
defaultValue: true,
101+
docsLink:
102+
'/docs/exporters/datapack_exporter/settings#include_remove_rigs_function',
103+
}),
104+
include_remove_all_function: new Settings.CheckboxSetting({
105+
id: 'animated_java:datapack_exporter/include_remove_all_function',
106+
displayName: TRANSLATIONS.include_remove_all_function.name,
107+
description: TRANSLATIONS.include_remove_all_function.description,
108+
defaultValue: true,
109+
docsLink:
110+
'/docs/exporters/datapack_exporter/settings#include_remove_all_function',
111+
}),
71112
}
72113
},
73114
settingsStructure: [
@@ -81,11 +122,41 @@ export function loadExporter() {
81122
},
82123
{
83124
type: 'setting',
84-
settingId: 'animated_java:datapack_exporter/include_convenience_functions',
125+
settingId: 'animated_java:datapack_exporter/root_entity_nbt',
85126
},
86127
{
87-
type: 'setting',
88-
settingId: 'animated_java:datapack_exporter/root_entity_nbt',
128+
type: 'group',
129+
title: TRANSLATIONS.function_toggles_group.title,
130+
openByDefault: false,
131+
children: [
132+
{
133+
type: 'setting',
134+
settingId:
135+
'animated_java:datapack_exporter/include_variant_summon_functions',
136+
},
137+
{
138+
type: 'setting',
139+
settingId:
140+
'animated_java:datapack_exporter/include_apply_variant_functions',
141+
},
142+
{
143+
type: 'setting',
144+
settingId: 'animated_java:datapack_exporter/include_uninstall_function',
145+
},
146+
{
147+
type: 'setting',
148+
settingId:
149+
'animated_java:datapack_exporter/include_pause_all_animations_function',
150+
},
151+
{
152+
type: 'setting',
153+
settingId: 'animated_java:datapack_exporter/include_remove_rigs_function',
154+
},
155+
{
156+
type: 'setting',
157+
settingId: 'animated_java:datapack_exporter/include_remove_all_function',
158+
},
159+
],
89160
},
90161
],
91162
export: loadDataPackGenerator() as any,

exporters/datapackExporter/exporter/datapackGen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ export function loadDataPackGenerator() {
105105
G.DATAPACK.newFile('.ajmeta', content)
106106
await Promise.all(
107107
G.DATAPACK.children.map(
108-
async child => await child.writeToDisk(G.DATAPACK_EXPORT_PATH, progress)
108+
async child =>
109+
await child.writeToDisk(G.DATAPACK_EXPORT_PATH, {
110+
progress,
111+
skipEmptyFolders: true,
112+
})
109113
)
110114
)
111115
progress.finish()

exporters/datapackExporter/exporter/datapackGen/namespaceFolderGen.ts

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,19 @@ export function generateNamespaceFolder() {
115115
tagJsonMerger,
116116
})
117117

118-
// ANCHOR - function NAMESPACE:uninstall
119-
functionsFolder.chainNewFile('uninstall.mcfunction', [
120-
// Scoreboard objectives
121-
...Object.values(G.SCOREBOARD)
122-
.filter(s => !s.includes('%s'))
123-
.map(s => `scoreboard objectives remove ${s}`),
124-
// prettier-ignore
125-
...renderedAnimations.map(a => `scoreboard objectives remove ${formatStr(G.SCOREBOARD.localAnimTime, [a.name])}`),
126-
// prettier-ignore
127-
...renderedAnimations.map(a => `scoreboard objectives remove ${formatStr(G.SCOREBOARD.loopMode, [a.name])}`),
128-
])
118+
if (exporterSettings.include_uninstall_function.value === true) {
119+
// ANCHOR - function NAMESPACE:uninstall
120+
functionsFolder.newFile('uninstall.mcfunction', [
121+
// Scoreboard objectives
122+
...Object.values(G.SCOREBOARD)
123+
.filter(s => !s.includes('%s'))
124+
.map(s => `scoreboard objectives remove ${s}`),
125+
// prettier-ignore
126+
...renderedAnimations.map(a => `scoreboard objectives remove ${formatStr(G.SCOREBOARD.localAnimTime, [a.name])}`),
127+
// prettier-ignore
128+
...renderedAnimations.map(a => `scoreboard objectives remove ${formatStr(G.SCOREBOARD.loopMode, [a.name])}`),
129+
])
130+
}
129131
const userRootEntityNbt = NbtTag.fromString(exporterSettings.root_entity_nbt.value)
130132

131133
// Summon NBT
@@ -330,7 +332,7 @@ export function generateNamespaceFolder() {
330332
])
331333
.newFolder('summon')
332334

333-
if (exporterSettings.include_convenience_functions.value === true) {
335+
if (exporterSettings.include_variant_summon_functions.value === true) {
334336
for (const variant of G.VARIANTS) {
335337
if (variant.default) continue
336338
// ANCHOR - function NAMESPACE:summon/${variant.name}
@@ -341,7 +343,7 @@ export function generateNamespaceFolder() {
341343
}
342344
}
343345

344-
functionsFolder
346+
const removeFolder = functionsFolder
345347
.newFolder('remove')
346348
// ANCHOR - function NAMESPACE:remove/this
347349
.chainNewFile('this.mcfunction', [
@@ -351,25 +353,31 @@ export function generateNamespaceFolder() {
351353
[`${G.NAMESPACE}:remove/this`]
352354
)}`,
353355
])
356+
if (exporterSettings.include_remove_rigs_function.value === true) {
354357
// ANCHOR - function NAMESPACE:remove/rigs
355-
.chainNewFile('rigs.mcfunction', [
358+
removeFolder.newFile('rigs.mcfunction', [
356359
`execute as @e[type=${G.ENTITY_TYPES.ajRoot},tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:remove/as_root`,
357360
])
361+
}
362+
if (exporterSettings.include_remove_all_function.value === true) {
358363
// ANCHOR - function NAMESPACE:remove/all
359-
.chainNewFile('all.mcfunction', [
364+
removeFolder.newFile('all.mcfunction', [
360365
`execute as @e[type=${G.ENTITY_TYPES.ajRoot},tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:remove/as_root`,
361366
`kill @e[tag=${G.TAGS.rigEntity}]`,
362367
])
368+
}
363369

364-
for (const variant of G.VARIANTS) {
365-
// ANCHOR - func NAMESPACE:apply_variant/${variant.name}
366-
applyVariantFolder.newFile(`${variant.name}.mcfunction`, [
367-
`execute if entity @s[tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:apply_variant/${variant.name}_as_root`,
368-
`execute if entity @s[tag=!${G.TAGS.rootEntity}] run tellraw @a ${formatStr(
369-
G.TELLRAW.errorMustBeRunAsRoot.toString(),
370-
[`${G.NAMESPACE}:apply_variant/${variant.name}`]
371-
)}`,
372-
])
370+
if (exporterSettings.include_apply_variant_functions.value === true) {
371+
for (const variant of G.VARIANTS) {
372+
// ANCHOR - func NAMESPACE:apply_variant/${variant.name}
373+
applyVariantFolder.newFile(`${variant.name}.mcfunction`, [
374+
`execute if entity @s[tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:apply_variant/${variant.name}_as_root`,
375+
`execute if entity @s[tag=!${G.TAGS.rootEntity}] run tellraw @a ${formatStr(
376+
G.TELLRAW.errorMustBeRunAsRoot.toString(),
377+
[`${G.NAMESPACE}:apply_variant/${variant.name}`]
378+
)}`,
379+
])
380+
}
373381
}
374382

375383
for (const anim of renderedAnimations) {
@@ -402,14 +410,17 @@ export function generateNamespaceFolder() {
402410
}
403411
}
404412

405-
if (!G.IS_SINGLE_ENTITY_RIG) {
413+
if (
414+
!G.IS_SINGLE_ENTITY_RIG &&
415+
exporterSettings.include_pause_all_animations_function.value === true
416+
) {
406417
animationsFolder
407-
// ANCHOR - function NAMESPACE:animations/stop_all_animations
408-
.chainNewFile('stop_all_animations.mcfunction', [
409-
`execute if entity @s[tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:animations/stop_all_animations_as_root`,
418+
// ANCHOR - function NAMESPACE:animations/pause_all_animations
419+
.chainNewFile('pause_all_animations.mcfunction', [
420+
`execute if entity @s[tag=${G.TAGS.rootEntity}] run function ${G.AJ_NAMESPACE}:animations/pause_all_animations_as_root`,
410421
`execute if entity @s[tag=!${G.TAGS.rootEntity}] run tellraw @a ${formatStr(
411422
G.TELLRAW.errorMustBeRunAsRoot.toString(),
412-
[`${G.NAMESPACE}:animations/stop_all_animations`]
423+
[`${G.NAMESPACE}:animations/pause_all_animations`]
413424
)}`,
414425
])
415426
}

exporters/datapackExporter/exporter/translations.ts

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,58 @@ export function loadTranslations() {
4141
'animated_java.datapack_exporter.settings.enable_outdated_rig_warning.description'
4242
).split('\n'),
4343
},
44-
include_convenience_functions: {
44+
root_entity_nbt: {
45+
name: translate('animated_java.datapack_exporter.settings.root_entity_nbt'),
46+
description: translate(
47+
'animated_java.datapack_exporter.settings.root_entity_nbt.description'
48+
).split('\n'),
49+
},
50+
include_variant_summon_functions: {
4551
name: translate(
46-
'animated_java.datapack_exporter.settings.include_convenience_functions'
52+
'animated_java.datapack_exporter.settings.include_variant_summon_functions'
4753
),
4854
description: translate(
49-
'animated_java.datapack_exporter.settings.include_convenience_functions.description'
55+
'animated_java.datapack_exporter.settings.include_variant_summon_functions.description'
5056
).split('\n'),
5157
},
52-
// enable_single_rig_optimizations: {
53-
// name: translate(
54-
// 'animated_java.datapack_exporter.settings.enable_single_rig_optimizations'
55-
// ),
56-
// description: translate(
57-
// 'animated_java.datapack_exporter.settings.enable_single_rig_optimizations.description'
58-
// ).split('\n'),
59-
// },
60-
root_entity_nbt: {
61-
name: translate('animated_java.datapack_exporter.settings.root_entity_nbt'),
58+
include_apply_variant_functions: {
59+
name: translate(
60+
'animated_java.datapack_exporter.settings.include_apply_variant_functions'
61+
),
6262
description: translate(
63-
'animated_java.datapack_exporter.settings.root_entity_nbt.description'
63+
'animated_java.datapack_exporter.settings.include_apply_variant_functions.description'
64+
).split('\n'),
65+
},
66+
include_uninstall_function: {
67+
name: translate('animated_java.datapack_exporter.settings.include_uninstall_function'),
68+
description: translate(
69+
'animated_java.datapack_exporter.settings.include_uninstall_function.description'
6470
).split('\n'),
6571
},
72+
include_pause_all_animations_function: {
73+
name: translate(
74+
'animated_java.datapack_exporter.settings.include_pause_all_animations_function'
75+
),
76+
description: translate(
77+
'animated_java.datapack_exporter.settings.include_pause_all_animations_function.description'
78+
).split('\n'),
79+
},
80+
include_remove_rigs_function: {
81+
name: translate(
82+
'animated_java.datapack_exporter.settings.include_remove_rigs_function'
83+
),
84+
description: translate(
85+
'animated_java.datapack_exporter.settings.include_remove_rigs_function.description'
86+
).split('\n'),
87+
},
88+
include_remove_all_function: {
89+
name: translate('animated_java.datapack_exporter.settings.include_remove_all_function'),
90+
description: translate(
91+
'animated_java.datapack_exporter.settings.include_remove_all_function.description'
92+
).split('\n'),
93+
},
94+
function_toggles_group: {
95+
title: translate('animated_java.datapack_exporter.settings.function_toggles_group'),
96+
},
6697
}
6798
}

exporters/datapackExporter/lang/en.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,35 @@ animated_java.datapack_exporter.settings.enable_outdated_rig_warning: Enable Out
2525
animated_java.datapack_exporter.settings.enable_outdated_rig_warning.description: |-
2626
Whether to show a warning in-game when a Rig is found that was summoned before the most recent export.
2727
28-
# animated_java.datapack_exporter.settings.enable_single_rig_optimizations: Enable Single Rig Optimizations
29-
# animated_java.datapack_exporter.settings.enable_single_rig_optimizations.description: |-
30-
# Whether to enable optimizations that are only possible when there is only one Rig in the world at a time.
31-
# These optimizations will reduce the performance impact of the generated Data Pack, but will prevent you from having multiple Rigs in the world at once.
32-
33-
animated_java.datapack_exporter.settings.include_convenience_functions: Include Convenience Functions
34-
animated_java.datapack_exporter.settings.include_convenience_functions.description: |-
35-
Whether to include convenience functions in the generated Data Pack.
36-
The convenience functions are simplified functions (Like the summon/<variant_name> functions) that are easier to use, but less flexible than their counterparts.
37-
You may want to disable them if you don't use them, or if you want to reduce the size of the generated Data Pack.
38-
3928
animated_java.datapack_exporter.settings.root_entity_nbt: Root Entity NBT
4029
animated_java.datapack_exporter.settings.root_entity_nbt.description: |-
4130
Custom NBT to apply to the root entity of the Rig.
4231
WARNING! This NBT will overwrite any NBT that the exporter would normally add to the root entity.
32+
33+
animated_java.datapack_exporter.settings.function_toggles_group: Function Toggles
34+
35+
animated_java.datapack_exporter.settings.include_variant_summon_functions: Include Variant Summon Functions
36+
animated_java.datapack_exporter.settings.include_variant_summon_functions.description: |-
37+
Whether to include functions that summon each variant of the Rig in the exported Data Pack.
38+
These functions are equivalent to setting #variant aj.id when running the summon function.
39+
40+
animated_java.datapack_exporter.settings.include_apply_variant_functions: Include Apply Variant Functions
41+
animated_java.datapack_exporter.settings.include_apply_variant_functions.description: |-
42+
Whether to include functions that apply each variant of the Rig in the exported Data Pack.
43+
Note that even if these functions are disabled, you will still be able to swap variants in animations using variant keyframes.
44+
45+
animated_java.datapack_exporter.settings.include_uninstall_function: Include Uninstall Function
46+
animated_java.datapack_exporter.settings.include_uninstall_function.description: |-
47+
Whether to include the uninstall function in the exported Data Pack.
48+
49+
animated_java.datapack_exporter.settings.include_pause_all_animations_function: Include Pause All Animations Function
50+
animated_java.datapack_exporter.settings.include_pause_all_animations_function.description: |-
51+
Whether to include the pause_all_animations function in the exported Data Pack.
52+
53+
animated_java.datapack_exporter.settings.include_remove_rigs_function: Include Remove Rigs Function
54+
animated_java.datapack_exporter.settings.include_remove_rigs_function.description: |-
55+
Whether to include the remove/rigs function in the exported Data Pack.
56+
57+
animated_java.datapack_exporter.settings.include_remove_all_function: Include Remove All Function
58+
animated_java.datapack_exporter.settings.include_remove_all_function.description: |-
59+
Whether to include the remove/all function in the exported Data Pack.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "module",
33
"name": "animated_java",
44
"title": "Animated Java",
5-
"version": "0.3.9",
5+
"version": "0.3.9a",
66
"min_blockbench_version": "4.6.5",
77
"author": {
88
"name": "Titus Evans (SnaveSutit)",

0 commit comments

Comments
 (0)