|
1 | 1 | import { mat4 } from 'gl-matrix'
|
2 |
| -import { Identifier } from '../core/index.js' |
3 | 2 | import { ItemStack } from '../core/ItemStack.js'
|
4 |
| -import type { Color } from '../index.js' |
| 3 | +import { Identifier } from '../core/index.js' |
| 4 | +import { Cull, SpecialRenderer, SpecialRenderers, type Color } from '../index.js' |
5 | 5 | import type { BlockModelProvider } from './BlockModel.js'
|
6 | 6 | import { getItemColor } from './ItemColors.js'
|
7 | 7 | import type { Mesh } from './Mesh.js'
|
@@ -48,7 +48,16 @@ export class ItemRenderer extends Renderer {
|
48 | 48 | if (!tint && this.item.id.namespace === Identifier.DEFAULT_NAMESPACE) {
|
49 | 49 | tint = getItemColor(this.item)
|
50 | 50 | }
|
51 |
| - const mesh = model.getDisplayMesh('gui', this.resources, tint) |
| 51 | + var additionalMesh = undefined |
| 52 | + if (SpecialRenderers.has(this.item.id.toString())){ |
| 53 | + additionalMesh = SpecialRenderer[this.item.id.toString()]({}, this.resources, Cull.none()) |
| 54 | + // undo the scaling done by the special renderer |
| 55 | + const t = mat4.create() |
| 56 | + mat4.identity(t) |
| 57 | + mat4.scale(t, t, [16, 16, 16]) |
| 58 | + additionalMesh.transform(t) |
| 59 | + } |
| 60 | + const mesh = model.getDisplayMesh('gui', this.resources, tint, additionalMesh) |
52 | 61 | mesh.quads.forEach(q => {
|
53 | 62 | const normal = q.normal()
|
54 | 63 | q.forEach(v => v.normal = normal)
|
|
0 commit comments