Skip to content

Commit 5f66528

Browse files
MeekiaveliqueSnaveSutit
authored andcommitted
fix(plugin-export): restore plugin mode and update JSON export schema
1 parent 02832a8 commit 5f66528

10 files changed

Lines changed: 138 additions & 99 deletions

File tree

src/components/blueprintSettingsDialog.svelte

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
console.error(e)
272272
return {
273273
type: 'error',
274-
message: translate('dialog.blueprint_settings.json_file.error.file_does_not_exist'),
274+
message: translate('dialog.blueprint_settings.json_file.error.invalid_path'),
275275
}
276276
}
277277
switch (true) {
@@ -333,8 +333,6 @@
333333
// Export Settings
334334
export let exportNamespace: Valuable<string>
335335
export let enablePluginMode: Valuable<boolean>
336-
// FIXME - Force-disable plugin mode for now
337-
$enablePluginMode = false
338336
export let resourcePackExportMode: Valuable<string>
339337
export let dataPackExportMode: Valuable<string>
340338
export let targetMinecraftVersion: Valuable<string>
@@ -433,12 +431,12 @@
433431
valueChecker={exportNamespaceChecker}
434432
/>
435433

436-
<!-- <Checkbox
437-
label={translate('dialog.blueprint_settings.enable_plugin_mode.title')}
438-
tooltip={translate('dialog.blueprint_settings.enable_plugin_mode.description')}
439-
bind:checked={enablePluginMode}
440-
defaultValue={defaultValues.enable_plugin_mode}
441-
/> -->
434+
<Checkbox
435+
label={translate('dialog.blueprint_settings.enable_plugin_mode.title')}
436+
tooltip={translate('dialog.blueprint_settings.enable_plugin_mode.description')}
437+
bind:checked={enablePluginMode}
438+
defaultValue={defaultValues.enable_plugin_mode}
439+
/>
442440

443441
{#if $enablePluginMode}
444442
<LineInput

src/formats/blueprint/codec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ export const BLUEPRINT_CODEC = registerCodec(
9191
}
9292
}
9393

94-
// FIXME - Temporarily disable plugin mode for 1.8.0
95-
if (Project.animated_java.enable_plugin_mode) {
96-
Project.animated_java.enable_plugin_mode = false
97-
}
98-
9994
Project.last_used_export_namespace =
10095
model.meta?.last_used_export_namespace ?? Project.animated_java.export_namespace
10196

src/lang/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ animated_java.dialog.blueprint_settings.baked_animations.description: |-
275275
276276
animated_java.dialog.blueprint_settings.json_file.title: JSON File
277277
animated_java.dialog.blueprint_settings.json_file.description: The path to the JSON file to export the project to.
278+
animated_java.dialog.blueprint_settings.json_file.error.invalid_path: Invalid file path!
278279
animated_java.dialog.blueprint_settings.json_file.error.no_file_selected: No file selected!
279280
animated_java.dialog.blueprint_settings.json_file.error.not_a_file: The selected path is not a file!
280281

src/systems/datapackCompiler/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { MSLimiter } from '../../util/msLimiter'
1717
import { Variant } from '../../variants'
1818
import type { IRenderedAnimation } from '../animationRenderer'
1919
import mcbFiles from '../datapackCompiler/mcbFiles'
20-
import { IntentionalExportError } from '../exporter'
20+
import { IntentionalExportError } from '../errors'
2121
import { AJMeta, PackMeta, SUPPORTED_MINECRAFT_VERSIONS } from '../global'
2222
import { JsonText } from '../jsonText'
2323
import { JsonTextParser } from '../jsonText/parser'

src/systems/errors.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export class IntentionalExportError extends Error {
2+
constructor(
3+
message: string,
4+
public messageBoxOptions?: MessageBoxOptions,
5+
public messageBoxCallback?: Parameters<typeof Blockbench.showMessageBox>[1]
6+
) {
7+
super(message)
8+
this.name = 'IntentionalExportError'
9+
}
10+
}
11+
12+
export class IntentionalExportErrorFromInvalidFile extends IntentionalExportError {
13+
constructor(filePath: string, public originalError: Error) {
14+
const parsed = PathModule.parse(filePath)
15+
super(
16+
`Failed to read file <code title="${filePath}">${parsed.base}</code>:\n\n` +
17+
'```\n' +
18+
originalError +
19+
'\n```',
20+
{
21+
commands: {
22+
open_file: {
23+
text: 'Open File Location',
24+
icon: 'folder_open',
25+
},
26+
},
27+
},
28+
button => {
29+
if (button === 'open_file') {
30+
shell.showItemInFolder(filePath)
31+
}
32+
}
33+
)
34+
this.name = 'IntentionalExportErrorFromInvalidFile'
35+
}
36+
}
37+

src/systems/exporter.ts

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,13 @@ import { isResourcePackPath } from '../util/minecraftUtil'
99
import { translate } from '../util/translation'
1010
import { Variant } from '../variants'
1111
import { hashAnimations, renderProjectAnimations } from './animationRenderer'
12+
import { exportJSON } from './jsonCompiler'
1213
import compileDataPack from './datapackCompiler'
14+
import { IntentionalExportError } from './errors'
1315
import resourcepackCompiler from './resourcepackCompiler'
1416
import { hashRig, renderRig } from './rigRenderer'
1517
import { isCubeValid } from './util'
1618

17-
export class IntentionalExportError extends Error {
18-
constructor(
19-
message: string,
20-
public messageBoxOptions?: MessageBoxOptions,
21-
public messageBoxCallback?: Parameters<typeof Blockbench.showMessageBox>[1]
22-
) {
23-
super(message)
24-
this.name = 'IntentionalExportError'
25-
}
26-
}
27-
28-
export class IntentionalExportErrorFromInvalidFile extends IntentionalExportError {
29-
constructor(filePath: string, public originalError: Error) {
30-
const parsed = PathModule.parse(filePath)
31-
super(
32-
`Failed to read file <code title="${filePath}">${parsed.base}</code>:\n\n` +
33-
'```\n' +
34-
originalError +
35-
'\n```',
36-
{
37-
commands: {
38-
open_file: {
39-
text: 'Open File Location',
40-
icon: 'folder_open',
41-
},
42-
},
43-
},
44-
button => {
45-
if (button === 'open_file') {
46-
shell.showItemInFolder(filePath)
47-
}
48-
}
49-
)
50-
this.name = 'IntentionalExportErrorFromInvalidFile'
51-
}
52-
}
53-
5419
export function getExportPaths() {
5520
const aj = Project!.animated_java
5621

@@ -164,7 +129,7 @@ async function actuallyExportProject({
164129
debugMode,
165130
})
166131

167-
if (aj.data_pack_export_mode !== 'none') {
132+
if (!aj.enable_plugin_mode && aj.data_pack_export_mode !== 'none') {
168133
await compileDataPack([aj.target_minecraft_version], {
169134
rig,
170135
animations,
@@ -175,6 +140,17 @@ async function actuallyExportProject({
175140
})
176141
}
177142

143+
if (aj.enable_plugin_mode) {
144+
PROGRESS_DESCRIPTION.set('Exporting Plugin JSON...')
145+
exportJSON({
146+
rig,
147+
animations,
148+
displayItemPath,
149+
textureExportFolder,
150+
modelExportFolder,
151+
})
152+
}
153+
178154
Project!.last_used_export_namespace = aj.export_namespace
179155

180156
if (forceSave) saveBlueprint()

src/systems/global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { normalizePath } from '../util/fileUtil'
2-
import { IntentionalExportError, IntentionalExportErrorFromInvalidFile } from './exporter'
2+
import { IntentionalExportError, IntentionalExportErrorFromInvalidFile } from './errors'
33
import { sortObjectKeys } from './util'
44

55
export enum SUPPORTED_MINECRAFT_VERSIONS {

0 commit comments

Comments
 (0)