From f9136d583f77b48570eea9559dd691b63389ed4d Mon Sep 17 00:00:00 2001 From: Frost-ZX Date: Sun, 13 Nov 2022 19:26:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=9C=E7=BA=BF=E8=B7=AF=E6=96=B9?= =?UTF-8?q?=E5=9D=97=E6=94=AF=E6=8C=81=E6=97=8B=E8=BD=AC=EF=BC=88=E4=B8=8D?= =?UTF-8?q?=E5=80=9F=E5=8A=A9=E8=BF=9E=E6=8E=A5=E7=BA=B9=E7=90=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kubejs/startup_scripts/wheat_plus.js | 127 +++++++++++------- .../{c_slant.properties => c_slant} | 0 .../{c_slant.properties => c_slant} | 0 .../{c_slant.properties => c_slant} | 0 .../{c_slant.properties => c_slant} | 0 5 files changed, 75 insertions(+), 52 deletions(-) rename resourcepack/assets/minecraft/optifine/ctm/road_line_double_white/{c_slant.properties => c_slant} (100%) rename resourcepack/assets/minecraft/optifine/ctm/road_line_double_yellow/{c_slant.properties => c_slant} (100%) rename resourcepack/assets/minecraft/optifine/ctm/road_line_single_white/{c_slant.properties => c_slant} (100%) rename resourcepack/assets/minecraft/optifine/ctm/road_line_single_yellow/{c_slant.properties => c_slant} (100%) diff --git a/kubejs/startup_scripts/wheat_plus.js b/kubejs/startup_scripts/wheat_plus.js index 7202880..9c914db 100644 --- a/kubejs/startup_scripts/wheat_plus.js +++ b/kubejs/startup_scripts/wheat_plus.js @@ -30,8 +30,7 @@ onEvent('block.registry', (event) => { console.info(`${LOG_PREFIX} 注册方块 - 路 - 开始`); - /** 普通路方块 */ - const roadBlocksNormal = [ + const blockList = [ { name: 'road_blank', label: '路 - 空白', @@ -97,12 +96,12 @@ onEvent('block.registry', (event) => { }, ]; - roadBlocksNormal.forEach((config) => { + blockList.forEach((config) => { - /** 方块 ID,包含模组 ID */ - const id = `${MOD_ID}:${config.name}`; + /** 方块名称 */ + const blockName = config.name; - /** 方块名称文本 */ + /** 方块文本 */ const label = (config.label || 'Unknown'); /** 纹理文件相对路径 */ @@ -111,99 +110,123 @@ onEvent('block.registry', (event) => { /** 是否存在侧边纹理 */ const tSide = config.hasSide; - // 完整,直线 + // 完整,普通 / 直线 if (config.hasNormal) { - const block = event.create(`${id}_full`, 'basic'); + const blockId = `${blockName}_full`; + const fullId = `${MOD_ID}:${blockId}`; + const block = event.create(fullId, 'basic'); const suffix = (config.isBlank ? '' : ',直线'); + const modelPathL = `${P_BLOCK_MODEL}/${blockId}`; + const modelPathS = `${P_BLOCK}/${blockId}`; + const modelJSON = { + parent: `${P_BLOCK}/road/base_full`, + textures: { + content: `${P_BLOCK}/${tPath}`, + side: tSide ? `${P_BLOCK}/${tPath}` : undefined + } + }; + + JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON }); + setBlockProps(block, { boxType: 'full', displayName: `${label},完整${suffix}`, + modelPath: modelPathS, renderType: 'cutout', }); - if (tPath) { - block.modelJson = { - parent: `${P_BLOCK}/road/base_full`, - textures: { - content: `${P_BLOCK}/${tPath}`, - side: tSide ? `${P_BLOCK}/${tPath}` : undefined - } - }; - } - } // 完整,斜线 if (config.hasSlant) { - const block = event.create(`${id}_full_slant`, 'basic'); - const suffix = (config.isBlank ? '' : ',斜线'); + const blockId = `${blockName}_full_slant`; + const fullId = `${MOD_ID}:${blockId}`; + const block = event.create(fullId, 'basic'); + const suffix = ',斜线'; + + const modelPathL = `${P_BLOCK_MODEL}/${blockId}`; + const modelPathS = `${P_BLOCK}/${blockId}`; + const modelJSON = { + parent: `${P_BLOCK}/road/base_full`, + textures: { + content: `${P_BLOCK}/${tPath}_slant`, + side: tSide ? `${P_BLOCK}/${tPath}` : undefined + } + }; + + JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON }); setBlockProps(block, { boxType: 'full', displayName: `${label},完整${suffix}`, + modelPath: modelPathS, renderType: 'cutout', }); - if (tPath) { - block.modelJson = { - parent: `${P_BLOCK}/road/base_full`, - textures: { - content: `${P_BLOCK}/${tPath}_slant`, - side: tSide ? `${P_BLOCK}/${tPath}` : undefined - } - }; - } + setHorizontalFacing(block, 'same', modelPathS); } - // 一半,直线 + // 一半,普通 / 直线 if (config.hasNormal) { - const block = event.create(`${id}_half`, 'basic'); + const blockId = `${blockName}_half`; + const fullId = `${MOD_ID}:${blockId}`; + const block = event.create(fullId, 'basic'); const suffix = (config.isBlank ? '' : ',直线'); + const modelPathL = `${P_BLOCK_MODEL}/${blockId}`; + const modelPathS = `${P_BLOCK}/${blockId}`; + const modelJSON = { + parent: `${P_BLOCK}/road/base_half`, + textures: { + content: `${P_BLOCK}/${tPath}`, + side: tSide ? `${P_BLOCK}/${tPath}` : undefined + } + }; + + JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON }); + setBlockProps(block, { boxType: 'half', displayName: `${label},一半${suffix}`, + modelPath: modelPathS, renderType: 'cutout', }); - if (tPath) { - block.modelJson = { - parent: `${P_BLOCK}/road/base_half`, - textures: { - content: `${P_BLOCK}/${tPath}`, - side: tSide ? `${P_BLOCK}/${tPath}` : undefined - } - }; - } - } // 一半,斜线 if (config.hasSlant) { - const block = event.create(`${id}_half_slant`, 'basic'); - const suffix = (config.isBlank ? '' : ',斜线'); + const blockId = `${blockName}_half_slant`; + const fullId = `${MOD_ID}:${blockId}`; + const block = event.create(fullId, 'basic'); + const suffix = ',斜线'; + + const modelPathL = `${P_BLOCK_MODEL}/${blockId}`; + const modelPathS = `${P_BLOCK}/${blockId}`; + const modelJSON = { + parent: `${P_BLOCK}/road/base_half`, + textures: { + content: `${P_BLOCK}/${tPath}_slant`, + side: tSide ? `${P_BLOCK}/${tPath}` : undefined + } + }; + + JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON }); setBlockProps(block, { boxType: 'half', displayName: `${label},一半${suffix}`, + modelPath: modelPathS, renderType: 'cutout', }); - if (tPath) { - block.modelJson = { - parent: `${P_BLOCK}/road/base_half`, - textures: { - content: `${P_BLOCK}/${tPath}_slant`, - side: tSide ? `${P_BLOCK}/${tPath}` : undefined - } - }; - } + setHorizontalFacing(block, 'same', modelPathS); } diff --git a/resourcepack/assets/minecraft/optifine/ctm/road_line_double_white/c_slant.properties b/resourcepack/assets/minecraft/optifine/ctm/road_line_double_white/c_slant similarity index 100% rename from resourcepack/assets/minecraft/optifine/ctm/road_line_double_white/c_slant.properties rename to resourcepack/assets/minecraft/optifine/ctm/road_line_double_white/c_slant diff --git a/resourcepack/assets/minecraft/optifine/ctm/road_line_double_yellow/c_slant.properties b/resourcepack/assets/minecraft/optifine/ctm/road_line_double_yellow/c_slant similarity index 100% rename from resourcepack/assets/minecraft/optifine/ctm/road_line_double_yellow/c_slant.properties rename to resourcepack/assets/minecraft/optifine/ctm/road_line_double_yellow/c_slant diff --git a/resourcepack/assets/minecraft/optifine/ctm/road_line_single_white/c_slant.properties b/resourcepack/assets/minecraft/optifine/ctm/road_line_single_white/c_slant similarity index 100% rename from resourcepack/assets/minecraft/optifine/ctm/road_line_single_white/c_slant.properties rename to resourcepack/assets/minecraft/optifine/ctm/road_line_single_white/c_slant diff --git a/resourcepack/assets/minecraft/optifine/ctm/road_line_single_yellow/c_slant.properties b/resourcepack/assets/minecraft/optifine/ctm/road_line_single_yellow/c_slant similarity index 100% rename from resourcepack/assets/minecraft/optifine/ctm/road_line_single_yellow/c_slant.properties rename to resourcepack/assets/minecraft/optifine/ctm/road_line_single_yellow/c_slant