Skip to content

Commit e03048a

Browse files
authored
🔀 Merge "🐛 A few texture saving / loading fixes" (#390)
2 parents 28f61be + 21653df commit e03048a

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/blueprintFormat.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import * as blueprintSettings from './blueprintSettings'
2-
import { BillboardMode, BoneConfig, LocatorConfig } from './nodeConfigs'
2+
import FormatPageSvelte from './components/formatPage.svelte'
33
import ProjectTitleSvelte from './components/projectTitle.svelte'
44
import { PACKAGE } from './constants'
5+
import { BillboardMode, BoneConfig, LocatorConfig } from './nodeConfigs'
6+
import { process } from './systems/modelDataFixerUpper'
57
import { events } from './util/events'
68
import { injectSvelteCompomponent } from './util/injectSvelteComponent'
79
import { toSafeFuntionName } from './util/minecraftUtil'
810
import { addProjectToRecentProjects } from './util/misc'
911
import { Valuable } from './util/stores'
10-
import { Variant } from './variants'
11-
import FormatPageSvelte from './components/formatPage.svelte'
1212
import { translate } from './util/translation'
13-
import { process } from './systems/modelDataFixerUpper'
13+
import { Variant } from './variants'
14+
15+
let boundingBoxUpdateIntervalId: ReturnType<typeof setInterval> | undefined
1416

1517
/**
1618
* The serialized Variant Bone Config
@@ -355,7 +357,7 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
355357
}
356358

357359
if (model.animation_variable_placeholders) {
358-
Interface.Panels.variable_placeholders.inside_vue._data.text =
360+
Interface.Panels.variable_placeholders.inside_vue.$data.text =
359361
model.animation_variable_placeholders
360362
}
361363

@@ -435,15 +437,23 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
435437

436438
model.textures = []
437439
for (const texture of Texture.all) {
438-
const save = texture.getUndoCopy() as Texture
440+
const save = texture.getSaveCopy() as Texture
439441
delete save.selected
440-
if (Project.save_path && texture.path) {
441-
const relative = PathModule.relative(Project.save_path, texture.path)
442-
texture.relative_path = relative.replace(/\\/g, '/')
442+
if (isApp && Project.save_path && texture.path && PathModule.isAbsolute(texture.path)) {
443+
const relative = PathModule.relative(
444+
PathModule.dirname(Project.save_path),
445+
texture.path
446+
)
447+
save.relative_path = relative.replace(/\\/g, '/')
448+
}
449+
if (
450+
options.bitmaps != false &&
451+
(Settings.get('embed_textures') || options.backup || options.bitmaps == true)
452+
) {
453+
save.source = texture.getDataURL()
454+
save.internal = true
443455
}
444-
save.source = 'data:image/png;base64,' + texture.getBase64()
445-
save.mode = 'bitmap'
446-
if (options.absolute_paths === false) delete save.path
456+
if (options.absolute_paths == false) delete save.path
447457
model.textures.push(save)
448458
}
449459

@@ -465,9 +475,9 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
465475
model.animation_controllers.push(controller.getUndoCopy(animationOptions, true))
466476
}
467477

468-
if (Interface.Panels.variable_placeholders.inside_vue._data.text) {
478+
if (Interface.Panels.variable_placeholders.inside_vue.$data.text) {
469479
model.animation_variable_placeholders =
470-
Interface.Panels.variable_placeholders.inside_vue._data.text
480+
Interface.Panels.variable_placeholders.inside_vue.$data.text
471481
}
472482

473483
if (!options.backup) {

0 commit comments

Comments
 (0)