Skip to content

Commit 206c42c

Browse files
committed
🛠️ Fix #268 & #255
1 parent ec2e41b commit 206c42c

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

src/systems/exporter.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { openBlueprintSettingsDialog } from '../interface/blueprintSettingsDialo
44
import { PROGRESS_DESCRIPTION, openExportProgressDialog } from '../interface/exportProgressDialog'
55
import { openUnexpectedErrorDialog } from '../interface/unexpectedErrorDialog'
66
import { resolvePath } from '../util/fileUtil'
7+
import { isResourcePackPath } from '../util/minecraftUtil'
78
import { translate } from '../util/translation'
89
import { Variant } from '../variants'
910
import { hashAnimations, renderProjectAnimations } from './animationRenderer'
@@ -24,6 +25,22 @@ async function actuallyExportProject(forceSave = true) {
2425
try {
2526
console.time('Exporting project took')
2627

28+
// Verify that all variant texture maps are valid
29+
for (const variant of Variant.all) {
30+
variant.verifyTextureMap()
31+
}
32+
33+
// Verify that all non-external textures have unique names
34+
for (const texture of Texture.all) {
35+
if (texture.path && isResourcePackPath(texture.path) && fs.existsSync(texture.path))
36+
continue
37+
if (Texture.all.some(t => t !== texture && t.name === texture.name)) {
38+
throw new IntentionalExportError(
39+
`Texture name "${texture.name}" is used more than once. Please make sure all textures have unique names.`
40+
)
41+
}
42+
}
43+
2744
let textureExportFolder: string, modelExportFolder: string, displayItemPath: string
2845

2946
const resourcePackFolder = resolvePath(aj.resource_pack)
@@ -161,7 +178,5 @@ export async function exportProject(forceSave = true) {
161178

162179
settingsDialog.close(0)
163180

164-
// Verify that all textures have unique IDs
165-
166181
await actuallyExportProject(forceSave)
167182
}

src/variants.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ export class TextureMap {
6666
return textureMap
6767
}
6868

69-
copy() {
69+
public copy() {
7070
const textureMap = new TextureMap()
7171
textureMap.map = new Map(this.map)
7272
return textureMap
7373
}
74+
75+
public verifyTextures() {
76+
for (const [key, value] of this.map) {
77+
if (!Texture.all.some(t => t.uuid === value)) {
78+
this.map.delete(key)
79+
}
80+
}
81+
}
7482
}
7583

7684
export class VariantBoneConfig {
@@ -158,6 +166,10 @@ export class Variant {
158166
variant.select()
159167
}
160168

169+
public verifyTextureMap() {
170+
this.textureMap.verifyTextures()
171+
}
172+
161173
public static fromJSON(json: IBlueprintVariantJSON, isDefault = false): Variant {
162174
const variant = new Variant(json.display_name, isDefault)
163175
variant.uuid = json.uuid

test_blueprints/armor_stand.ajblueprint

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@
857857
"scale": [1, 1, 1],
858858
"visibility": true,
859859
"item": "minecraft:diamond",
860+
"item_display": "none",
860861
"config": {},
861862
"block": "minecraft:stone",
862863
"text": "\"\\\"Hello World!\\\"\"\n",
@@ -975,7 +976,6 @@
975976
"color": 0,
976977
"configs": {
977978
"default": {
978-
"vanilla_item_model": "",
979979
"billboard": "fixed",
980980
"brightness_override": 0,
981981
"enchanted": false,
@@ -1005,7 +1005,6 @@
10051005
"color": 0,
10061006
"configs": {
10071007
"default": {
1008-
"vanilla_item_model": "",
10091008
"billboard": "fixed",
10101009
"brightness_override": 0,
10111010
"enchanted": false,
@@ -1037,7 +1036,6 @@
10371036
"color": 0,
10381037
"configs": {
10391038
"default": {
1040-
"vanilla_item_model": "",
10411039
"billboard": "fixed",
10421040
"brightness_override": 0,
10431041
"enchanted": false,
@@ -1069,7 +1067,6 @@
10691067
"color": 0,
10701068
"configs": {
10711069
"default": {
1072-
"vanilla_item_model": "",
10731070
"billboard": "fixed",
10741071
"override_brightness": false,
10751072
"brightness_override": 0,
@@ -3070,7 +3067,7 @@
30703067
"override": false,
30713068
"length": 0.8,
30723069
"snapping": 20,
3073-
"selected": true,
3070+
"selected": false,
30743071
"saved": false,
30753072
"path": "",
30763073
"anim_time_update": "",

0 commit comments

Comments
 (0)