Skip to content

Commit 0070b9c

Browse files
committed
🛠️ Slightly improved empty JSON text rendering
#322
1 parent 5781f3f commit 0070b9c

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/outliner/textDisplay.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export class TextDisplay extends ResizableOutlinerElement {
270270
this.textError.set('')
271271
try {
272272
text = JsonText.fromString(this.text)
273+
console.log(text)
273274
} catch (e: any) {
274275
console.error(e)
275276
this.textError.set(e.message as string)
@@ -282,7 +283,7 @@ export class TextDisplay extends ResizableOutlinerElement {
282283
this._newBackgroundAlpha = undefined
283284
this._newShadow = undefined
284285
this._newAlign = undefined
285-
if (!text) continue
286+
if (text === undefined) continue
286287
latestMesh = await this.setText(text)
287288
}
288289
this._updating = false

src/outliner/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function sanitizeOutlinerElementName(name: string, elementUUID: string):
1212
...VanillaItemDisplay.all,
1313
]
1414
if (OutlinerElement.types.camera) {
15-
otherNodes.push(OutlinerElement.types.camera)
15+
otherNodes.push(...OutlinerElement.types.camera.all)
1616
}
1717
const otherNames = new Set(otherNodes.map(v => v.name))
1818

src/systems/minecraft/jsonText.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class JsonTextParser {
162162
this.s = new StringStream(str)
163163
}
164164

165-
parse(): JsonText | undefined {
165+
parse(): JsonText {
166166
let text: JsonTextComponent | undefined
167167
try {
168168
text = this.parseTextComponent(true)
@@ -172,6 +172,7 @@ class JsonTextParser {
172172
if (text) {
173173
return new JsonText(text)
174174
}
175+
return new JsonText('')
175176
}
176177

177178
consumeWhitespace() {

test_blueprints/armor_stand.ajblueprint

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,11 @@
878878
"rotation": [0, 0, 0],
879879
"scale": [1, 1, 1],
880880
"visibility": true,
881+
"block": "minecraft:stone",
882+
"config": {},
881883
"item": "minecraft:diamond",
882884
"item_display": "none",
883-
"config": {},
884-
"block": "minecraft:stone",
885-
"text": "\"Hello World!\"\n",
885+
"text": "\"Hello, World!\"\n",
886886
"lineWidth": 200,
887887
"backgroundColor": "#ffffff",
888888
"backgroundAlpha": 0.25098,
@@ -1502,7 +1502,7 @@
15021502
"default": {
15031503
"name": "default",
15041504
"display_name": "Default",
1505-
"uuid": "bdd4ab62-ecd7-75eb-1be3-6787b9d8db79",
1505+
"uuid": "646a10f7-499f-3875-2a76-70898d364798",
15061506
"texture_map": {},
15071507
"excluded_nodes": [],
15081508
"is_default": true
@@ -3108,7 +3108,7 @@
31083108
"override": false,
31093109
"length": 0.8,
31103110
"snapping": 20,
3111-
"selected": true,
3111+
"selected": false,
31123112
"saved": false,
31133113
"path": "",
31143114
"anim_time_update": "",

0 commit comments

Comments
 (0)