Skip to content

Commit 61b6a87

Browse files
committed
✨ Rework Node config system (no UI changes)
1 parent 3cb91e7 commit 61b6a87

File tree

33 files changed

+614
-1442
lines changed

33 files changed

+614
-1442
lines changed

src/blockbench-additions/model-formats/ajblueprint/dfu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { GenericDisplayConfig } from '@aj/systems/node-configs'
12
import TransparentTexture from '@assets/transparent.png'
23
import { NbtCompound, NbtList, NbtString, NbtTag } from 'deepslate/lib/nbt'
34
import { type IBlueprintFormatJSON, getDefaultProjectSettings } from '.'
45
import { PACKAGE } from '../../../constants'
5-
import { BoneConfig } from '../../../nodeConfigs'
66
import { openUnexpectedErrorDialog } from '../../../ui/dialogs/unexpected-error'
77

88
export function process(model: any): any {
@@ -276,7 +276,7 @@ function updateModelTo1_0pre1(model: any) {
276276
if (typeof node === 'string') return
277277
bones.push(node.uuid as string)
278278
node.configs = {
279-
default: new BoneConfig().toJSON(),
279+
default: new GenericDisplayConfig().toJSON(),
280280
variants: {},
281281
}
282282
node.children.forEach((child: any) => {

src/blockbench-additions/model-formats/ajblueprint/index.ts

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,17 @@
11
import EVENTS from '@events'
2+
import THREE from 'three'
23
import * as blueprintSettings from '../../../blueprintSettings'
34
import { PACKAGE } from '../../../constants'
45
import { injectSvelteCompomponent } from '../../../util/injectSvelteComponent'
56
import { toSafeFunctionName } from '../../../util/minecraftUtil'
67
import { addProjectToRecentProjects } from '../../../util/misc'
7-
import { type BillboardMode, BoneConfig, LocatorConfig } from '../../../util/serializableConfig'
88
import { Valuable } from '../../../util/stores'
99
import { translate } from '../../../util/translation'
1010
import { Variant } from '../../../variants'
1111
import { process } from './dfu'
1212
import FormatPageSvelte from './formatPage.svelte'
1313
import ProjectTitleSvelte from './projectTitle.svelte'
1414

15-
/**
16-
* The serialized Variant Bone Config
17-
*/
18-
export interface IBlueprintBoneConfigJSON {
19-
custom_name?: BoneConfig['customName']
20-
custom_name_visible?: BoneConfig['customNameVisible']
21-
billboard?: BoneConfig['billboard']
22-
override_brightness?: BoneConfig['overrideBrightness']
23-
brightness_override?: BoneConfig['brightnessOverride']
24-
enchanted?: BoneConfig['enchanted']
25-
glowing?: BoneConfig['glowing']
26-
override_glow_color?: BoneConfig['overrideGlowColor']
27-
glow_color?: BoneConfig['glowColor']
28-
inherit_settings?: BoneConfig['inheritSettings']
29-
invisible?: BoneConfig['invisible']
30-
/**
31-
* Custom NBT for the bone that will be merged when this Variant is applied
32-
*/
33-
nbt?: BoneConfig['nbt']
34-
shadow_radius?: BoneConfig['shadowRadius']
35-
shadow_strength?: BoneConfig['shadowStrength']
36-
use_nbt?: BoneConfig['useNBT']
37-
}
38-
39-
/**
40-
* The serialized Variant Locator Config
41-
*/
42-
export interface IBlueprintLocatorConfigJSON {
43-
use_entity?: LocatorConfig['useEntity']
44-
entity_type?: LocatorConfig['entityType']
45-
summon_commands?: LocatorConfig['_summonCommands']
46-
ticking_commands?: LocatorConfig['tickingCommands']
47-
}
48-
49-
/**
50-
* The serialized Variant Camera Config
51-
*/
52-
export interface IBlueprintCameraConfigJSON {
53-
entity_type?: string
54-
nbt?: string
55-
ticking_commands?: string
56-
}
57-
58-
/**
59-
* The serialized Variant Locator Config
60-
*/
61-
export interface IBlueprintTextDisplayConfigJSON {
62-
billboard?: BillboardMode
63-
override_brightness?: BoneConfig['overrideBrightness']
64-
brightness_override?: BoneConfig['brightnessOverride']
65-
glowing?: BoneConfig['glowing']
66-
override_glow_color?: BoneConfig['overrideGlowColor']
67-
glow_color?: BoneConfig['glowColor']
68-
invisible?: BoneConfig['invisible']
69-
shadow_radius?: BoneConfig['shadowRadius']
70-
shadow_strength?: BoneConfig['shadowStrength']
71-
use_nbt?: BoneConfig['useNBT']
72-
/**
73-
* Custom NBT for the bone that will be merged when this Variant is applied
74-
*/
75-
nbt?: BoneConfig['nbt']
76-
}
77-
7815
/**
7916
* The serialized Variant
8017
*/

src/blockbench-additions/model-formats/ajblueprint/versions/v1.6.4.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import type { PACKAGE } from '@aj/constants'
2-
import {
2+
import type {
33
CameraConfig,
4+
GenericDisplayConfig,
5+
LocatorConfig,
6+
Serialized,
47
TextDisplayConfig,
5-
type BoneConfig,
6-
type LocatorConfig,
7-
} from '@aj/nodeConfigs'
8+
} from '@aj/systems/node-configs'
89

910
namespace v1_6_4 {
10-
type SerializeConfig<T> = {
11-
[Key in keyof T as T[Key] extends Function ? never : Key]: T[Key] | undefined
12-
}
13-
14-
export type IBlueprintBoneConfigJSON = SerializeConfig<BoneConfig>
15-
export type IBlueprintLocatorConfigJSON = SerializeConfig<LocatorConfig>
16-
export type IBlueprintCameraConfigJSON = SerializeConfig<CameraConfig>
17-
export type IBlueprintTextDisplayConfigJSON = SerializeConfig<TextDisplayConfig>
11+
export type IBlueprintBoneConfigJSON = Serialized<GenericDisplayConfig>
12+
export type IBlueprintLocatorConfigJSON = Serialized<LocatorConfig>
13+
export type IBlueprintCameraConfigJSON = Serialized<CameraConfig>
14+
export type IBlueprintTextDisplayConfigJSON = Serialized<TextDisplayConfig>
1815

1916
/**
2017
* The serialized Variant

src/blockbench-additions/outliner-elements/blockDisplay.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { getBlockModel } from '@aj/systems/minecraft-temp/blockModelManager'
22
import { type BlockStateValue, getBlockState } from '@aj/systems/minecraft-temp/blockstateManager'
33
import { MINECRAFT_REGISTRY } from '@aj/systems/minecraft-temp/registryManager'
44
import { getCurrentVersion } from '@aj/systems/minecraft-temp/versionManager'
5+
import { GenericDisplayConfig, type Serialized } from '@aj/systems/node-configs'
56
import EVENTS from '@events'
67
import { PACKAGE } from '../../constants'
78
import { VANILLA_BLOCK_DISPLAY_CONFIG_ACTION } from '../../ui/dialogs/block-display-config'
89
import { parseBlock } from '../../util/minecraftUtil'
910
import { createAction, createBlockbenchMod } from '../../util/moddingTools'
10-
import { BoneConfig } from '../../util/serializableConfig'
1111
import { Valuable } from '../../util/stores'
1212
import { translate } from '../../util/translation'
13-
import { type IBlueprintBoneConfigJSON, isCurrentFormat } from '../model-formats/ajblueprint'
13+
import { isCurrentFormat } from '../model-formats/ajblueprint'
1414
import { ResizableOutlinerElement } from './resizableOutlinerElement'
1515
import { sanitizeOutlinerElementName } from './util'
1616

@@ -36,8 +36,8 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
3636
public needsUniqueName = true
3737

3838
// Properties
39-
public _block = new Valuable('minecraft:stone')
40-
public config: IBlueprintBoneConfigJSON
39+
private __block = new Valuable('minecraft:stone')
40+
public config: Serialized<GenericDisplayConfig>
4141

4242
public error = new Valuable('')
4343

@@ -93,19 +93,19 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
9393
}
9494
}
9595

96-
this._block.subscribe(value => {
96+
this.__block.subscribe(value => {
9797
void updateBlock(value)
9898
})
9999
}
100100

101101
get block() {
102-
if (this._block === undefined) return 'minecraft:stone'
103-
return this._block.get()
102+
if (this.__block === undefined) return 'minecraft:stone'
103+
return this.__block.get()
104104
}
105105
set block(value: string) {
106-
if (this._block === undefined) return
106+
if (this.__block === undefined) return
107107
if (this.block === value) return
108-
this._block.set(value)
108+
this.__block.set(value)
109109
}
110110

111111
async waitForReady() {
@@ -184,7 +184,7 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
184184
new Property(VanillaBlockDisplay, 'string', 'block', { default: 'minecraft:stone' })
185185
new Property(VanillaBlockDisplay, 'object', 'config', {
186186
get default() {
187-
return new BoneConfig().toJSON()
187+
return new GenericDisplayConfig().toJSON()
188188
},
189189
})
190190
OutlinerElement.registerType(VanillaBlockDisplay, VanillaBlockDisplay.type)
@@ -254,15 +254,15 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay,
254254
})
255255

256256
class VanillaBlockDisplayAnimator extends BoneAnimator {
257-
private _name: string
257+
private __name: string
258258

259259
public uuid: string
260260
public element: VanillaBlockDisplay | undefined
261261

262262
constructor(uuid: string, animation: _Animation, name: string) {
263263
super(uuid, animation, name)
264264
this.uuid = uuid
265-
this._name = name
265+
this.__name = name
266266
}
267267

268268
getElement() {

src/blockbench-additions/outliner-elements/itemDisplay.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { getItemModel } from '@aj/systems/minecraft-temp/itemModelManager'
22
import { MINECRAFT_REGISTRY } from '@aj/systems/minecraft-temp/registryManager'
33
import { getCurrentVersion } from '@aj/systems/minecraft-temp/versionManager'
4+
import { GenericDisplayConfig, type Serialized } from '@aj/systems/node-configs'
45
import EVENTS from '@events'
6+
import THREE from 'three'
57
import { PACKAGE } from '../../constants'
68
import { VANILLA_ITEM_DISPLAY_CONFIG_ACTION } from '../../ui/dialogs/item-display-config'
79
import { createAction, createBlockbenchMod } from '../../util/moddingTools'
8-
import { BoneConfig } from '../../util/serializableConfig'
910
import { Valuable } from '../../util/stores'
1011
import { translate } from '../../util/translation'
11-
import { type IBlueprintBoneConfigJSON, isCurrentFormat } from '../model-formats/ajblueprint'
12+
import { isCurrentFormat } from '../model-formats/ajblueprint'
1213
import { ResizableOutlinerElement } from './resizableOutlinerElement'
1314
import { sanitizeOutlinerElementName } from './util'
1415

@@ -32,9 +33,9 @@ export class VanillaItemDisplay extends ResizableOutlinerElement {
3233
public needsUniqueName = true
3334

3435
// Properties
35-
public _item = new Valuable('minecraft:diamond')
36-
public _itemDisplay = new Valuable('none')
37-
public config: IBlueprintBoneConfigJSON
36+
private __item = new Valuable('minecraft:diamond')
37+
private __itemDisplay = new Valuable('none')
38+
public config: Serialized<GenericDisplayConfig>
3839

3940
public error = new Valuable('')
4041

@@ -93,27 +94,27 @@ export class VanillaItemDisplay extends ResizableOutlinerElement {
9394
}
9495
}
9596

96-
this._item.subscribe(value => {
97+
this.__item.subscribe(value => {
9798
updateItem(value)
9899
})
99100
}
100101

101102
get item() {
102-
if (this._item === undefined) return 'minecraft:diamond'
103-
return this._item.get()
103+
if (this.__item === undefined) return 'minecraft:diamond'
104+
return this.__item.get()
104105
}
105106
set item(value: string) {
106-
if (this._item === undefined) return
107-
this._item.set(value)
107+
if (this.__item === undefined) return
108+
this.__item.set(value)
108109
}
109110

110111
get itemDisplay() {
111-
if (this._itemDisplay === undefined) return 'none'
112-
return this._itemDisplay.get()
112+
if (this.__itemDisplay === undefined) return 'none'
113+
return this.__itemDisplay.get()
113114
}
114115
set itemDisplay(value: string) {
115-
if (this._itemDisplay === undefined) return
116-
this._itemDisplay.set(value)
116+
if (this.__itemDisplay === undefined) return
117+
this.__itemDisplay.set(value)
117118
}
118119

119120
async waitForReady() {
@@ -193,7 +194,7 @@ new Property(VanillaItemDisplay, 'string', 'item', { default: 'minecraft:diamond
193194
new Property(VanillaItemDisplay, 'string', 'item_display', { default: 'none' })
194195
new Property(VanillaItemDisplay, 'object', 'config', {
195196
get default() {
196-
return new BoneConfig().toJSON()
197+
return new GenericDisplayConfig().toJSON()
197198
},
198199
})
199200
OutlinerElement.registerType(VanillaItemDisplay, VanillaItemDisplay.type)
@@ -254,15 +255,15 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaItemDisplay,
254255
})
255256

256257
class VanillaItemDisplayAnimator extends BoneAnimator {
257-
private _name: string
258+
private __name: string
258259

259260
public uuid: string
260261
public element: VanillaItemDisplay | undefined
261262

262263
constructor(uuid: string, animation: _Animation, name: string) {
263264
super(uuid, animation, name)
264265
this.uuid = uuid
265-
this._name = name
266+
this.__name = name
266267
}
267268

268269
getElement() {

0 commit comments

Comments
 (0)