1
0

feat: 添加枫树、棕榈树、柳树的树叶和树木方块

This commit is contained in:
2025-04-29 23:32:56 +08:00
parent b9fc6e7f0a
commit 3c807c4b5f
13 changed files with 117 additions and 28 deletions
+6
View File
@@ -152,6 +152,12 @@ type SetBlockPropsOpts = {
/** 纹理文件路径,每一面都相同时指定 */ /** 纹理文件路径,每一面都相同时指定 */
textureAll?: string; textureAll?: string;
/** 纹理文件路径,侧面都相同时指定 */
textureSide?: string;
/** 纹理文件路径,上下面都相同时指定 */
textureUpDown?: string;
}; };
declare global { declare global {
+18 -6
View File
@@ -131,6 +131,8 @@ global.setBlockProps = function (block, opts) {
let resistance = defaults(opts.resistance, 16); let resistance = defaults(opts.resistance, 16);
let soundType = defaults(opts.soundType, 'stone'); let soundType = defaults(opts.soundType, 'stone');
let textureAll = defaults(opts.textureAll, ''); let textureAll = defaults(opts.textureAll, '');
let textureSide = defaults(opts.textureSide, '');
let textureUpDown = defaults(opts.textureUpDown, '');
if (boxType === 'custom') { if (boxType === 'custom') {
if (boxConfig) { if (boxConfig) {
@@ -171,12 +173,22 @@ global.setBlockProps = function (block, opts) {
if (textureAll) { if (textureAll) {
block.texture(textureAll); block.texture(textureAll);
// block.texture(Direction.UP, textureAll); }
// block.texture(Direction.DOWN, textureAll);
// block.texture(Direction.NORTH, textureAll); if (textureSide) {
// block.texture(Direction.SOUTH, textureAll); block.texture([
// block.texture(Direction.WEST, textureAll); Direction.NORTH,
// block.texture(Direction.EAST, textureAll); Direction.SOUTH,
Direction.WEST,
Direction.EAST,
], textureSide);
}
if (textureUpDown) {
block.texture([
Direction.UP,
Direction.DOWN,
], textureUpDown);
} }
block.hardness(hardness); block.hardness(hardness);
+93 -22
View File
@@ -356,7 +356,7 @@ function regBlockCommon(event) {
blockstate: null, blockstate: null,
box: null, box: null,
model: '', model: '',
texture: `common/oak_leaves`, texture: `common/tree_oak_leaves`,
type: 'wall', type: 'wall',
}, },
{ {
@@ -1084,6 +1084,67 @@ function regBlockCommon(event) {
texture: '', texture: '',
type: 'cardinal', type: 'cardinal',
}, },
// 树木
{
name: 'tree_maple_leaves',
label: '枫树叶',
blockstate: null,
box: [0, 0, 0, 16, 16, 16, true],
model: '',
texture: 'common/tree_maple_leaves',
type: '',
},
{
name: 'tree_maple_wood',
label: '枫树木',
blockstate: null,
box: null,
model: '',
texture: '',
textureSide: 'common/tree_maple_wood_side',
textureUpDown: 'common/tree_maple_wood_ud',
type: '',
},
{
name: 'tree_palm_leaves',
label: '棕榈树叶',
blockstate: null,
box: [0, 0, 0, 16, 16, 16, true],
model: '',
texture: 'common/tree_palm_leaves',
type: '',
},
{
name: 'tree_palm_wood',
label: '棕榈树木',
blockstate: null,
box: null,
model: '',
texture: '',
textureSide: 'common/tree_palm_wood_side',
textureUpDown: 'common/tree_palm_wood_ud',
type: '',
},
{
name: 'tree_willow_leaves',
label: '柳树叶',
blockstate: null,
box: [0, 0, 0, 16, 16, 16, true],
model: '',
texture: 'common/tree_willow_leaves',
type: '',
},
{
name: 'tree_willow_wood',
label: '柳树木',
blockstate: null,
box: null,
model: '',
texture: '',
textureSide: 'common/tree_willow_wood_side',
textureUpDown: 'common/tree_willow_wood_ud',
type: '',
},
]; ];
blockList.forEach((config) => { blockList.forEach((config) => {
@@ -1097,14 +1158,27 @@ function regBlockCommon(event) {
let block = null; let block = null;
// 获取模型文件路径
let modelPath0 = config.model; let modelPath0 = config.model;
let modelPath1 = modelPath0 ? `${P_BLOCK}/${modelPath0}` : ''; let modelPath1 = modelPath0 ? `${P_BLOCK}/${modelPath0}` : '';
let texturePath0 = config.texture; // 获取纹理文件路径
let texturePath1 = texturePath0 || ''; let textureAllPath0 = config.texture;
let textureAllPath1 = textureAllPath0 || '';
let textureSidePath0 = config.textureSide;
let textureSidePath1 = textureSidePath0 || '';
let textureUpDownPath0 = config.textureUpDown;
let textureUpDownPath1 = textureUpDownPath0 || '';
if (texturePath0 && !texturePath0.includes(':')) { // 处理纹理文件路径
texturePath1 = `${P_BLOCK}/${texturePath0}`; if (textureAllPath0 && !textureAllPath0.includes(':')) {
textureAllPath1 = `${P_BLOCK}/${textureAllPath0}`;
}
if (textureSidePath0 && !textureSidePath0.includes(':')) {
textureSidePath1 = `${P_BLOCK}/${textureSidePath0}`;
}
if (textureUpDownPath0 && !textureUpDownPath0.includes(':')) {
textureUpDownPath1 = `${P_BLOCK}/${textureUpDownPath0}`;
} }
// 创建方块 // 创建方块
@@ -1120,42 +1194,39 @@ function regBlockCommon(event) {
let isType1 = ['', 'cardinal'].indexOf(blockType > -1); let isType1 = ['', 'cardinal'].indexOf(blockType > -1);
let isType2 = ['fence', 'slab', 'stairs', 'wall'].indexOf(blockType) > -1; let isType2 = ['fence', 'slab', 'stairs', 'wall'].indexOf(blockType) > -1;
// 设置基础属性 // 设置基础属性(通用)
setBlockProps(block, {
displayName: blockLabel,
modelPath: modelPath1 ? {
blockName: blockName,
blockNamespace: MOD_ID,
filePath: modelPath1,
} : null,
textureAll: textureAllPath1,
textureSide: textureSidePath1,
textureUpDown: textureUpDownPath1,
});
// 设置基础属性(特殊)
if (isType1) { if (isType1) {
if (blockBox) { if (blockBox) {
setBlockProps(block, { setBlockProps(block, {
boxConfig: blockBox, boxConfig: blockBox,
boxType: 'custom', boxType: 'custom',
displayName: blockLabel,
isSolid: false, isSolid: false,
modelPath: modelPath1 ? {
blockName: blockName,
blockNamespace: MOD_ID,
filePath: modelPath1,
} : null,
renderType: 'cutout', renderType: 'cutout',
textureAll: texturePath1,
}); });
} else { } else {
setBlockProps(block, { setBlockProps(block, {
boxConfig: null, boxConfig: null,
boxType: 'full', boxType: 'full',
displayName: blockLabel,
isSolid: true, isSolid: true,
modelPath: modelPath1 ? {
blockName: blockName,
blockNamespace: MOD_ID,
filePath: modelPath1,
} : null,
renderType: 'solid', renderType: 'solid',
textureAll: texturePath1,
}); });
} }
} else if (isType2) { } else if (isType2) {
setBlockProps(block, { setBlockProps(block, {
displayName: blockLabel,
renderType: 'cutout_mipped', renderType: 'cutout_mipped',
textureAll: texturePath1,
}); });
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B