Skip to content

Commit f51819d

Browse files
committed
✨ Visualization of Structure groups
I've also added titles to all custom outliner elements.
1 parent 29cb09a commit f51819d

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class BlockDisplay extends ResizableOutlinerElement {
3838

3939
public type = BlockDisplay.type
4040
public icon = 'deployed_code'
41+
public title = translate('node.block_display.title')
4142
public needsUniqueName = true
4243

4344
// Properties

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class ItemDisplay extends ResizableOutlinerElement {
3535

3636
public type = ItemDisplay.type
3737
public icon = 'icecream'
38+
public title = translate('node.item_display.title')
3839
public needsUniqueName = true
3940

4041
// Properties

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class TextDisplay extends ResizableOutlinerElement {
3939

4040
public type = TextDisplay.type
4141
public icon = 'text_fields'
42+
public title = translate('node.text_display.title')
4243
public needsUniqueName = true
4344

4445
// Properties

src/blockbench-mods/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import './ui/animationsPanel'
3131
import './ui/formatIcon'
3232
import './ui/formatOrder'
3333
import './ui/incompatiblePluginNotice'
34+
import './ui/structureNodeIcons'
3435
// Misc
3536
import './misc/customKeyframes'
3637
import './misc/locatorAnimator'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { PACKAGE } from '@aj/constants'
2+
import { createBlockbenchMod } from '@aj/util/moddingTools'
3+
import { translate } from '@aj/util/translation'
4+
5+
createBlockbenchMod(
6+
`${PACKAGE.name}:structureNodeIcons`,
7+
{
8+
// @ts-expect-error
9+
originalIcon: Group.prototype.icon,
10+
// @ts-expect-error
11+
originalTitle: Group.prototype.title,
12+
},
13+
ctx => {
14+
Object.defineProperty(Group.prototype, 'icon', {
15+
get() {
16+
for (const child of this.children) {
17+
if (child instanceof Cube) {
18+
return ctx.originalIcon
19+
}
20+
}
21+
return 'account_tree'
22+
},
23+
set() {
24+
console.warn('Setting the default Group icon is not allowed!')
25+
},
26+
})
27+
28+
Object.defineProperty(Group.prototype, 'title', {
29+
get() {
30+
for (const child of this.children) {
31+
if (child instanceof Cube) {
32+
return ctx.originalTitle
33+
}
34+
}
35+
return translate('node.structure.title').replaceAll('<br/>', '\n')
36+
},
37+
set() {
38+
console.warn('Setting the default Group icon is not allowed!')
39+
},
40+
})
41+
42+
return ctx
43+
},
44+
ctx => {
45+
Object.defineProperty(Group.prototype, 'icon', {
46+
value: ctx.originalIcon,
47+
get: undefined,
48+
set: undefined,
49+
})
50+
Object.defineProperty(Group.prototype, 'title', {
51+
value: ctx.originalTitle,
52+
get: undefined,
53+
set: undefined,
54+
})
55+
}
56+
)

src/lang/en.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ panel:
125125
animated_java:block_display:
126126
label: Block Display
127127

128+
node:
129+
structure.title: |-
130+
Structure - (Animated Java)
131+
A Group will become a Structure if it doesn't have Cube children.
132+
Structures will not create an entity in-game, but can be used to organize your model, and effect the animation.
133+
item_display.title: Item Display
134+
block_display.title: Block Display
135+
text_display.title: Text Display
136+
128137
# ----------------------------------------
129138
# OLD TRANSLATIONS
130139
# ----------------------------------------

0 commit comments

Comments
 (0)