1
0

fix: 优化方块属性设置逻辑

This commit is contained in:
2025-04-29 23:41:17 +08:00
parent 3c807c4b5f
commit 3c646fb000
2 changed files with 19 additions and 10 deletions

View File

@@ -165,6 +165,9 @@ declare global {
/** 方块注册事件 */
type _RegistryBlock = $Block;
/** 配置选项 */
type _SetBlockPropsOpts = SetBlockPropsOpts;
const global: {
/**

View File

@@ -1194,8 +1194,8 @@ function regBlockCommon(event) {
let isType1 = ['', 'cardinal'].indexOf(blockType > -1);
let isType2 = ['fence', 'slab', 'stairs', 'wall'].indexOf(blockType) > -1;
// 设置基础属性(通用)
setBlockProps(block, {
/** @type {_SetBlockPropsOpts} */
let commonProps = {
displayName: blockLabel,
modelPath: modelPath1 ? {
blockName: blockName,
@@ -1205,31 +1205,37 @@ function regBlockCommon(event) {
textureAll: textureAllPath1,
textureSide: textureSidePath1,
textureUpDown: textureUpDownPath1,
});
};
// 设置基础属性(特殊)
/** @type {_SetBlockPropsOpts} */
let specialProps = {};
// 处理基础属性
if (isType1) {
if (blockBox) {
setBlockProps(block, {
specialProps = {
boxConfig: blockBox,
boxType: 'custom',
isSolid: false,
renderType: 'cutout',
});
};
} else {
setBlockProps(block, {
specialProps = {
boxConfig: null,
boxType: 'full',
isSolid: true,
renderType: 'solid',
});
};
}
} else if (isType2) {
setBlockProps(block, {
specialProps = {
renderType: 'cutout_mipped',
});
};
}
// 设置基础属性
setBlockProps(block, Object.assign(commonProps, specialProps));
// 生成方块状态
if (blockState) {
JSON_ASSETS.push({