1
0

refactor: 优化路方块纹理定义,支持空白侧边纹理

This commit is contained in:
2022-09-04 19:17:04 +08:00
parent 5486e63340
commit 8f7193edf6
+26 -16
View File
@@ -109,9 +109,10 @@ onEvent('block.registry', (event) => {
name: 'road_blank', name: 'road_blank',
label: '路 - 空白', label: '路 - 空白',
texturePath: 'transparent', texturePath: 'transparent',
hasNormal: true, hasNormal: true, // 普通 / 直线
hasSlant: false, hasSlant: false, // 斜线
isBlank: true, hasSide: false, // 侧边纹理
isBlank: true, // 空白
}, },
{ {
name: 'road_white', name: 'road_white',
@@ -119,6 +120,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/content_white', texturePath: 'road/content_white',
hasNormal: true, hasNormal: true,
hasSlant: false, hasSlant: false,
hasSide: false,
isBlank: true, isBlank: true,
}, },
{ {
@@ -127,6 +129,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/content_yellow', texturePath: 'road/content_yellow',
hasNormal: true, hasNormal: true,
hasSlant: false, hasSlant: false,
hasSide: false,
isBlank: true, isBlank: true,
}, },
{ {
@@ -135,6 +138,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/line/single_white', texturePath: 'road/line/single_white',
hasNormal: true, hasNormal: true,
hasSlant: true, hasSlant: true,
hasSide: true,
isBlank: false, isBlank: false,
}, },
{ {
@@ -143,6 +147,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/line/single_yellow', texturePath: 'road/line/single_yellow',
hasNormal: true, hasNormal: true,
hasSlant: true, hasSlant: true,
hasSide: true,
isBlank: false, isBlank: false,
}, },
{ {
@@ -151,6 +156,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/line/double_white', texturePath: 'road/line/double_white',
hasNormal: true, hasNormal: true,
hasSlant: true, hasSlant: true,
hasSide: true,
isBlank: false, isBlank: false,
}, },
{ {
@@ -159,6 +165,7 @@ onEvent('block.registry', (event) => {
texturePath: 'road/line/double_yellow', texturePath: 'road/line/double_yellow',
hasNormal: true, hasNormal: true,
hasSlant: true, hasSlant: true,
hasSide: true,
isBlank: false, isBlank: false,
}, },
]; ];
@@ -172,7 +179,10 @@ onEvent('block.registry', (event) => {
const label = (config.label || 'Unknown'); const label = (config.label || 'Unknown');
/** 纹理文件相对路径 */ /** 纹理文件相对路径 */
const texturePath = config.texturePath; const tPath = config.texturePath;
/** 是否存在侧边纹理 */
const tSide = config.hasSide;
// 完整,直线 // 完整,直线
if (config.hasNormal) { if (config.hasNormal) {
@@ -186,12 +196,12 @@ onEvent('block.registry', (event) => {
renderType: 'cutout', renderType: 'cutout',
}); });
if (texturePath) { if (tPath) {
block.modelJson = { block.modelJson = {
parent: `${PATH_MODEL}road/base_full`, parent: `${PATH_MODEL}road/base_full`,
textures: { textures: {
content: `${PATH_TEXTURE}${texturePath}`, content: `${PATH_TEXTURE}${tPath}`,
side: `${PATH_TEXTURE}${texturePath}` side: tSide ? `${PATH_TEXTURE}${tPath}` : undefined
} }
}; };
} }
@@ -210,12 +220,12 @@ onEvent('block.registry', (event) => {
renderType: 'cutout', renderType: 'cutout',
}); });
if (texturePath) { if (tPath) {
block.modelJson = { block.modelJson = {
parent: `${PATH_MODEL}road/base_full`, parent: `${PATH_MODEL}road/base_full`,
textures: { textures: {
content: `${PATH_TEXTURE}${texturePath}_slant`, content: `${PATH_TEXTURE}${tPath}_slant`,
side: `${PATH_TEXTURE}${texturePath}` side: tSide ? `${PATH_TEXTURE}${tPath}` : undefined
} }
}; };
} }
@@ -234,12 +244,12 @@ onEvent('block.registry', (event) => {
renderType: 'cutout', renderType: 'cutout',
}); });
if (texturePath) { if (tPath) {
block.modelJson = { block.modelJson = {
parent: `${PATH_MODEL}road/base_half`, parent: `${PATH_MODEL}road/base_half`,
textures: { textures: {
content: `${PATH_TEXTURE}${texturePath}`, content: `${PATH_TEXTURE}${tPath}`,
side: `${PATH_TEXTURE}${texturePath}` side: tSide ? `${PATH_TEXTURE}${tPath}` : undefined
} }
}; };
} }
@@ -258,12 +268,12 @@ onEvent('block.registry', (event) => {
renderType: 'cutout', renderType: 'cutout',
}); });
if (texturePath) { if (tPath) {
block.modelJson = { block.modelJson = {
parent: `${PATH_MODEL}road/base_half`, parent: `${PATH_MODEL}road/base_half`,
textures: { textures: {
content: `${PATH_TEXTURE}${texturePath}_slant`, content: `${PATH_TEXTURE}${tPath}_slant`,
side: `${PATH_TEXTURE}${texturePath}` side: tSide ? `${PATH_TEXTURE}${tPath}` : undefined
} }
}; };
} }