Skip to content

Commit e8d74d3

Browse files
committed
🚧 Static Export
- Added a bunch of checks that reduce the number of exported functions based on what features are in use in the Blueprint. - Added a static export system that removes all animation tech when exporting a Blueprint with no animations. - Fixed cameras not being removed when using remove/this. - Added showFunctionErrors and showOutdatedWarning options.
1 parent f98ddce commit e8d74d3

File tree

7 files changed

+657
-150
lines changed

7 files changed

+657
-150
lines changed

src/blueprintSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const defaultValues = {
2828
interpolation_duration: 1,
2929
teleportation_duration: 1,
3030
use_storage_for_animation: false,
31+
show_function_errors: true,
32+
show_outdated_warning: true,
3133
// Plugin Settings
3234
baked_animations: true,
3335
json_file: '',

src/components/blueprintSettingsDialog.svelte

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
export let interpolationDuration: Valuable<number>
6565
export let teleportationDuration: Valuable<number>
6666
export let useStorageForAnimation: Valuable<boolean>
67+
export let showFunctionErrors: Valuable<boolean>
68+
export let showOutdatedWarning: Valuable<boolean>
6769
// Plugin Export Settings
6870
export let bakedAnimations: Valuable<boolean>
6971
export let jsonFile: Valuable<string>
@@ -685,13 +687,6 @@
685687
/>
686688

687689
{#if $dataPackExportMode === 'raw'}
688-
<!-- {#if $enableAdvancedDataPackSettings}
689-
<p class="warning">
690-
{translate('dialog.blueprint_settings.advanced_settings_warning')}
691-
</p>
692-
{:else}
693-
{/if} -->
694-
695690
<FolderSelect
696691
label={translate('dialog.blueprint_settings.data_pack.title')}
697692
tooltip={translate('dialog.blueprint_settings.data_pack.description')}
@@ -749,6 +744,20 @@
749744
bind:checked={useStorageForAnimation}
750745
defaultValue={defaultValues.use_storage_for_animation}
751746
/>
747+
748+
<Checkbox
749+
label={translate('dialog.blueprint_settings.show_function_errors.title')}
750+
tooltip={translate('dialog.blueprint_settings.show_function_errors.description')}
751+
bind:checked={showFunctionErrors}
752+
defaultValue={defaultValues.show_function_errors}
753+
/>
754+
755+
<Checkbox
756+
label={translate('dialog.blueprint_settings.show_outdated_warning.title')}
757+
tooltip={translate('dialog.blueprint_settings.show_outdated_warning.description')}
758+
bind:checked={showOutdatedWarning}
759+
defaultValue={defaultValues.show_outdated_warning}
760+
/>
752761
{/if}
753762
{/if}
754763
</div>

src/interface/blueprintSettingsDialog.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function getSettings() {
6161
interpolationDuration: new Valuable(Project!.animated_java.interpolation_duration),
6262
teleportationDuration: new Valuable(Project!.animated_java.teleportation_duration),
6363
useStorageForAnimation: new Valuable(Project!.animated_java.use_storage_for_animation),
64+
showFunctionErrors: new Valuable(Project!.animated_java.show_function_errors),
65+
showOutdatedWarning: new Valuable(Project!.animated_java.show_outdated_warning),
6466
// Plugin Settings
6567
bakedAnimations: new Valuable(Project!.animated_java.baked_animations),
6668
jsonFile: new Valuable(Project!.animated_java.json_file),
@@ -104,6 +106,8 @@ function setSettings(settings: ReturnType<typeof getSettings>) {
104106
Project.animated_java.interpolation_duration = settings.interpolationDuration.get()
105107
Project.animated_java.teleportation_duration = settings.teleportationDuration.get()
106108
Project.animated_java.use_storage_for_animation = settings.useStorageForAnimation.get()
109+
Project.animated_java.show_function_errors = settings.showFunctionErrors.get()
110+
Project.animated_java.show_outdated_warning = settings.showOutdatedWarning.get()
107111
// Plugin Settings
108112
Project.animated_java.baked_animations = settings.bakedAnimations.get()
109113
Project.animated_java.json_file = settings.jsonFile.get()

src/lang/en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ animated_java.dialog.blueprint_settings.use_storage_for_animation.description: |
183183
Whether or not to use NBT storage to store animation data instead of functions.
184184
This will vastly reduce the number of functions in the generated Data Pack, but is 42% slower than the function method.
185185
186+
animated_java.dialog.blueprint_settings.show_function_errors.title: Show Function Errors
187+
animated_java.dialog.blueprint_settings.show_function_errors.description: Whether or not to show errors in chat when running functions in-game if they're used incorrectly.
188+
189+
animated_java.dialog.blueprint_settings.show_outdated_warning.title: Show Outdated Warning
190+
animated_java.dialog.blueprint_settings.show_outdated_warning.description: Whether or not to show a warning in chat when a Rig Instance is outdated.
191+
186192
# Plugin Settings
187193
animated_java.dialog.blueprint_settings.baked_animations.title: Baked Animations
188194
animated_java.dialog.blueprint_settings.baked_animations.description: |-

src/systems/datapackCompiler.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Compiler, Parser, Tokenizer, SyncIo } from 'mc-build'
22
import { VariableMap } from 'mc-build/dist/mcl/Compiler'
33
import { isFunctionTagPath } from '../util/fileUtil'
44
import animationMcb from './datapackCompiler/animation.mcb'
5+
import staticMcb from './datapackCompiler/static.mcb'
56
import { AnyRenderedNode, IRenderedRig, IRenderedVariant } from './rigRenderer'
67
import { IRenderedAnimation } from './animationRenderer'
78
import { Variant } from '../variants'
@@ -215,6 +216,13 @@ namespace TELLRAW {
215216
])
216217
),
217218
])
219+
export const NO_VARIANTS = () =>
220+
new JsonText([
221+
'',
222+
TELLRAW_PREFIX,
223+
{ text: 'Error: ', color: 'red' },
224+
{ text: 'No variants are available.', color: 'red' },
225+
])
218226
}
219227

