Skip to content

Commit 75a717d

Browse files
committed
🚧 Begin work on Display Panel
Very work-in-progress! Does not function
1 parent ca598ea commit 75a717d

File tree

28 files changed

+540
-196
lines changed

28 files changed

+540
-196
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
245245
break
246246
}
247247
case newElement instanceof AnimatedJava.API.TextDisplay:
248-
case newElement instanceof AnimatedJava.API.VanillaItemDisplay:
249-
case newElement instanceof AnimatedJava.API.VanillaBlockDisplay: {
248+
case newElement instanceof AnimatedJava.API.ItemDisplay:
249+
case newElement instanceof AnimatedJava.API.BlockDisplay: {
250250
// ES-Lint doesn't like the types here for some reason, so I'm casing them to please it.
251251
Project.loadingPromises.push(newElement.waitForReady() as Promise<void>)
252252
break
@@ -599,8 +599,8 @@ export function updateRotationLock() {
599599
BLUEPRINT_FORMAT.rotation_limit = !(
600600
!!Group.first_selected ||
601601
!!AnimatedJava.API.TextDisplay.selected.length ||
602-
!!AnimatedJava.API.VanillaItemDisplay.selected.length ||
603-
!!AnimatedJava.API.VanillaBlockDisplay.selected.length ||
602+
!!AnimatedJava.API.ItemDisplay.selected.length ||
603+
!!AnimatedJava.API.BlockDisplay.selected.length ||
604604
!!(OutlinerElement.types.camera?.selected && OutlinerElement.types.camera?.selected)
605605
)
606606
BLUEPRINT_FORMAT.rotation_snap = BLUEPRINT_FORMAT.rotation_limit

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { sanitizeOutlinerElementName } from './util'
1717
const ERROR_OUTLINE_MATERIAL = Canvas.outlineMaterial.clone()
1818
ERROR_OUTLINE_MATERIAL.color.set('#ff0000')
1919

20-
interface VanillaBlockDisplayOptions {
20+
interface BlockDisplayOptions {
2121
name?: string
2222
block?: string
2323
position?: ArrayVector3
@@ -26,12 +26,12 @@ interface VanillaBlockDisplayOptions {
2626
visibility?: boolean
2727
}
2828

29-
export class VanillaBlockDisplay extends ResizableOutlinerElement {
29+
export class BlockDisplay extends ResizableOutlinerElement {
3030
static type = `${PACKAGE.name}:vanilla_block_display`
31-
static selected: VanillaBlockDisplay[] = []
32-
static all: VanillaBlockDisplay[] = []
31+
static selected: BlockDisplay[] = []
32+
static all: BlockDisplay[] = []
3333

34-
public type = VanillaBlockDisplay.type
34+
public type = BlockDisplay.type
3535
public icon = 'deployed_code'
3636
public needsUniqueName = true
3737

@@ -54,12 +54,12 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
5454

5555
public ready = false
5656

57-
constructor(data: VanillaBlockDisplayOptions, uuid = guid()) {
57+
constructor(data: BlockDisplayOptions, uuid = guid()) {
5858
super(data, uuid)
59-
VanillaBlockDisplay.all.push(this)
59+
BlockDisplay.all.push(this)
6060

61-
for (const key in VanillaBlockDisplay.properties) {
62-
VanillaBlockDisplay.properties[key].reset(this)
61+
for (const key in BlockDisplay.properties) {
62+
BlockDisplay.properties[key].reset(this)
6363
}
6464

6565
this.name = 'block_display'
@@ -120,10 +120,10 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
120120
}
121121

122122
getUndoCopy() {
123-
const copy = {} as VanillaBlockDisplayOptions & { uuid: string; type: string }
123+
const copy = {} as BlockDisplayOptions & { uuid: string; type: string }
124124

125-
for (const key in VanillaBlockDisplay.properties) {
126-
VanillaBlockDisplay.properties[key].copy(this, copy)
125+
for (const key in BlockDisplay.properties) {
126+
BlockDisplay.properties[key].copy(this, copy)
127127
}
128128

129129
copy.uuid = this.uuid
@@ -133,8 +133,8 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
133133

134134
getSaveCopy() {
135135
const el: any = {}
136-
for (const key in VanillaBlockDisplay.properties) {
137-
VanillaBlockDisplay.properties[key].copy(this, el)
136+
for (const key in BlockDisplay.properties) {
137+
BlockDisplay.properties[key].copy(this, el)
138138
}
139139
el.uuid = this.uuid
140140
el.type = this.type
@@ -154,7 +154,7 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
154154
}
155155
}
156156

157-
VanillaBlockDisplay.selected.safePush(this)
157+
BlockDisplay.selected.safePush(this)
158158
this.selectLow()
159159
this.showInOutliner()
160160
updateSelection()
@@ -175,25 +175,25 @@ export class VanillaBlockDisplay extends ResizableOutlinerElement {
175175
Timeline.selected.empty()
176176
}
177177
Project!.selected_elements.remove(this)
178-
VanillaBlockDisplay.selected.remove(this)
178+
BlockDisplay.selected.remove(this)
179179
this.selected = false
180180
TickUpdates.selection = true
181181
this.preview_controller.updateHighlight(this)
182182
}
183183
}
184-
new Property(VanillaBlockDisplay, 'string', 'block', { default: 'minecraft:stone' })
185-
new Property(VanillaBlockDisplay, 'object', 'config', {
184+
new Property(BlockDisplay, 'string', 'block', { default: 'minecraft:stone' })
185+
new Property(BlockDisplay, 'object', 'config', {
186186
get default() {
187187
return new GenericDisplayConfig().toJSON()
188188
},
189189
})
190-
OutlinerElement.registerType(VanillaBlockDisplay, VanillaBlockDisplay.type)
190+
OutlinerElement.registerType(BlockDisplay, BlockDisplay.type)
191191

192-
export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay, {
193-
setup(el: VanillaBlockDisplay) {
192+
export const PREVIEW_CONTROLLER = new NodePreviewController(BlockDisplay, {
193+
setup(el: BlockDisplay) {
194194
ResizableOutlinerElement.prototype.preview_controller.setup(el)
195195
},
196-
updateGeometry(el: VanillaBlockDisplay) {
196+
updateGeometry(el: BlockDisplay) {
197197
if (!el.mesh) return
198198

199199
void getBlockModel(el.block)
@@ -231,10 +231,10 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay,
231231
el.ready = true
232232
})
233233
},
234-
updateTransform(el: VanillaBlockDisplay) {
234+
updateTransform(el: BlockDisplay) {
235235
ResizableOutlinerElement.prototype.preview_controller.updateTransform(el)
236236
},
237-
updateHighlight(el: VanillaBlockDisplay, force?: boolean | VanillaBlockDisplay) {
237+
updateHighlight(el: BlockDisplay, force?: boolean | BlockDisplay) {
238238
if (!isCurrentFormat() || !el?.mesh) return
239239
const highlighted = Modes.edit && (force === true || force === el || el.selected) ? 1 : 0
240240

@@ -253,11 +253,11 @@ export const PREVIEW_CONTROLLER = new NodePreviewController(VanillaBlockDisplay,
253253
},
254254
})
255255

256-
class VanillaBlockDisplayAnimator extends BoneAnimator {
256+
class BlockDisplayAnimator extends BoneAnimator {
257257
private __name: string
258258

259259
public uuid: string
260-
public element: VanillaBlockDisplay | undefined
260+
public element: BlockDisplay | undefined
261261

262262
constructor(uuid: string, animation: _Animation, name: string) {
263263
super(uuid, animation, name)
@@ -266,7 +266,7 @@ class VanillaBlockDisplayAnimator extends BoneAnimator {
266266
}
267267

268268
getElement() {
269-
this.element = OutlinerNode.uuids[this.uuid] as VanillaBlockDisplay
269+
this.element = OutlinerNode.uuids[this.uuid] as BlockDisplay
270270
return this.element
271271
}
272272

@@ -371,8 +371,8 @@ class VanillaBlockDisplayAnimator extends BoneAnimator {
371371
return this
372372
}
373373
}
374-
VanillaBlockDisplayAnimator.prototype.type = VanillaBlockDisplay.type
375-
VanillaBlockDisplay.animator = VanillaBlockDisplayAnimator as any
374+
BlockDisplayAnimator.prototype.type = BlockDisplay.type
375+
BlockDisplay.animator = BlockDisplayAnimator as any
376376

377377
createBlockbenchMod(
378378
`${PACKAGE.name}:vanillaBlockDisplay`,
@@ -387,12 +387,12 @@ createBlockbenchMod(
387387
context.subscriptions.push(
388388
EVENTS.SELECT_PROJECT.subscribe(project => {
389389
project.vanillaBlockDisplays ??= []
390-
VanillaBlockDisplay.all.empty()
391-
VanillaBlockDisplay.all.push(...project.vanillaBlockDisplays)
390+
BlockDisplay.all.empty()
391+
BlockDisplay.all.push(...project.vanillaBlockDisplays)
392392
}),
393393
EVENTS.UNSELECT_PROJECT.subscribe(project => {
394-
project.vanillaBlockDisplays = [...VanillaBlockDisplay.all]
395-
VanillaBlockDisplay.all.empty()
394+
project.vanillaBlockDisplays = [...BlockDisplay.all]
395+
BlockDisplay.all.empty()
396396
})
397397
)
398398
return context
@@ -416,7 +416,7 @@ export const CREATE_ACTION = createAction(`${PACKAGE.name}:create_vanilla_block_
416416
click() {
417417
Undo.initEdit({ outliner: true, elements: [], selection: true })
418418

419-
const vanillaBlockDisplay = new VanillaBlockDisplay({}).init()
419+
const vanillaBlockDisplay = new BlockDisplay({}).init()
420420
const group = getCurrentGroup()
421421

422422
if (group instanceof Group) {
@@ -444,7 +444,7 @@ export function debugBlocks() {
444444
const block = MINECRAFT_REGISTRY.block.items[i]
445445
const x = (i % maxX) * 32
446446
const y = Math.floor(i / maxX) * 32
447-
new VanillaBlockDisplay({ name: block, block, position: [x, 8, y] }).init()
447+
new BlockDisplay({ name: block, block, position: [x, 8, y] }).init()
448448
}
449449
}
450450

@@ -459,7 +459,7 @@ export async function debugBlockState(block: string) {
459459
const x = (i % maxX) * 32
460460
const y = Math.floor(i / maxX) * 32
461461
const str = generateBlockStateString(permutations[i])
462-
new VanillaBlockDisplay({
462+
new BlockDisplay({
463463
name: block + str,
464464
block: block + str,
465465
position: [x, 8, y],

0 commit comments

Comments
 (0)