feat: 添加杆子方块
This commit is contained in:
@@ -16,6 +16,9 @@ const P_BLOCK = `${MOD_ID}:block`;
|
||||
/** 方块模型文件基础长路径 */
|
||||
const P_BLOCK_MODEL = `${MOD_ID}:models/block`;
|
||||
|
||||
/** 方块状态文件基础长路径 */
|
||||
const P_BLOCK_STATE = `${MOD_ID}:blockstates`;
|
||||
|
||||
/** 方块透明纹理文件路径 */
|
||||
const P_BLOCK_TRANSPARENT = `${P_BLOCK}/common/transparent`;
|
||||
|
||||
@@ -36,6 +39,37 @@ const TAB_ROADS_ITEMS = [];
|
||||
|
||||
console.info(`${LOG_PREFIX} 处理 ${MOD_ID} 相关内容`);
|
||||
|
||||
/**
|
||||
* @description 获取栅栏方块状态 JSON
|
||||
* @param {string} postPath 栅栏 post 模型短路径
|
||||
* @param {string} sidePath 栅栏 side 模型短路径
|
||||
*/
|
||||
function getFenceBlockstateJson(postPath, sidePath) {
|
||||
return {
|
||||
multipart: [
|
||||
{
|
||||
apply: { model: postPath }
|
||||
},
|
||||
{
|
||||
apply: { model: sidePath, uvlock: true },
|
||||
when: { north: 'true' }
|
||||
},
|
||||
{
|
||||
apply: { model: sidePath, uvlock: true, y: 90 },
|
||||
when: { east: 'true' }
|
||||
},
|
||||
{
|
||||
apply: { model: sidePath, uvlock: true, y: 180 },
|
||||
when: { south: 'true' }
|
||||
},
|
||||
{
|
||||
apply: { model: sidePath, uvlock: true, y: 270 },
|
||||
when: { west: 'true' }
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 砖块
|
||||
* @param {_RegistryBlock} event
|
||||
@@ -1459,33 +1493,57 @@ function regBlockOtherShaped(event) {
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 其他 - 特殊 - 开始`);
|
||||
|
||||
const blocks = [
|
||||
const blockList = [
|
||||
{
|
||||
name: 'gravel_stairs',
|
||||
label: '沙砾楼梯',
|
||||
blockstate: null,
|
||||
texture: 'minecraft:block/gravel',
|
||||
type: 'stairs',
|
||||
},
|
||||
{
|
||||
name: 'gravel_slab',
|
||||
label: '沙砾半砖',
|
||||
blockstate: null,
|
||||
texture: 'minecraft:block/gravel',
|
||||
type: 'slab',
|
||||
},
|
||||
{
|
||||
name: 'oak_leaves_wall',
|
||||
label: '橡木树叶墙',
|
||||
blockstate: null,
|
||||
texture: `${P_BLOCK}/common/oak_leaves`,
|
||||
type: 'wall',
|
||||
},
|
||||
{
|
||||
name: 'pole_a_horizon',
|
||||
label: '杆子(水平)',
|
||||
blockstate: getFenceBlockstateJson(
|
||||
`${P_BLOCK}/pole/pole_a_horizon_post`,
|
||||
`${P_BLOCK}/pole/pole_a_horizon_side`,
|
||||
),
|
||||
texture: 'block/light_gray_concrete',
|
||||
type: 'fence',
|
||||
},
|
||||
{
|
||||
name: 'pole_a_vertical',
|
||||
label: '杆子(垂直)',
|
||||
blockstate: getFenceBlockstateJson(
|
||||
`${P_BLOCK}/pole/pole_a_vertical_post`,
|
||||
`${P_BLOCK}/pole/pole_a_vertical_side`,
|
||||
),
|
||||
texture: 'block/light_gray_concrete',
|
||||
type: 'fence',
|
||||
},
|
||||
];
|
||||
|
||||
blocks.forEach((config) => {
|
||||
blockList.forEach((config) => {
|
||||
|
||||
const id = `${MOD_ID}:${config.name}`;
|
||||
const block = event.create(id, config.type);
|
||||
const blockName = config.name;
|
||||
const blockId = `${MOD_ID}:${blockName}`;
|
||||
const block = event.create(blockId, config.type);
|
||||
|
||||
TAB_BLOCKS_ITEMS.push(id);
|
||||
TAB_BLOCKS_ITEMS.push(blockId);
|
||||
|
||||
// 设置基础属性
|
||||
setBlockProps(block, {
|
||||
@@ -1494,6 +1552,14 @@ function regBlockOtherShaped(event) {
|
||||
textureAll: config.texture,
|
||||
});
|
||||
|
||||
// 生成方块状态
|
||||
if (config.blockstate) {
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_STATE}/${blockName}`,
|
||||
data: config.blockstate,
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 其他 - 特殊 - 完成`);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"credit": "Created by Frost-ZX using Blockbench.",
|
||||
"textures": {
|
||||
"particle": "block/light_gray_concrete",
|
||||
"texture": "block/light_gray_concrete"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6, 6, 6],
|
||||
"to": [10, 10, 10],
|
||||
"faces": {
|
||||
"north": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"east": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"south": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"west": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"up": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"down": {"uv": [6, 6, 10, 10], "texture": "#texture"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"credit": "Created by Frost-ZX using Blockbench.",
|
||||
"textures": {
|
||||
"particle": "block/light_gray_concrete",
|
||||
"texture": "block/light_gray_concrete"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6, 6, 0],
|
||||
"to": [10, 10, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"east": {"uv": [9, 6, 16, 10], "texture": "#texture"},
|
||||
"south": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"west": {"uv": [0, 6, 7, 10], "texture": "#texture"},
|
||||
"up": {"uv": [6, 0, 10, 7], "texture": "#texture"},
|
||||
"down": {"uv": [6, 9, 10, 16], "texture": "#texture"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"credit": "Created by Frost-ZX using Blockbench.",
|
||||
"textures": {
|
||||
"particle": "block/light_gray_concrete",
|
||||
"texture": "block/light_gray_concrete"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6, 0, 6],
|
||||
"to": [10, 16, 10],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [6, 0, 10, 16], "texture": "#texture"},
|
||||
"east": {"uv": [6, 0, 10, 16], "texture": "#texture"},
|
||||
"south": {"uv": [6, 0, 10, 16], "texture": "#texture"},
|
||||
"west": {"uv": [6, 0, 10, 16], "texture": "#texture"},
|
||||
"up": {"uv": [6, 6, 10, 10], "texture": "#texture"},
|
||||
"down": {"uv": [6, 6, 10, 10], "texture": "#texture"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"credit": "Created by Frost-ZX using Blockbench.",
|
||||
"textures": {
|
||||
"particle": "block/light_gray_concrete",
|
||||
"texture": "block/light_gray_concrete"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [7, 3, 0],
|
||||
"to": [9, 13, 1],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"north": {"uv": [7, 3, 9, 13], "texture": "#texture"},
|
||||
"east": {"uv": [15, 3, 16, 13], "texture": "#texture"},
|
||||
"south": {"uv": [7, 3, 9, 13], "texture": "#texture"},
|
||||
"west": {"uv": [0, 3, 1, 13], "texture": "#texture"},
|
||||
"up": {"uv": [7, 0, 9, 1], "texture": "#texture"},
|
||||
"down": {"uv": [7, 15, 9, 16], "texture": "#texture"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [7.5, 11, 1],
|
||||
"to": [8.5, 13, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"east": {"uv": [9, 3, 15, 5], "texture": "#texture"},
|
||||
"west": {"uv": [1, 3, 7, 5], "texture": "#texture"},
|
||||
"up": {"uv": [7.5, 1, 8.5, 7], "texture": "#texture"},
|
||||
"down": {"uv": [7.5, 9, 8.5, 15], "texture": "#texture"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [7.5, 3, 1],
|
||||
"to": [8.5, 5, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
|
||||
"faces": {
|
||||
"east": {"uv": [9, 11, 15, 13], "texture": "#texture"},
|
||||
"west": {"uv": [1, 11, 7, 13], "texture": "#texture"},
|
||||
"up": {"uv": [7.5, 1, 8.5, 7], "texture": "#texture"},
|
||||
"down": {"uv": [7.5, 9, 8.5, 15], "texture": "#texture"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user