Skip to content

Commit 0d2932e

Browse files
SnaveSutitgitbutler-client
authored andcommitted
✨ Split brightnessOverride into skyBrightness and blockBrightness
1 parent 8885b91 commit 0d2932e

11 files changed

Lines changed: 151 additions & 49 deletions

File tree

schemas/blueprint-project.schema.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@
517517
"glow_color",
518518
"shadow_radius",
519519
"shadow_strength",
520-
"brightness_override",
520+
"sky_brightness",
521+
"block_brightness",
521522
"enchanted",
522523
"invisible",
523524
"nbt"
@@ -556,6 +557,18 @@
556557
"maximum": 15,
557558
"default": 0
558559
},
560+
"sky_brightness": {
561+
"type": "number",
562+
"minimum": 0,
563+
"maximum": 15,
564+
"default": 0
565+
},
566+
"block_brightness": {
567+
"type": "number",
568+
"minimum": 0,
569+
"maximum": 15,
570+
"default": 0
571+
},
559572
"enchanted": {
560573
"type": "boolean",
561574
"default": false

schemas/plugin-blueprint.schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,20 @@
450450
"default": "fixed"
451451
},
452452
"custom_brightness": {
453-
"type": "number",
454-
"default": 0
453+
"type": "object",
454+
"required": ["sky", "block"],
455+
"properties": {
456+
"sky": {
457+
"type": "number",
458+
"minimum": 0,
459+
"maximum": 15
460+
},
461+
"block": {
462+
"type": "number",
463+
"minimum": 0,
464+
"maximum": 15
465+
}
466+
}
455467
},
456468
"custom_name": {
457469
"$ref": "#/definitions/optional_adventure_component",

src/dialogs/displayEntityConfig/displayEntityConfig.svelte

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
3434
let billboard = observable<string>(DEFAULT_CONFIG.billboard)
3535
let overrideBrightness = observable<boolean>(DEFAULT_CONFIG.overrideBrightness)
36-
let brightnessOverride = observable<number>(DEFAULT_CONFIG.brightnessOverride)
36+
let skyBrightness = observable<number>(DEFAULT_CONFIG.skyBrightness)
37+
let blockBrightness = observable<number>(DEFAULT_CONFIG.blockBrightness)
3738
let enchanted = observable<boolean>(DEFAULT_CONFIG.enchanted)
3839
let glowing = observable<boolean>(DEFAULT_CONFIG.glowing)
3940
let overrideGlowColor = observable<boolean>(DEFAULT_CONFIG.overrideGlowColor)
@@ -58,7 +59,8 @@
5859
$onApplyFunction = config.onApplyFunction
5960
$billboard = config.billboard
6061
$overrideBrightness = config.overrideBrightness
61-
$brightnessOverride = config.brightnessOverride
62+
$skyBrightness = config.skyBrightness
63+
$blockBrightness = config.blockBrightness
6264
$enchanted = config.enchanted
6365
$glowing = config.glowing
6466
$overrideGlowColor = config.overrideGlowColor
@@ -95,7 +97,8 @@
9597
config.onApplyFunction = $onApplyFunction
9698
config.billboard = $billboard as BillboardMode
9799
config.overrideBrightness = $overrideBrightness
98-
config.brightnessOverride = $brightnessOverride
100+
config.skyBrightness = $skyBrightness
101+
config.blockBrightness = $blockBrightness
99102
config.enchanted = $enchanted
100103
config.glowing = $glowing
101104
config.overrideGlowColor = $overrideGlowColor
@@ -172,10 +175,20 @@
172175

173176
{#if $overrideBrightness}
174177
<NumberSlider
175-
label={translate('dialog.display_entity.brightness_override.title')}
176-
tooltip={translate('dialog.display_entity.brightness_override.description')}
177-
bind:value={brightnessOverride}
178-
defaultValue={DisplayEntityConfig.prototype.brightnessOverride}
178+
label={translate('dialog.display_entity.sky_brightness.title')}
179+
tooltip={translate('dialog.display_entity.sky_brightness.description')}
180+
bind:value={skyBrightness}
181+
defaultValue={DisplayEntityConfig.prototype.skyBrightness}
182+
min={0}
183+
max={15}
184+
valueStep={1}
185+
/>
186+
187+
<NumberSlider
188+
label={translate('dialog.display_entity.block_brightness.title')}
189+
tooltip={translate('dialog.display_entity.block_brightness.description')}
190+
bind:value={blockBrightness}
191+
defaultValue={DisplayEntityConfig.prototype.blockBrightness}
179192
min={0}
180193
max={15}
181194
valueStep={1}

src/formats/blueprint/dfu.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import v1_0_0_pre7 from './versions/1.0.0-pre7'
1616
import v1_0_0_pre8 from './versions/1.0.0-pre8'
1717
import v1_10_0_beta_1 from './versions/1.10.0-beta.1'
1818
import v1_10_0_beta_4 from './versions/1.10.0-beta.4'
19+
import v1_10_0_beta_7 from './versions/1.10.0-beta.7'
1920
import v1_4_0 from './versions/1.4.0'
2021
import v1_6_3 from './versions/1.6.3'
2122
import v1_6_5 from './versions/1.6.5'
@@ -99,6 +100,8 @@ export function upgradeAnimatedJavaBlueprint(model: any): IBlueprintFormatJSON {
99100
model = v1_10_0_beta_1(model)
100101
case VersionUtil.compare(model.meta.format_version, '<', '1.10.0-beta.4'):
101102
model = v1_10_0_beta_4(model)
103+
case VersionUtil.compare(model.meta.format_version, '<', '1.10.0-beta.7'):
104+
model = v1_10_0_beta_7(model)
102105
}
103106

104107
// Remove unknown blueprint settings

src/formats/blueprint/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export interface IBlueprintDisplayEntityConfigJSON {
4545
on_apply_function?: DisplayEntityConfig['__onApplyFunction']
4646
billboard?: DisplayEntityConfig['billboard']
4747
override_brightness?: DisplayEntityConfig['overrideBrightness']
48-
brightness_override?: DisplayEntityConfig['brightnessOverride']
48+
sky_brightness?: DisplayEntityConfig['skyBrightness']
49+
block_brightness?: DisplayEntityConfig['blockBrightness']
50+
brightness_override?: number
4951
enchanted?: DisplayEntityConfig['enchanted']
5052
glowing?: DisplayEntityConfig['glowing']
5153
override_glow_color?: DisplayEntityConfig['overrideGlowColor']

src/formats/blueprint/versions/1.10.0-beta.1.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@ export default function upgrade(model: any): IBlueprintFormatJSON {
66

77
// Invert rotation xy and position x for Blockbench 5.0
88
for (const animation of fixed.animations ?? []) {
9-
for (const [uuid, animator] of Object.entries<Record<string, any>>(
10-
animation.animators ?? {}
11-
)) {
12-
console.log('Processing animator', uuid, JSON.parse(JSON.stringify(animator)))
9+
for (const animator of Object.values<Record<string, any>>(animation.animators ?? {})) {
1310
for (const keyframe of animator.keyframes ?? []) {
14-
console.log('Processing keyframe', JSON.parse(JSON.stringify(keyframe)))
1511
if (keyframe.channel === 'rotation') {
1612
for (const datapoint of keyframe.data_points ?? []) {
17-
console.log('Processing datapoint', JSON.parse(JSON.stringify(datapoint)))
1813
datapoint.x = invertMolang(datapoint.x)
1914
datapoint.y = invertMolang(datapoint.y)
2015
}
2116
}
2217
if (keyframe.channel === 'position') {
2318
for (const datapoint of keyframe.data_points ?? []) {
24-
console.log(
25-
'Processing position datapoint',
26-
JSON.parse(JSON.stringify(datapoint))
27-
)
2819
datapoint.x = invertMolang(datapoint.x)
2920
}
3021
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { IBlueprintFormatJSON } from '..'
2+
3+
export default function upgrade(model: any): IBlueprintFormatJSON {
4+
console.log('Processing model format 1.10.0-beta.7', JSON.parse(JSON.stringify(model)))
5+
const fixed: IBlueprintFormatJSON = JSON.parse(JSON.stringify(model))
6+
7+
// Split brightness override into separate sky and block brightness values.
8+
for (const group of fixed.groups ?? []) {
9+
if (group.configs?.default) upgradeConfig(group.configs.default)
10+
for (const config of Object.values(group.configs.variants ?? {}) as any) {
11+
upgradeConfig(config)
12+
}
13+
}
14+
for (const element of fixed.elements ?? []) {
15+
if (element.configs?.default) upgradeConfig(element.configs.default)
16+
for (const config of Object.values(element.configs.variants ?? {}) as any) {
17+
upgradeConfig(config)
18+
}
19+
}
20+
21+
return fixed
22+
}
23+
24+
function upgradeConfig(config: any) {
25+
if (config?.brightness_override !== undefined) {
26+
config.sky_brightness ??= config.brightness_override
27+
config.block_brightness ??= config.brightness_override
28+
delete config.brightness_override
29+
}
30+
}

src/lang/en.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ animated_java:
466466
brightness_override:
467467
title: Brightness
468468
description: The brightness of the node. This should be a value between 0 and 15.
469+
sky_brightness:
470+
title: Sky Brightness
471+
description: The sky light brightness of the node. This should be a value between 0 and 15.
472+
block_brightness:
473+
title: Block Brightness
474+
description: The block light brightness of the node. This should be a value between 0 and 15.
469475
use_custom_brightness:
470476
title: Use Custom Brightness
471477
description: Whether or not to enable the custom brightness override for the node.
@@ -632,6 +638,12 @@ animated_java:
632638
brightness_override:
633639
title: Brightness
634640
description: The brightness of the text display. This should be a value between 0 and 15.
641+
sky_brightness:
642+
title: Sky Brightness
643+
description: The sky light brightness of the text display. This should be a value between 0 and 15.
644+
block_brightness:
645+
title: Block Brightness
646+
description: The block light brightness of the text display. This should be a value between 0 and 15.
635647
use_custom_brightness:
636648
title: Use Custom Brightness
637649
description: Whether or not to enable the custom brightness override for the bone.

src/nodeConfigs.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class DisplayEntityConfig {
1313
private __onApplyFunction?: string
1414
private __billboard?: BillboardMode
1515
private __overrideBrightness?: boolean
16-
private __brightnessOverride?: number
16+
private __skyBrightness?: number
17+
private __blockBrightness?: number
1718
private __enchanted?: boolean
1819
private __glowing?: boolean
1920
private __overrideGlowColor?: boolean
@@ -27,7 +28,8 @@ export class DisplayEntityConfig {
2728
on_apply_function: '',
2829
billboard: 'fixed',
2930
override_brightness: false,
30-
brightness_override: 0,
31+
sky_brightness: 0,
32+
block_brightness: 0,
3133
enchanted: false,
3234
glowing: false,
3335
override_glow_color: false,
@@ -64,13 +66,22 @@ export class DisplayEntityConfig {
6466
this.__overrideBrightness = value
6567
}
6668

67-
get brightnessOverride(): NonNullable<DisplayEntityConfig['__brightnessOverride']> {
68-
if (this.__brightnessOverride !== undefined) return this.__brightnessOverride
69+
get skyBrightness(): NonNullable<DisplayEntityConfig['__skyBrightness']> {
70+
if (this.__skyBrightness !== undefined) return this.__skyBrightness
6971
const defaultConfig = DisplayEntityConfig.getDefault()
70-
return defaultConfig.brightnessOverride
72+
return defaultConfig.skyBrightness
7173
}
72-
set brightnessOverride(value: DisplayEntityConfig['__brightnessOverride']) {
73-
this.__brightnessOverride = value
74+
set skyBrightness(value: DisplayEntityConfig['__skyBrightness']) {
75+
this.__skyBrightness = value
76+
}
77+
78+
get blockBrightness(): NonNullable<DisplayEntityConfig['__blockBrightness']> {
79+
if (this.__blockBrightness !== undefined) return this.__blockBrightness
80+
const defaultConfig = DisplayEntityConfig.getDefault()
81+
return defaultConfig.blockBrightness
82+
}
83+
set blockBrightness(value: DisplayEntityConfig['__blockBrightness']) {
84+
this.__blockBrightness = value
7485
}
7586

7687
get enchanted(): NonNullable<DisplayEntityConfig['__enchanted']> {
@@ -141,7 +152,8 @@ export class DisplayEntityConfig {
141152
this.__onApplyFunction === other.__onApplyFunction &&
142153
this.__billboard === other.__billboard &&
143154
this.__overrideBrightness === other.__overrideBrightness &&
144-
this.__brightnessOverride === other.__brightnessOverride &&
155+
this.__skyBrightness === other.__skyBrightness &&
156+
this.__blockBrightness === other.__blockBrightness &&
145157
this.__enchanted === other.__enchanted &&
146158
this.__glowing === other.__glowing &&
147159
this.__overrideGlowColor === other.__overrideGlowColor &&
@@ -161,7 +173,8 @@ export class DisplayEntityConfig {
161173
on_apply_function: this.__onApplyFunction,
162174
billboard: this.__billboard,
163175
override_brightness: this.__overrideBrightness,
164-
brightness_override: this.__brightnessOverride,
176+
sky_brightness: this.__skyBrightness,
177+
block_brightness: this.__blockBrightness,
165178
enchanted: this.__enchanted,
166179
glowing: this.__glowing,
167180
override_glow_color: this.__overrideGlowColor,
@@ -177,8 +190,8 @@ export class DisplayEntityConfig {
177190
if (other.__billboard !== undefined) this.billboard = other.billboard
178191
if (other.__overrideBrightness !== undefined)
179192
this.overrideBrightness = other.overrideBrightness
180-
if (other.__brightnessOverride !== undefined)
181-
this.brightnessOverride = other.brightnessOverride
193+
if (other.__skyBrightness !== undefined) this.skyBrightness = other.skyBrightness
194+
if (other.__blockBrightness !== undefined) this.blockBrightness = other.blockBrightness
182195
if (other.__enchanted !== undefined) this.enchanted = other.enchanted
183196
if (other.__glowing !== undefined) this.glowing = other.glowing
184197
if (other.__overrideGlowColor !== undefined)
@@ -195,8 +208,12 @@ export class DisplayEntityConfig {
195208
if (json.billboard !== undefined) config.__billboard = json.billboard
196209
if (json.override_brightness !== undefined)
197210
config.__overrideBrightness = json.override_brightness
198-
if (json.brightness_override !== undefined)
199-
config.__brightnessOverride = json.brightness_override
211+
if (json.sky_brightness !== undefined) config.__skyBrightness = json.sky_brightness
212+
if (json.block_brightness !== undefined) config.__blockBrightness = json.block_brightness
213+
if (json.brightness_override !== undefined) {
214+
config.__skyBrightness ??= json.brightness_override
215+
config.__blockBrightness ??= json.brightness_override
216+
}
200217
if (json.enchanted !== undefined) config.__enchanted = json.enchanted
201218
if (json.glowing !== undefined) config.__glowing = json.glowing
202219
if (json.override_glow_color !== undefined)
@@ -217,8 +234,8 @@ export class DisplayEntityConfig {
217234
compound.set(
218235
'brightness',
219236
new NbtCompound()
220-
.set('block', new NbtFloat(this.brightnessOverride))
221-
.set('sky', new NbtFloat(this.brightnessOverride))
237+
.set('block', new NbtInt(this.blockBrightness))
238+
.set('sky', new NbtInt(this.skyBrightness))
222239
)
223240
}
224241

src/outliner/interaction.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ export const PREVIEW_CONTROLLER: NodePreviewController = new NodePreviewControll
241241
updateTransform(el: Interaction) {
242242
ResizableOutlinerElement.prototype.preview_controller.updateTransform(el)
243243
if (el.mesh.parent) {
244-
console.log('Updating interaction transform with parent')
245244
Reusable.euler1.setFromQuaternion(
246245
el.mesh.parent.getWorldQuaternion(Reusable.quat1),
247246
'ZYX'

0 commit comments

Comments
 (0)