From a1af8b59d71ae3170bf793dd86b2994235668e59 Mon Sep 17 00:00:00 2001 From: Frost-ZX Date: Mon, 28 Apr 2025 21:29:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9D=86=E5=AD=90?= =?UTF-8?q?=E6=96=B9=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kubejs/startup_scripts/wheat_plus.js | 76 +++++++++++++++++-- .../block/pole/pole_a_horizon_post.json | 21 +++++ .../block/pole/pole_a_horizon_side.json | 22 ++++++ .../block/pole/pole_a_vertical_post.json | 22 ++++++ .../block/pole/pole_a_vertical_side.json | 44 +++++++++++ 5 files changed, 180 insertions(+), 5 deletions(-) create mode 100644 resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_post.json create mode 100644 resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_side.json create mode 100644 resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_post.json create mode 100644 resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_side.json diff --git a/kubejs/startup_scripts/wheat_plus.js b/kubejs/startup_scripts/wheat_plus.js index 1bde45d..75369b3 100644 --- a/kubejs/startup_scripts/wheat_plus.js +++ b/kubejs/startup_scripts/wheat_plus.js @@ -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} 注册方块 - 其他 - 特殊 - 完成`); diff --git a/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_post.json b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_post.json new file mode 100644 index 0000000..96ec8d1 --- /dev/null +++ b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_post.json @@ -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"} + } + } + ] +} \ No newline at end of file diff --git a/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_side.json b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_side.json new file mode 100644 index 0000000..685d094 --- /dev/null +++ b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_horizon_side.json @@ -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"} + } + } + ] +} \ No newline at end of file diff --git a/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_post.json b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_post.json new file mode 100644 index 0000000..ed5368f --- /dev/null +++ b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_post.json @@ -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"} + } + } + ] +} \ No newline at end of file diff --git a/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_side.json b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_side.json new file mode 100644 index 0000000..9628516 --- /dev/null +++ b/resourcepack/assets/wheat_plus/models/block/pole/pole_a_vertical_side.json @@ -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"} + } + } + ] +} \ No newline at end of file