Skip to content

Commit f356972

Browse files
committed
🐛 shadow_color is ignored while caching character meshes
1 parent f8755d9 commit f356972

File tree

3 files changed

+60
-27
lines changed

3 files changed

+60
-27
lines changed

src/systems/minecraft/fontManager.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
import { createHash } from 'crypto'
2+
import MissingCharacter from '../../assets/missing_character.png'
3+
import { type Alignment } from '../../outliner/textDisplay'
4+
import { mergeGeometries } from '../../util/bufferGeometryUtils'
15
import { events } from '../../util/events'
2-
import { COLOR_MAP, JsonText } from './jsonText'
36
import { getPathFromResourceLocation } from '../../util/minecraftUtil'
7+
import { UnicodeString } from '../../util/unicodeString'
48
import * as assets from './assetManager'
5-
import MissingCharacter from '../../assets/missing_character.png'
9+
import { COLOR_MAP, JsonText } from './jsonText'
610
import {
11+
computeTextWrapping,
12+
getComponentWords,
713
IComponentWord,
814
IStyleSpan,
9-
getComponentWords,
10-
computeTextWrapping,
1115
StyleRecord,
1216
} from './textWrapping'
13-
import { createHash } from 'crypto'
14-
import { UnicodeString } from '../../util/unicodeString'
15-
import { type Alignment } from '../../outliner/textDisplay'
16-
import { mergeGeometries } from '../../util/bufferGeometryUtils'
1717

1818
interface IFontProviderBitmap {
1919
type: 'bitmap'
@@ -530,12 +530,13 @@ export class MinecraftFont {
530530
if (charData.type === 'bitmap') {
531531
const hash = createHash('sha256')
532532
hash.update(char)
533-
hash.update(color.getHexString())
533+
hash.update(';' + color.getHexString())
534534
if (shadow) hash.update('shadow')
535535
if (style.bold) hash.update('bold')
536536
if (style.italic) hash.update('italic')
537537
if (style.underlined) hash.update('underlined')
538538
if (style.strikethrough) hash.update('strikethrough')
539+
if (style.shadow_color) hash.update(';' + shadowColor.getHexString())
539540
if (style.font) hash.update(';' + font.id)
540541
// if (style.obfuscated) hash.update('obfuscated')
541542
const digest = hash.digest('hex')

src/systems/minecraft/jsonText.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,20 @@ class JsonTextParser {
297297
case 'fallback':
298298
obj[key] = this.parseString()
299299
break
300-
case 'color':
301-
case 'shadow_color': {
300+
case 'color': {
302301
const color = this.parseString() as JsonTextColor
303302
if (!(color.startsWith('#') || COLOR_MAP[color])) {
304303
throw new ParserError(`Unknown color '${color}'`, this.s)
305304
}
306-
if (key === 'color') {
307-
obj.color = color
308-
} else {
309-
obj.shadow_color = color
305+
obj.color = color
306+
break
307+
}
308+
case 'shadow_color': {
309+
const color = this.parseString() as JsonTextColor
310+
if (!(color.startsWith('#') || COLOR_MAP[color])) {
311+
throw new ParserError(`Unknown color '${color}'`, this.s)
310312
}
313+
obj.shadow_color = color
311314
break
312315
}
313316
case 'bold':

test_blueprints/armor_stand.ajblueprint

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"meta": {
33
"format": "animated_java_blueprint",
4-
"format_version": "1.6.4",
4+
"format_version": "1.6.5",
55
"uuid": "167b27cd-b559-3f13-a97c-0841fe21f1d1",
66
"save_location": "D:\\github-repos\\animated-java\\animated-java\\test_blueprints\\armor_stand.ajblueprint",
77
"last_used_export_namespace": "armor_stand"
@@ -882,7 +882,7 @@
882882
"config": {},
883883
"item": "minecraft:diamond",
884884
"item_display": "none",
885-
"text": "{\n\t\"text\": \"Hello, World!\",\n\t\"color\": \"green\"\n}\n",
885+
"text": "{\n\t\"text\": \"Hello, World!\",\n\t\"color\": \"green\",\n\t\"shadow_color\": \"red\",\n}\n",
886886
"lineWidth": 200,
887887
"backgroundColor": "#ffffff",
888888
"backgroundAlpha": 0.25098,
@@ -894,15 +894,44 @@
894894
},
895895
{
896896
"name": "camera",
897-
"path": "",
898-
"position": [0, 0, 0],
899-
"rotation": [0, 0, 0],
900-
"fov": 70,
901-
"aspect_ratio": [16, 9],
902-
"linked_preview": "",
903-
"camera_linked": false,
904-
"visibility": true,
905-
"type": "camera",
897+
"box_uv": false,
898+
"rescale": false,
899+
"locked": false,
900+
"light_emission": 0,
901+
"render_order": "default",
902+
"allow_mirror_modeling": true,
903+
"from": [0, 0, 0],
904+
"to": [1, 1, 1],
905+
"autouv": 0,
906+
"color": 0,
907+
"origin": [0, 0, 0],
908+
"faces": {
909+
"north": {
910+
"uv": [0, 0, 1, 1],
911+
"texture": 0
912+
},
913+
"east": {
914+
"uv": [0, 0, 1, 1],
915+
"texture": 0
916+
},
917+
"south": {
918+
"uv": [0, 0, 1, 1],
919+
"texture": 0
920+
},
921+
"west": {
922+
"uv": [0, 0, 1, 1],
923+
"texture": 0
924+
},
925+
"up": {
926+
"uv": [0, 0, 1, 1],
927+
"texture": 0
928+
},
929+
"down": {
930+
"uv": [0, 0, 1, 1],
931+
"texture": 0
932+
}
933+
},
934+
"type": "cube",
906935
"uuid": "3f916352-b0e1-f1e4-0e09-308cc68f96e6"
907936
}
908937
],
@@ -3148,7 +3177,7 @@
31483177
"override": false,
31493178
"length": 0.8,
31503179
"snapping": 20,
3151-
"selected": true,
3180+
"selected": false,
31523181
"saved": false,
31533182
"path": "",
31543183
"anim_time_update": "",

0 commit comments

Comments
 (0)