Skip to content

Commit 26a5af7

Browse files
committed
🚧 Update to Blockbench 4.12.0
- Removed internal transparent texture. - Replaced all references to `Group.selected` with `Group.first_selected`.
1 parent 4482a54 commit 26a5af7

14 files changed

+77
-143
lines changed

src/blockbenchTypeMods.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ declare global {
9898
isDataPackPath: typeof isDataPackPath
9999
blueprintSettingErrors: typeof blueprintSettingErrors
100100
openUnexpectedErrorDialog: typeof openUnexpectedErrorDialog
101-
TRANSPARENT_TEXTURE: Texture
102101
BLUEPRINT_FORMAT: typeof BLUEPRINT_FORMAT
103102
BLUEPRINT_CODEC: typeof BLUEPRINT_CODEC
104103
TextDisplay: typeof TextDisplay

src/blueprintFormat.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { injectSvelteCompomponent } from './util/injectSvelteComponent'
77
import { toSafeFuntionName } from './util/minecraftUtil'
88
import { addProjectToRecentProjects } from './util/misc'
99
import { Valuable } from './util/stores'
10-
import { TRANSPARENT_TEXTURE, TRANSPARENT_TEXTURE_MATERIAL, Variant } from './variants'
10+
import { Variant } from './variants'
1111
import FormatPageSvelte from './components/formatPage.svelte'
1212
import { translate } from './util/translation'
1313
import { process } from './systems/modelDataFixerUpper'
@@ -577,9 +577,6 @@ export const BLUEPRINT_FORMAT = new Blockbench.ModelFormat({
577577
events.UNLOAD.subscribe(() => clearInterval(updateBoundingBoxIntervalId), true)
578578
events.UNINSTALL.subscribe(() => clearInterval(updateBoundingBoxIntervalId), true)
579579

580-
thisProject.materials[TRANSPARENT_TEXTURE.uuid] = TRANSPARENT_TEXTURE_MATERIAL
581-
TRANSPARENT_TEXTURE.updateMaterial()
582-
583580
Project.loadingPromises ??= []
584581
Project.loadingPromises.push(
585582
new Promise<void>(resolve => {
@@ -669,7 +666,7 @@ export function saveBlueprint() {
669666
export function updateRotationLock() {
670667
if (!isCurrentFormat()) return
671668
BLUEPRINT_FORMAT.rotation_limit = !(
672-
!!Group.selected ||
669+
!!Group.first_selected ||
673670
!!AnimatedJava.API.TextDisplay.selected.length ||
674671
!!AnimatedJava.API.VanillaItemDisplay.selected.length ||
675672
!!AnimatedJava.API.VanillaBlockDisplay.selected.length ||

src/components/variantConfigDialog.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" context="module">
22
import { type Valuable } from '../util/stores'
33
import { translate } from '../util/translation'
4-
import { TRANSPARENT_TEXTURE, TextureMap, Variant } from '../variants'
4+
import { TextureMap, Variant } from '../variants'
55
import Checkbox from './dialogItems/checkbox.svelte'
66
import LineInput from './dialogItems/lineInput.svelte'
77
import MissingTexture from '../assets/missing_texture.png'
@@ -19,7 +19,7 @@
1919
export let generateNameFromDisplayName: Valuable<boolean>
2020
export let excludedNodes: Valuable<Array<CollectionItem>>
2121
22-
const availableTextures = [...Texture.all, TRANSPARENT_TEXTURE]
22+
const availableTextures = [...Texture.all]
2323
const primaryTextures = [...Texture.all]
2424
const secondaryTextures = availableTextures
2525

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import './systems/minecraft/blockstateManager'
2020
import './systems/minecraft/assetManager'
2121
import './systems/minecraft/fontManager'
2222
// Misc imports
23-
import { TRANSPARENT_TEXTURE, Variant } from './variants'
23+
import { Variant } from './variants'
2424
import './systems/minecraft/registryManager'
2525
import { MINECRAFT_REGISTRY } from './systems/minecraft/registryManager'
2626
import resourcepackCompiler from './systems/resourcepackCompiler'
@@ -58,7 +58,6 @@ globalThis.AnimatedJava = {
5858
isDataPackPath,
5959
blueprintSettingErrors,
6060
openUnexpectedErrorDialog,
61-
TRANSPARENT_TEXTURE,
6261
BLUEPRINT_FORMAT,
6362
BLUEPRINT_CODEC,
6463
TextDisplay,

src/interface/boneConfigDialog.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const BONE_CONFIG_ACTION = createAction(`${PACKAGE.name}:bone_config`, {
174174
name: translate('action.open_bone_config.name'),
175175
condition: () => Format === BLUEPRINT_FORMAT,
176176
click: () => {
177-
openBoneConfigDialog(Group.selected)
177+
if (!Group.first_selected) return
178+
openBoneConfigDialog(Group.first_selected)
178179
},
179180
})

src/outliner/textDisplay.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ export class TextDisplay extends ResizableOutlinerElement {
215215
}
216216

217217
select() {
218-
if (Group.selected) {
219-
Group.selected.unselect()
218+
if (Group.first_selected) {
219+
Group.first_selected.unselect()
220220
}
221221

222222
if (!Pressing.ctrl && !Pressing.shift) {
@@ -551,7 +551,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_text_display`,
551551
}
552552

553553
selected.forEachReverse(el => el.unselect())
554-
Group.selected && Group.selected.unselect()
554+
Group.first_selected && Group.first_selected.unselect()
555555
textDisplay.select()
556556

557557
Undo.finishEdit('Create Text Display', {

src/outliner/vanillaBlockDisplay.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
145145
}
146146

147147
select() {
148-
if (Group.selected) {
149-
Group.selected.unselect()
148+
if (Group.first_selected) {
149+
Group.first_selected.unselect()
150150
}
151151
if (!Pressing.ctrl && !Pressing.shift) {
152152
if (Cube.selected.length) {
@@ -428,7 +428,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_vanilla_block_
428428
}
429429

430430
selected.forEachReverse(el => el.unselect())
431-
Group.selected && Group.selected.unselect()
431+
Group.first_selected && Group.first_selected.unselect()
432432
vanillaBlockDisplay.select()
433433

434434
Undo.finishEdit('Create Vanilla Block Display', {

src/outliner/vanillaItemDisplay.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ export class VanillaItemDisplay extends ResizableOutlinerElement {
154154
}
155155

156156
select() {
157-
if (Group.selected) {
158-
Group.selected.unselect()
157+
if (Group.first_selected) {
158+
Group.first_selected.unselect()
159159
}
160160
if (!Pressing.ctrl && !Pressing.shift) {
161161
if (Cube.selected.length) {
@@ -428,7 +428,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_vanilla_item_d
428428
}
429429

430430
selected.forEachReverse(el => el.unselect())
431-
Group.selected && Group.selected.unselect()
431+
Group.first_selected && Group.first_selected.unselect()
432432
vanillaItemDisplay.select()
433433

434434
Undo.finishEdit('Create Vanilla Item Display', {

src/systems/resourcepackCompiler/1.21.1.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { MAX_PROGRESS, PROGRESS, PROGRESS_DESCRIPTION } from '../../interface/exportProgressDialog'
22
import { isResourcePackPath, toSafeFuntionName } from '../../util/minecraftUtil'
3-
import { TRANSPARENT_TEXTURE } from '../../variants'
43
import { IntentionalExportError } from '../exporter'
54
import { ITextureAtlas } from '../minecraft/textureAtlas'
65
import { IRenderedNodes, IRenderedRig } from '../rigRenderer'
@@ -268,16 +267,6 @@ export default async function compileResourcePack(options: {
268267
}
269268
exportedFiles.set(blockAtlasFile, autoStringify(blockAtlas))
270269

271-
// Transparent texture
272-
const transparentTexturePath = PathModule.join(
273-
resourcePackFolder,
274-
'assets/animated_java/textures/blueprint/transparent.png'
275-
)
276-
exportedFiles.set(
277-
transparentTexturePath,
278-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
279-
)
280-
281270
// Variant Models
282271
for (const variant of Object.values(rig.variants)) {
283272
for (const [boneUuid, variantModel] of Object.entries(variant.models)) {

src/systems/resourcepackCompiler/1.21.2.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { MAX_PROGRESS, PROGRESS, PROGRESS_DESCRIPTION } from '../../interface/exportProgressDialog'
22
import { isResourcePackPath, toSafeFuntionName } from '../../util/minecraftUtil'
3-
import { TRANSPARENT_TEXTURE } from '../../variants'
43
import { IntentionalExportError } from '../exporter'
54
import { type ITextureAtlas } from '../minecraft/textureAtlas'
65
import { IRenderedNodes, IRenderedRig } from '../rigRenderer'
@@ -131,16 +130,6 @@ export default async function compileResourcePack(options: {
131130
)
132131
}
133132

134-
// Transparent texture
135-
const transparentTexturePath = PathModule.join(
136-
resourcePackFolder,
137-
'assets/animated_java/textures/blueprint/transparent.png'
138-
)
139-
exportedFiles.set(
140-
transparentTexturePath,
141-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
142-
)
143-
144133
// Variant Models
145134
for (const variant of Object.values(rig.variants)) {
146135
for (const [boneUuid, variantModel] of Object.entries(variant.models)) {

src/systems/resourcepackCompiler/1.21.4.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MAX_PROGRESS, PROGRESS, PROGRESS_DESCRIPTION } from '../../interface/exportProgressDialog'
22
import { isResourcePackPath, toSafeFuntionName } from '../../util/minecraftUtil'
3-
import { TRANSPARENT_TEXTURE, Variant } from '../../variants'
3+
import { Variant } from '../../variants'
44
import { IntentionalExportError } from '../exporter'
55
import { IItemDefinition } from '../minecraft/itemDefinitions'
66
import { type ITextureAtlas } from '../minecraft/textureAtlas'
@@ -119,16 +119,6 @@ export default async function compileResourcePack(options: {
119119
)
120120
}
121121

122-
// Transparent texture
123-
const transparentTexturePath = PathModule.join(
124-
resourcePackFolder,
125-
'assets/animated_java/textures/blueprint/transparent.png'
126-
)
127-
exportedFiles.set(
128-
transparentTexturePath,
129-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
130-
)
131-
132122
// Item Model Definitions
133123
const defaultVariant = Variant.getDefault()
134124

src/systems/rigRenderer.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
parseResourcePackPath,
1313
toSafeFuntionName,
1414
} from '../util/minecraftUtil'
15-
import { TRANSPARENT_TEXTURE, TRANSPARENT_TEXTURE_RESOURCE_LOCATION, Variant } from '../variants'
15+
import { Variant } from '../variants'
1616
import {
1717
correctSceneAngle,
1818
getFrame,
@@ -240,8 +240,7 @@ function renderCube(cube: Cube, rig: IRenderedRig, model: IRenderedModel) {
240240

241241
element.faces = {}
242242
for (const [face, data] of Object.entries(cube.faces)) {
243-
if (!data) continue
244-
if (!data.texture || data.getTexture()?.uuid === TRANSPARENT_TEXTURE.uuid) continue
243+
if (!data?.texture) continue
245244
const renderedFace = {} as IRenderedFace
246245
if (data.enabled) {
247246
renderedFace.uv = data.uv
@@ -570,20 +569,11 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
570569
for (const [fromUUID, toUUID] of variant.textureMap.map.entries()) {
571570
const fromTexture = Texture.all.find(t => t.uuid === fromUUID)
572571
if (!fromTexture) throw new Error(`From texture not found: ${fromUUID}`)
573-
if (toUUID === TRANSPARENT_TEXTURE.uuid) {
574-
textures[fromTexture.id] = TRANSPARENT_TEXTURE_RESOURCE_LOCATION
575-
rig.textures[TRANSPARENT_TEXTURE.id] = TRANSPARENT_TEXTURE
576-
unreplacedTextures.delete(fromTexture.id)
577-
} else {
578-
const toTexture = Texture.all.find(t => t.uuid === toUUID)
579-
if (!toTexture) throw new Error(`To texture not found: ${toUUID}`)
580-
textures[fromTexture.id] = getTextureResourceLocation(
581-
toTexture,
582-
rig
583-
).resourceLocation
584-
rig.textures[toTexture.id] = toTexture
585-
isOnlyTransparent = false
586-
}
572+
const toTexture = Texture.all.find(t => t.uuid === toUUID)
573+
if (!toTexture) throw new Error(`To texture not found: ${toUUID}`)
574+
textures[fromTexture.id] = getTextureResourceLocation(toTexture, rig).resourceLocation
575+
rig.textures[toTexture.id] = toTexture
576+
isOnlyTransparent = false
587577
}
588578

589579
// Don't export models without any texture changes

src/variants.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
import { IBlueprintVariantJSON } from './blueprintFormat'
2-
import { PACKAGE } from './constants'
32
import { events } from './util/events'
4-
import TransparentTexture from './assets/transparent.png'
53
import { toSafeFuntionName } from './util/minecraftUtil'
64

7-
const OLD_PROJECT = Project
8-
// @ts-ignore
9-
Project = { materials: {} }
10-
export const TRANSPARENT_TEXTURE = new Texture(
11-
{
12-
id: `${PACKAGE.name}:transparent_texture`,
13-
name: 'Transparent',
14-
},
15-
'797174ae-5c58-4a83-a630-eefd51007c80'
16-
).fromDataURL(TransparentTexture)
17-
export const TRANSPARENT_TEXTURE_MATERIAL = Project!.materials[TRANSPARENT_TEXTURE.uuid]
18-
export const TRANSPARENT_TEXTURE_RESOURCE_LOCATION = 'animated_java:blueprint/transparent'
19-
Project = OLD_PROJECT
20-
215
export class TextureMap {
226
map: Map<string, string>
237

@@ -46,7 +30,6 @@ export class TextureMap {
4630
*/
4731
public getMappedTexture(texture: Texture | string): Texture | undefined {
4832
const uuid = this.map.get(texture instanceof Texture ? texture.uuid : texture)
49-
if (uuid === TRANSPARENT_TEXTURE.uuid) return TRANSPARENT_TEXTURE
5033
return Texture.all.find(t => t.uuid === uuid)
5134
}
5235

@@ -74,7 +57,6 @@ export class TextureMap {
7457

7558
public verifyTextures() {
7659
for (const [key, value] of this.map) {
77-
if (value === TRANSPARENT_TEXTURE.uuid) continue
7860
if (!Texture.all.some(t => t.uuid === value)) {
7961
this.map.delete(key)
8062
}

0 commit comments

Comments
 (0)