220228
async function generateRootEntityPassengers(rig: IRenderedRig, rigHash: string) {
@@ -647,14 +655,23 @@ export async function compileDataPack(options: {
647655
nodeSorter,
648656
getRotationFromQuaternion: eulerFromQuaternion,
649657
root_ticking_commands: aj.ticking_commands,
658+
show_function_errors: aj.show_function_errors,
659+
show_outdated_warning: aj.show_outdated_warning,
660+
has_locators: Object.values(rig.nodes).filter(n => n.type === 'locator').length > 0,
661+
has_entity_locators:
662+
Object.values(rig.nodes).filter(n => n.type === 'locator' && n.config?.use_entity)
663+
.length > 0,
664+
has_cameras: Object.values(rig.nodes).filter(n => n.type === 'camera').length > 0,
650665
}
651666
console.log('Compiler Variables:', variables)
652667

668+
const mcbFile = animations.length === 0 ? staticMcb : animationMcb
669+
653670
PROGRESS_DESCRIPTION.set('Compiling Data Pack...')
654671
PROGRESS.set(0)
655672
await new Promise(resolve => setTimeout(resolve, 2000 / framespersecond))
656673
console.time('MC-Build Compiler took')
657-
const tokens = Tokenizer.tokenize(animationMcb, 'src/animated_java.mcb')
674+
const tokens = Tokenizer.tokenize(mcbFile, 'src/animated_java.mcb')
658675
compiler.addFile('src/animated_java.mcb', Parser.parseMcbFile(tokens))
659676
compiler.compile(VariableMap.fromObject(variables))
660677
console.timeEnd('MC-Build Compiler took')

0 commit comments

Comments
 (0)