From 72ad94bab76b765c731f264cb24c7821bbb045cd Mon Sep 17 00:00:00 2001 From: SpaceshipCaptain <64009670+SpaceshipCaptain@users.noreply.github.com> Date: Mon, 7 Jul 2025 16:25:02 -0500 Subject: [PATCH 1/3] possible fix for getTexture in BlockModel --- src/render/BlockModel.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/render/BlockModel.ts b/src/render/BlockModel.ts index a865d2f2..5433056b 100644 --- a/src/render/BlockModel.ts +++ b/src/render/BlockModel.ts @@ -188,10 +188,16 @@ export class BlockModel { } private getTexture(textureRef: string) { - while (textureRef.startsWith('#')) { - textureRef = this.textures?.[textureRef.slice(1)] ?? '' + let currentRef = textureRef; + for (let i = 0; i < 7; i++) { + const key = currentRef.startsWith('#') ? currentRef.slice(1) : currentRef; + const nextRef = this.textures?.[key]; + if (nextRef === undefined) { + break; + } + currentRef = nextRef; } - return Identifier.parse(textureRef) + return Identifier.parse(currentRef) } public flatten(accessor: BlockModelProvider) { From deeafda4f38a6cbd5d434311bf624f585d8b947d Mon Sep 17 00:00:00 2001 From: SpaceshipCaptain <64009670+SpaceshipCaptain@users.noreply.github.com> Date: Tue, 8 Jul 2025 00:40:51 -0500 Subject: [PATCH 2/3] better fix for getTexture --- src/render/BlockModel.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/render/BlockModel.ts b/src/render/BlockModel.ts index 5433056b..42833a74 100644 --- a/src/render/BlockModel.ts +++ b/src/render/BlockModel.ts @@ -188,15 +188,13 @@ export class BlockModel { } private getTexture(textureRef: string) { - let currentRef = textureRef; - for (let i = 0; i < 7; i++) { - const key = currentRef.startsWith('#') ? currentRef.slice(1) : currentRef; - const nextRef = this.textures?.[key]; - if (nextRef === undefined) { - break; - } - currentRef = nextRef; + let key = textureRef.startsWith('#') ? textureRef.slice(1) : textureRef; + let currentRef = this.textures?.[key] ?? '' + + while (currentRef.startsWith('#')) { + currentRef = this.textures?.[currentRef.slice(1)] ?? '' } + return Identifier.parse(currentRef) } From 6232abe375fd439f87f885928591e5018723adee Mon Sep 17 00:00:00 2001 From: Misode Date: Sat, 3 Jan 2026 00:33:22 +0100 Subject: [PATCH 3/3] Refactor code to simplify code diff --- src/render/BlockModel.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/render/BlockModel.ts b/src/render/BlockModel.ts index 42833a74..3b19eb75 100644 --- a/src/render/BlockModel.ts +++ b/src/render/BlockModel.ts @@ -188,14 +188,12 @@ export class BlockModel { } private getTexture(textureRef: string) { - let key = textureRef.startsWith('#') ? textureRef.slice(1) : textureRef; - let currentRef = this.textures?.[key] ?? '' - - while (currentRef.startsWith('#')) { - currentRef = this.textures?.[currentRef.slice(1)] ?? '' + textureRef = textureRef.startsWith('#') ? textureRef.slice(1) : textureRef + textureRef = this.textures?.[textureRef] ?? '' + while (textureRef.startsWith('#')) { + textureRef = this.textures?.[textureRef.slice(1)] ?? '' } - - return Identifier.parse(currentRef) + return Identifier.parse(textureRef) } public flatten(accessor: BlockModelProvider) {