From bbb5ebc4d8c038a482fabced100e2e48a720c491 Mon Sep 17 00:00:00 2001 From: Frost-ZX <30585462+Frost-ZX@users.noreply.github.com> Date: Mon, 12 Sep 2022 20:51:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=96=B9?= =?UTF-8?q?=E5=9D=97=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kubejs/startup_scripts/wheat_plus.js | 53 +++++++++++++++------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/kubejs/startup_scripts/wheat_plus.js b/kubejs/startup_scripts/wheat_plus.js index 68b5d26..0d8047f 100644 --- a/kubejs/startup_scripts/wheat_plus.js +++ b/kubejs/startup_scripts/wheat_plus.js @@ -14,7 +14,7 @@ const LOG_PREFIX = global.LOG_PREFIX; /** * @desc 方块碰撞箱类型 * @typedef B.BoxType - * @type {'full'|'half'} + * @type {'custom'|'full'|'half'} */ /** @@ -50,17 +50,20 @@ const P_ITEM_MODEL = `${MOD_ID}:models/item`; * @description 设置方块基础属性 * @param {B.Builder} block * @param {object} options - * @param {B.BoxType} options.boxType 碰撞箱类型 - * @param {boolean} options.collision 开启碰撞箱 - * @param {string} options.displayName - * @param {number} options.hardness - * @param {boolean} options.isFull 是否完整方块 - * @param {boolean} options.isOpaque 是否不透明 - * @param {number} options.lightLevel 范围 0 ~ 1 - * @param {B.Material} options.material + * @param {number[]} options.boxConfig 碰撞箱配置(自定义) + * @param {B.BoxType} options.boxType 碰撞箱类型(内置) + * @param {boolean} options.collision 开启碰撞箱,默认:true + * @param {string} options.displayName 方块显示名称 + * @param {number} options.hardness 默认:8 + * @param {boolean} options.isSolid 是否为完整方块,默认:true + * @param {number} options.lightLevel 范围:0 ~ 1 + * @param {B.Material} options.material 默认:stone * @param {string} options.modelPath 模型文件路径 - * @param {B.RenderType} options.renderType - * @param {number} options.resistance + * @param {B.RenderType} options.renderType 默认:solid + * @param {number} options.resistance 默认:16 + * @param {boolean} options.isFull fullBlock(未使用) + * @param {boolean} options.isOpaque opaque(未使用) + * @param {boolean} options.transparent transparent(未使用) */ const setBlockProps = function (block, options) { @@ -73,23 +76,21 @@ const setBlockProps = function (block, options) { options = {}; } + const boxConfig = defaults(options.boxConfig, null); const boxType = defaults(options.boxType, ''); const collision = defaults(options.collision, true); const displayName = defaults(options.displayName, ''); const hardness = defaults(options.hardness, 8); - const isFull = defaults(options.isFull, true); - const isOpaque = defaults(options.isOpaque, true); + const isSolid = defaults(options.isSolid, true); const lightLevel = defaults(options.lightLevel, 0); const material = defaults(options.material, 'stone'); const modelPath = defaults(options.modelPath, ''); const renderType = defaults(options.renderType, 'solid'); const resistance = defaults(options.resistance, 16); - if (displayName) { - block.displayName(displayName); - } - - if (boxType === 'full') { + if (boxConfig) { + block.box.apply(block, boxConfig); + } else if (boxType === 'full') { block.box(0, 0, 0, 16, 16, 16, true); } else if (boxType === 'half') { block.box(0, 0, 0, 16, 8, 16, true); @@ -99,14 +100,20 @@ const setBlockProps = function (block, options) { block.noCollision(); } + if (displayName) { + block.displayName(displayName); + } + + if (!isSolid) { + block.notSolid(); + } + if (modelPath) { block.model(modelPath); } - block.fullBlock(isFull); block.hardness(hardness); block.lightLevel(lightLevel); - block.opaque(isOpaque); block.material(material); block.renderType(renderType); block.resistance(resistance); @@ -324,10 +331,7 @@ onEvent('block.registry', (event) => { displayName: `${color.LABEL_CN}强化混凝土`, }); - block.modelJson = { - parent: 'minecraft:block/cube_all', - textures: { all: texture }, - }; + block.textureAll(texture); }); @@ -378,6 +382,7 @@ onEvent('block.registry', (event) => { setBlockProps(block, { boxType: 'full', displayName: `现代${color.LABEL_CN}灯`, + isSolid: false, lightLevel: 1, material: 'glass', renderType: 'translucent',