Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/components/blueprintSettingsDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
console.error(e)
return {
type: 'error',
message: translate('dialog.blueprint_settings.json_file.error.file_does_not_exist'),
message: translate('dialog.blueprint_settings.json_file.error.invalid_path'),
}
}
switch (true) {
Expand Down Expand Up @@ -333,8 +333,6 @@
// Export Settings
export let exportNamespace: Valuable<string>
export let enablePluginMode: Valuable<boolean>
// FIXME - Force-disable plugin mode for now
$enablePluginMode = false
export let resourcePackExportMode: Valuable<string>
export let dataPackExportMode: Valuable<string>
export let targetMinecraftVersion: Valuable<string>
Expand Down Expand Up @@ -433,12 +431,12 @@
valueChecker={exportNamespaceChecker}
/>

<!-- <Checkbox
label={translate('dialog.blueprint_settings.enable_plugin_mode.title')}
tooltip={translate('dialog.blueprint_settings.enable_plugin_mode.description')}
bind:checked={enablePluginMode}
defaultValue={defaultValues.enable_plugin_mode}
/> -->
<Checkbox
label={translate('dialog.blueprint_settings.enable_plugin_mode.title')}
tooltip={translate('dialog.blueprint_settings.enable_plugin_mode.description')}
bind:checked={enablePluginMode}
defaultValue={defaultValues.enable_plugin_mode}
/>

{#if $enablePluginMode}
<LineInput
Expand Down
5 changes: 0 additions & 5 deletions src/formats/blueprint/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ export const BLUEPRINT_CODEC = registerCodec(
}
}

// FIXME - Temporarily disable plugin mode for 1.8.0
if (Project.animated_java.enable_plugin_mode) {
Project.animated_java.enable_plugin_mode = false
}

Project.last_used_export_namespace =
model.meta?.last_used_export_namespace ?? Project.animated_java.export_namespace

Expand Down
1 change: 1 addition & 0 deletions src/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ animated_java.dialog.blueprint_settings.baked_animations.description: |-

animated_java.dialog.blueprint_settings.json_file.title: JSON File
animated_java.dialog.blueprint_settings.json_file.description: The path to the JSON file to export the project to.
animated_java.dialog.blueprint_settings.json_file.error.invalid_path: Invalid file path!
animated_java.dialog.blueprint_settings.json_file.error.no_file_selected: No file selected!
animated_java.dialog.blueprint_settings.json_file.error.not_a_file: The selected path is not a file!

Expand Down
2 changes: 1 addition & 1 deletion src/systems/datapackCompiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MSLimiter } from '../../util/msLimiter'
import { Variant } from '../../variants'
import type { IRenderedAnimation } from '../animationRenderer'
import mcbFiles from '../datapackCompiler/mcbFiles'
import { IntentionalExportError } from '../exporter'
import { IntentionalExportError } from '../errors'
import { AJMeta, PackMeta, SUPPORTED_MINECRAFT_VERSIONS } from '../global'
import { JsonText } from '../jsonText'
import { JsonTextParser } from '../jsonText/parser'
Expand Down
37 changes: 37 additions & 0 deletions src/systems/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export class IntentionalExportError extends Error {
constructor(
message: string,
public messageBoxOptions?: MessageBoxOptions,
public messageBoxCallback?: Parameters<typeof Blockbench.showMessageBox>[1]
) {
super(message)
this.name = 'IntentionalExportError'
}
}

export class IntentionalExportErrorFromInvalidFile extends IntentionalExportError {
constructor(filePath: string, public originalError: Error) {
const parsed = PathModule.parse(filePath)
super(
`Failed to read file <code title="${filePath}">${parsed.base}</code>:\n\n` +
'```\n' +
originalError +
'\n```',
{
commands: {
open_file: {
text: 'Open File Location',
icon: 'folder_open',
},
},
},
button => {
if (button === 'open_file') {
shell.showItemInFolder(filePath)
}
}
)
this.name = 'IntentionalExportErrorFromInvalidFile'
}
}

52 changes: 14 additions & 38 deletions src/systems/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,13 @@ import { isResourcePackPath } from '../util/minecraftUtil'
import { translate } from '../util/translation'
import { Variant } from '../variants'
import { hashAnimations, renderProjectAnimations } from './animationRenderer'
import { exportJSON } from './jsonCompiler'
import compileDataPack from './datapackCompiler'
import { IntentionalExportError } from './errors'
import resourcepackCompiler from './resourcepackCompiler'
import { hashRig, renderRig } from './rigRenderer'
import { isCubeValid } from './util'

export class IntentionalExportError extends Error {
constructor(
message: string,
public messageBoxOptions?: MessageBoxOptions,
public messageBoxCallback?: Parameters<typeof Blockbench.showMessageBox>[1]
) {
super(message)
this.name = 'IntentionalExportError'
}
}

export class IntentionalExportErrorFromInvalidFile extends IntentionalExportError {
constructor(filePath: string, public originalError: Error) {
const parsed = PathModule.parse(filePath)
super(
`Failed to read file <code title="${filePath}">${parsed.base}</code>:\n\n` +
'```\n' +
originalError +
'\n```',
{
commands: {
open_file: {
text: 'Open File Location',
icon: 'folder_open',
},
},
},
button => {
if (button === 'open_file') {
shell.showItemInFolder(filePath)
}
}
)
this.name = 'IntentionalExportErrorFromInvalidFile'
}
}

export function getExportPaths() {
const aj = Project!.animated_java

Expand Down Expand Up @@ -164,7 +129,7 @@ async function actuallyExportProject({
debugMode,
})

if (aj.data_pack_export_mode !== 'none') {
if (!aj.enable_plugin_mode && aj.data_pack_export_mode !== 'none') {
await compileDataPack([aj.target_minecraft_version], {
rig,
animations,
Expand All @@ -175,6 +140,17 @@ async function actuallyExportProject({
})
}

if (aj.enable_plugin_mode) {
PROGRESS_DESCRIPTION.set('Exporting Plugin JSON...')
exportJSON({
rig,
animations,
displayItemPath,
textureExportFolder,
modelExportFolder,
})
}

Project!.last_used_export_namespace = aj.export_namespace

if (forceSave) saveBlueprint()
Expand Down
2 changes: 1 addition & 1 deletion src/systems/global.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { normalizePath } from '../util/fileUtil'
import { IntentionalExportError, IntentionalExportErrorFromInvalidFile } from './exporter'
import { IntentionalExportError, IntentionalExportErrorFromInvalidFile } from './errors'
import { sortObjectKeys } from './util'

export enum SUPPORTED_MINECRAFT_VERSIONS {
Expand Down
Loading