Skip to content

Commit 7aac7a2

Browse files
committed
Merge branch 'blockbench-4.12.0' into next
2 parents a921620 + 26a5af7 commit 7aac7a2

13 files changed

+24
-88
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'
@@ -572,9 +572,6 @@ export const BLUEPRINT_FORMAT = new Blockbench.ModelFormat({
572572
events.UNLOAD.subscribe(() => clearInterval(updateBoundingBoxIntervalId), true)
573573
events.UNINSTALL.subscribe(() => clearInterval(updateBoundingBoxIntervalId), true)
574574

575-
thisProject.materials[TRANSPARENT_TEXTURE.uuid] = TRANSPARENT_TEXTURE_MATERIAL
576-
TRANSPARENT_TEXTURE.updateMaterial()
577-
578575
Project.loadingPromises ??= []
579576
Project.loadingPromises.push(
580577
new Promise<void>(resolve => {
@@ -664,7 +661,7 @@ export function saveBlueprint() {
664661
export function updateRotationLock() {
665662
if (!isCurrentFormat()) return
666663
BLUEPRINT_FORMAT.rotation_limit = !(
667-
!!Group.selected ||
664+
!!Group.first_selected ||
668665
!!AnimatedJava.API.TextDisplay.selected.length ||
669666
!!AnimatedJava.API.VanillaItemDisplay.selected.length ||
670667
!!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'
@@ -59,7 +59,6 @@ globalThis.AnimatedJava = {
5959
isDataPackPath,
6060
blueprintSettingErrors,
6161
openUnexpectedErrorDialog,
62-
TRANSPARENT_TEXTURE,
6362
BLUEPRINT_FORMAT,
6463
BLUEPRINT_CODEC,
6564
TextDisplay,

src/interface/dialog/boneConfig.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
@@ -212,8 +212,8 @@ export class TextDisplay extends ResizableOutlinerElement {
212212
}
213213

214214
select() {
215-
if (Group.selected) {
216-
Group.selected.unselect()
215+
if (Group.first_selected) {
216+
Group.first_selected.unselect()
217217
}
218218

219219
if (!Pressing.ctrl && !Pressing.shift) {
@@ -548,7 +548,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_text_display`,
548548
}
549549

550550
selected.forEachReverse(el => el.unselect())
551-
Group.selected && Group.selected.unselect()
551+
Group.first_selected && Group.first_selected.unselect()
552552
textDisplay.select()
553553

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

src/outliner/vanillaBlockDisplay.ts

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

145145
select() {
146-
if (Group.selected) {
147-
Group.selected.unselect()
146+
if (Group.first_selected) {
147+
Group.first_selected.unselect()
148148
}
149149
if (!Pressing.ctrl && !Pressing.shift) {
150150
if (Cube.selected.length) {
@@ -426,7 +426,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_vanilla_block_
426426
}
427427

428428
selected.forEachReverse(el => el.unselect())
429-
Group.selected && Group.selected.unselect()
429+
Group.first_selected && Group.first_selected.unselect()
430430
vanillaBlockDisplay.select()
431431

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

src/outliner/vanillaItemDisplay.ts

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

153153
select() {
154-
if (Group.selected) {
155-
Group.selected.unselect()
154+
if (Group.first_selected) {
155+
Group.first_selected.unselect()
156156
}
157157
if (!Pressing.ctrl && !Pressing.shift) {
158158
if (Cube.selected.length) {
@@ -425,7 +425,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_vanilla_item_d
425425
}
426426

427427
selected.forEachReverse(el => el.unselect())
428-
Group.selected && Group.selected.unselect()
428+
Group.first_selected && Group.first_selected.unselect()
429429
vanillaItemDisplay.select()
430430

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

src/systems/resourcepackCompiler/1.20.4.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/dialog/exportProgress'
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'
@@ -242,16 +241,6 @@ export default async function compileResourcePack(options: {
242241
}
243242
exportedFiles.set(blockAtlasPath, autoStringify(blockAtlas))
244243

245-
// Transparent texture
246-
const transparentTexturePath = PathModule.join(
247-
resourcePackFolder,
248-
'assets/animated_java/textures/blueprint/transparent.png'
249-
)
250-
exportedFiles.set(
251-
transparentTexturePath,
252-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
253-
)
254-
255244
// Variant Models
256245
for (const variant of Object.values(rig.variants)) {
257246
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/dialog/exportProgress'
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'
@@ -109,16 +108,6 @@ export default async function compileResourcePack(options: {
109108
)
110109
}
111110

112-
// Transparent texture
113-
const transparentTexturePath = PathModule.join(
114-
resourcePackFolder,
115-
'assets/animated_java/textures/blueprint/transparent.png'
116-
)
117-
exportedFiles.set(
118-
transparentTexturePath,
119-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
120-
)
121-
122111
// Variant Models
123112
for (const variant of Object.values(rig.variants)) {
124113
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/dialog/exportProgress'
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'
@@ -108,16 +108,6 @@ export default async function compileResourcePack(options: {
108108
)
109109
}
110110

111-
// Transparent texture
112-
const transparentTexturePath = PathModule.join(
113-
resourcePackFolder,
114-
'assets/animated_java/textures/blueprint/transparent.png'
115-
)
116-
exportedFiles.set(
117-
transparentTexturePath,
118-
nativeImage.createFromDataURL(TRANSPARENT_TEXTURE.source).toPNG()
119-
)
120-
121111
// Item Model Definitions
122112
const defaultVariant = Variant.getDefault()
123113

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)