feat: 添加简约灯方块
This commit is contained in:
@@ -1,3 +1,21 @@
|
|||||||
// priority: 100
|
// priority: 100
|
||||||
|
|
||||||
console.info(`${global.LOG_PREFIX} 加载客户端内容`);
|
const JSON_ASSETS = global.JSON_ASSETS;
|
||||||
|
const LOG_PREFIX = global.LOG_PREFIX;
|
||||||
|
|
||||||
|
console.info(`${LOG_PREFIX} 加载客户端内容`);
|
||||||
|
|
||||||
|
// 生成客户端资源
|
||||||
|
// event.add(new ResourceLocation(`<命名空间>:<资源相对路径>`), `JSON`);
|
||||||
|
// event.add(new ResourceLocation(`minecraft:models/block/stone`), {});
|
||||||
|
onEvent('client.generate_assets', (event) => {
|
||||||
|
|
||||||
|
console.info(`${LOG_PREFIX} 生成客户端资源 - 开始`);
|
||||||
|
|
||||||
|
JSON_ASSETS.forEach((item) => {
|
||||||
|
event.add(new ResourceLocation(item.PATH), item.DATA);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.info(`${LOG_PREFIX} 生成客户端资源 - 完成`);
|
||||||
|
|
||||||
|
});
|
||||||
|
|||||||
Vendored
+6
@@ -24,6 +24,12 @@ declare const global: {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 需要在 `client.generate_assets` 生成的 JSON 文件 */
|
||||||
|
JSON_ASSETS: Array<{
|
||||||
|
PATH: string;
|
||||||
|
DATA: Internal.JsonElement;
|
||||||
|
}>;
|
||||||
|
|
||||||
/** 日志前缀 */
|
/** 日志前缀 */
|
||||||
LOG_PREFIX: string;
|
LOG_PREFIX: string;
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ global.COLORS = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.JSON_ASSETS = [];
|
||||||
global.LOG_PREFIX = '[KubeJS]';
|
global.LOG_PREFIX = '[KubeJS]';
|
||||||
|
|
||||||
console.info(`${global.LOG_PREFIX} 启动`);
|
console.info(`${global.LOG_PREFIX} 启动`);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const defaults = global.defaults;
|
const defaults = global.defaults;
|
||||||
const COLORS = global.COLORS;
|
const COLORS = global.COLORS;
|
||||||
|
const JSON_ASSETS = global.JSON_ASSETS;
|
||||||
const LOG_PREFIX = global.LOG_PREFIX;
|
const LOG_PREFIX = global.LOG_PREFIX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +28,7 @@ const LOG_PREFIX = global.LOG_PREFIX;
|
|||||||
* - `cutout`: required for blocks with texture like glass
|
* - `cutout`: required for blocks with texture like glass
|
||||||
* - `translucent`: required for blocks like stained glass
|
* - `translucent`: required for blocks like stained glass
|
||||||
* @typedef B.RenderType
|
* @typedef B.RenderType
|
||||||
* @type {'solid'|'cutout'|'translucent'}
|
* @type {'solid'|'cutout'|'cutout_mipped'|'translucent'}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** 模组 ID */
|
/** 模组 ID */
|
||||||
@@ -44,12 +45,14 @@ const PATH_TEXTURE = `${MOD_ID}:block`;
|
|||||||
* @param {B.Builder} block
|
* @param {B.Builder} block
|
||||||
* @param {object} options
|
* @param {object} options
|
||||||
* @param {B.BoxType} options.boxType 碰撞箱类型
|
* @param {B.BoxType} options.boxType 碰撞箱类型
|
||||||
|
* @param {boolean} options.collision 开启碰撞箱
|
||||||
* @param {string} options.displayName
|
* @param {string} options.displayName
|
||||||
* @param {number} options.hardness
|
* @param {number} options.hardness
|
||||||
* @param {boolean} options.isFull 是否完整方块
|
* @param {boolean} options.isFull 是否完整方块
|
||||||
* @param {boolean} options.isOpaque 是否不透明
|
* @param {boolean} options.isOpaque 是否不透明
|
||||||
* @param {number} options.lightLevel 范围 0 ~ 1
|
* @param {number} options.lightLevel 范围 0 ~ 1
|
||||||
* @param {B.Material} options.material
|
* @param {B.Material} options.material
|
||||||
|
* @param {string} options.modelPath 模型文件路径
|
||||||
* @param {B.RenderType} options.renderType
|
* @param {B.RenderType} options.renderType
|
||||||
* @param {number} options.resistance
|
* @param {number} options.resistance
|
||||||
*/
|
*/
|
||||||
@@ -65,12 +68,14 @@ const setBlockProps = function (block, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const boxType = defaults(options.boxType, '');
|
const boxType = defaults(options.boxType, '');
|
||||||
|
const collision = defaults(options.collision, true);
|
||||||
const displayName = defaults(options.displayName, '');
|
const displayName = defaults(options.displayName, '');
|
||||||
const hardness = defaults(options.hardness, 8);
|
const hardness = defaults(options.hardness, 8);
|
||||||
const isFull = defaults(options.isFull, true);
|
const isFull = defaults(options.isFull, true);
|
||||||
const isOpaque = defaults(options.isOpaque, true);
|
const isOpaque = defaults(options.isOpaque, true);
|
||||||
const lightLevel = defaults(options.lightLevel, 0);
|
const lightLevel = defaults(options.lightLevel, 0);
|
||||||
const material = defaults(options.material, 'stone');
|
const material = defaults(options.material, 'stone');
|
||||||
|
const modelPath = defaults(options.modelPath, '');
|
||||||
const renderType = defaults(options.renderType, 'solid');
|
const renderType = defaults(options.renderType, 'solid');
|
||||||
const resistance = defaults(options.resistance, 16);
|
const resistance = defaults(options.resistance, 16);
|
||||||
|
|
||||||
@@ -84,6 +89,14 @@ const setBlockProps = function (block, options) {
|
|||||||
block.box(0, 0, 0, 16, 8, 16, true);
|
block.box(0, 0, 0, 16, 8, 16, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!collision) {
|
||||||
|
block.noCollision();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelPath) {
|
||||||
|
block.model(modelPath);
|
||||||
|
}
|
||||||
|
|
||||||
block.fullBlock(isFull);
|
block.fullBlock(isFull);
|
||||||
block.hardness(hardness);
|
block.hardness(hardness);
|
||||||
block.lightLevel(lightLevel);
|
block.lightLevel(lightLevel);
|
||||||
@@ -316,10 +329,10 @@ onEvent('block.registry', (event) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 注册方块 - 灯
|
// 注册方块 - 现代灯
|
||||||
onEvent('block.registry', (event) => {
|
onEvent('block.registry', (event) => {
|
||||||
|
|
||||||
console.info(`${LOG_PREFIX} 注册方块 - 灯 - 开始`);
|
console.info(`${LOG_PREFIX} 注册方块 - 现代灯 - 开始`);
|
||||||
|
|
||||||
const keys = Object.keys(COLORS);
|
const keys = Object.keys(COLORS);
|
||||||
|
|
||||||
@@ -355,7 +368,75 @@ onEvent('block.registry', (event) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.info(`${LOG_PREFIX} 注册方块 - 灯 - 完成`);
|
console.info(`${LOG_PREFIX} 注册方块 - 现代灯 - 完成`);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// 注册方块 - 简约灯
|
||||||
|
onEvent('block.registry', (event) => {
|
||||||
|
|
||||||
|
console.info(`${LOG_PREFIX} 注册方块 - 简约灯 - 开始`);
|
||||||
|
|
||||||
|
const blocks = [
|
||||||
|
{
|
||||||
|
name: 'lamp_simple_large',
|
||||||
|
label: '简约灯(大)',
|
||||||
|
model: 'lamp/simple_large',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lamp_simple_medium',
|
||||||
|
label: '简约灯(中)',
|
||||||
|
model: 'lamp/simple_medium',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lamp_simple_small',
|
||||||
|
label: '简约灯(小)',
|
||||||
|
model: 'lamp/simple_small',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lamp_simple_stripe',
|
||||||
|
label: '简约灯(条状)',
|
||||||
|
model: 'lamp/simple_stripe',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
blocks.forEach((config) => {
|
||||||
|
|
||||||
|
const blockName = config.name;
|
||||||
|
const blockId = `${MOD_ID}:${blockName}`;
|
||||||
|
const block = event.create(blockId, 'stone_button');
|
||||||
|
|
||||||
|
// 用于替换默认模型
|
||||||
|
const modelJSON = { parent: `${PATH_MODEL}/${config.model}` };
|
||||||
|
|
||||||
|
setBlockProps(block, {
|
||||||
|
displayName: config.label,
|
||||||
|
lightLevel: 0.8,
|
||||||
|
material: 'glass',
|
||||||
|
renderType: 'translucent',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 按钮方块默认状态
|
||||||
|
JSON_ASSETS.push({
|
||||||
|
PATH: `${MOD_ID}:models/block/${blockName}`,
|
||||||
|
DATA: modelJSON,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 按钮方块按下状态
|
||||||
|
JSON_ASSETS.push({
|
||||||
|
PATH: `${MOD_ID}:models/block/${blockName}_pressed`,
|
||||||
|
DATA: modelJSON,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 按钮物品状态
|
||||||
|
JSON_ASSETS.push({
|
||||||
|
PATH: `${MOD_ID}:models/item/${blockName}`,
|
||||||
|
DATA: modelJSON,
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
console.info(`${LOG_PREFIX} 注册方块 - 简约灯 - 完成`);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"credit": "Created by Frost-ZX using Blockbench.",
|
||||||
|
"parent": "block/block",
|
||||||
|
"ambientocclusion": false,
|
||||||
|
"textures": {
|
||||||
|
"particle": "block/gray_concrete",
|
||||||
|
"base": "block/gray_concrete",
|
||||||
|
"core": "wheat_plus:block/lamp_common/white_core",
|
||||||
|
"glow": "wheat_plus:block/lamp_common/white_glow"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "core",
|
||||||
|
"from": [3, 1.5, 3],
|
||||||
|
"to": [13, 3.5, 13],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [3, 13, 13, 15], "texture": "#core"},
|
||||||
|
"east": {"uv": [3, 13, 13, 15], "texture": "#core"},
|
||||||
|
"south": {"uv": [3, 13, 13, 15], "texture": "#core"},
|
||||||
|
"west": {"uv": [3, 13, 13, 15], "texture": "#core"},
|
||||||
|
"up": {"uv": [3, 3, 13, 13], "texture": "#core"},
|
||||||
|
"down": {"uv": [3, 3, 13, 13], "texture": "#core"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "glow",
|
||||||
|
"from": [2, 1.5, 2],
|
||||||
|
"to": [14, 4.5, 14],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [2, 12, 14, 15], "texture": "#glow"},
|
||||||
|
"east": {"uv": [2, 12, 14, 15], "texture": "#glow"},
|
||||||
|
"south": {"uv": [2, 12, 14, 15], "texture": "#glow"},
|
||||||
|
"west": {"uv": [2, 12, 14, 15], "texture": "#glow"},
|
||||||
|
"up": {"uv": [2, 2, 14, 14], "texture": "#glow"},
|
||||||
|
"down": {"uv": [2, 2, 14, 14], "texture": "#glow"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base",
|
||||||
|
"from": [1, 0, 1],
|
||||||
|
"to": [15, 1.5, 15],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [1, 15, 15, 16], "texture": "#base"},
|
||||||
|
"east": {"uv": [1, 15, 15, 16], "texture": "#base"},
|
||||||
|
"south": {"uv": [1, 15, 15, 16], "texture": "#base"},
|
||||||
|
"west": {"uv": [1, 15, 15, 16], "texture": "#base"},
|
||||||
|
"up": {"uv": [1, 1, 15, 15], "texture": "#base"},
|
||||||
|
"down": {"uv": [1, 1, 15, 15], "texture": "#base"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"credit": "Created by Frost-ZX using Blockbench.",
|
||||||
|
"parent": "block/block",
|
||||||
|
"ambientocclusion": false,
|
||||||
|
"textures": {
|
||||||
|
"particle": "block/gray_concrete",
|
||||||
|
"base": "block/gray_concrete",
|
||||||
|
"core": "wheat_plus:block/lamp_common/white_core",
|
||||||
|
"glow": "wheat_plus:block/lamp_common/white_glow"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "core",
|
||||||
|
"from": [4.5, 1, 4.5],
|
||||||
|
"to": [11.5, 3, 11.5],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [4.5, 13, 11.5, 15], "texture": "#core"},
|
||||||
|
"east": {"uv": [4.5, 13, 11.5, 15], "texture": "#core"},
|
||||||
|
"south": {"uv": [4.5, 13, 11.5, 15], "texture": "#core"},
|
||||||
|
"west": {"uv": [4.5, 13, 11.5, 15], "texture": "#core"},
|
||||||
|
"up": {"uv": [4.5, 4.5, 11.5, 11.5], "texture": "#core"},
|
||||||
|
"down": {"uv": [4.5, 4.5, 11.5, 11.5], "texture": "#core"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "glow",
|
||||||
|
"from": [4, 1, 4],
|
||||||
|
"to": [12, 3.5, 12],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [4, 12.5, 12, 15], "texture": "#glow"},
|
||||||
|
"east": {"uv": [4, 12.5, 12, 15], "texture": "#glow"},
|
||||||
|
"south": {"uv": [4, 12.5, 12, 15], "texture": "#glow"},
|
||||||
|
"west": {"uv": [4, 12.5, 12, 15], "texture": "#glow"},
|
||||||
|
"up": {"uv": [4, 4, 12, 12], "texture": "#glow"},
|
||||||
|
"down": {"uv": [4, 4, 12, 12], "texture": "#glow"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base",
|
||||||
|
"from": [3.5, 0, 3.5],
|
||||||
|
"to": [12.5, 1, 12.5],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [3.5, 15, 12.5, 16], "texture": "#base"},
|
||||||
|
"east": {"uv": [3.5, 15, 12.5, 16], "texture": "#base"},
|
||||||
|
"south": {"uv": [3.5, 15, 12.5, 16], "texture": "#base"},
|
||||||
|
"west": {"uv": [3.5, 15, 12.5, 16], "texture": "#base"},
|
||||||
|
"up": {"uv": [3.5, 3.5, 12.5, 12.5], "texture": "#base"},
|
||||||
|
"down": {"uv": [3.5, 3.5, 12.5, 12.5], "texture": "#base"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"credit": "Created by Frost-ZX using Blockbench.",
|
||||||
|
"parent": "block/block",
|
||||||
|
"ambientocclusion": false,
|
||||||
|
"textures": {
|
||||||
|
"particle": "block/gray_concrete",
|
||||||
|
"base": "block/gray_concrete",
|
||||||
|
"core": "wheat_plus:block/lamp_common/white_core",
|
||||||
|
"glow": "wheat_plus:block/lamp_common/white_glow"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "core",
|
||||||
|
"from": [7, 0.5, 7],
|
||||||
|
"to": [9, 1, 9],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [7, 15, 9, 15.5], "texture": "#core"},
|
||||||
|
"east": {"uv": [7, 15, 9, 15.5], "texture": "#core"},
|
||||||
|
"south": {"uv": [7, 15, 9, 15.5], "texture": "#core"},
|
||||||
|
"west": {"uv": [7, 15, 9, 15.5], "texture": "#core"},
|
||||||
|
"up": {"uv": [7, 7, 9, 9], "texture": "#core"},
|
||||||
|
"down": {"uv": [7, 7, 9, 9], "texture": "#core"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "glow",
|
||||||
|
"from": [6.75, 0.25, 6.75],
|
||||||
|
"to": [9.25, 1.25, 9.25],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [6.75, 14.75, 9.25, 15.75], "texture": "#glow"},
|
||||||
|
"east": {"uv": [6.75, 14.75, 9.25, 15.75], "texture": "#glow"},
|
||||||
|
"south": {"uv": [6.75, 14.75, 9.25, 15.75], "texture": "#glow"},
|
||||||
|
"west": {"uv": [6.75, 14.75, 9.25, 15.75], "texture": "#glow"},
|
||||||
|
"up": {"uv": [6.75, 6.75, 9.25, 9.25], "texture": "#glow"},
|
||||||
|
"down": {"uv": [6.75, 6.75, 9.25, 9.25], "texture": "#glow"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base",
|
||||||
|
"from": [6.5, 0, 6.5],
|
||||||
|
"to": [9.5, 0.5, 9.5],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [6.5, 15.5, 9.5, 16], "texture": "#base"},
|
||||||
|
"east": {"uv": [6.5, 15.5, 9.5, 16], "texture": "#base"},
|
||||||
|
"south": {"uv": [6.5, 15.5, 9.5, 16], "texture": "#base"},
|
||||||
|
"west": {"uv": [6.5, 15.5, 9.5, 16], "texture": "#base"},
|
||||||
|
"up": {"uv": [6.5, 6.5, 9.5, 9.5], "texture": "#base"},
|
||||||
|
"down": {"uv": [6.5, 6.5, 9.5, 9.5], "texture": "#base"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"credit": "Created by Frost-ZX using Blockbench.",
|
||||||
|
"parent": "block/block",
|
||||||
|
"ambientocclusion": false,
|
||||||
|
"textures": {
|
||||||
|
"particle": "block/gray_concrete",
|
||||||
|
"base": "block/gray_concrete",
|
||||||
|
"core": "wheat_plus:block/lamp_common/white_core",
|
||||||
|
"glow": "wheat_plus:block/lamp_common/white_glow"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "core",
|
||||||
|
"from": [3, 1, 7],
|
||||||
|
"to": [13, 2, 9],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [3, 14, 13, 15], "texture": "#core"},
|
||||||
|
"east": {"uv": [7, 14, 9, 15], "texture": "#core"},
|
||||||
|
"south": {"uv": [3, 14, 13, 15], "texture": "#core"},
|
||||||
|
"west": {"uv": [7, 14, 9, 15], "texture": "#core"},
|
||||||
|
"up": {"uv": [3, 7, 13, 9], "texture": "#core"},
|
||||||
|
"down": {"uv": [3, 7, 13, 9], "texture": "#core"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "glow",
|
||||||
|
"from": [2.5, 1, 6.5],
|
||||||
|
"to": [13.5, 2.5, 9.5],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [2.5, 13.5, 13.5, 15], "texture": "#glow"},
|
||||||
|
"east": {"uv": [6.5, 13.5, 9.5, 15], "texture": "#glow"},
|
||||||
|
"south": {"uv": [2.5, 13.5, 13.5, 15], "texture": "#glow"},
|
||||||
|
"west": {"uv": [6.5, 13.5, 9.5, 15], "texture": "#glow"},
|
||||||
|
"up": {"uv": [2.5, 6.5, 13.5, 9.5], "texture": "#glow"},
|
||||||
|
"down": {"uv": [2.5, 6.5, 13.5, 9.5], "texture": "#glow"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "base",
|
||||||
|
"from": [2, 0, 6],
|
||||||
|
"to": [14, 1, 10],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [2, 15, 14, 16], "texture": "#base"},
|
||||||
|
"east": {"uv": [6, 15, 10, 16], "texture": "#base"},
|
||||||
|
"south": {"uv": [2, 15, 14, 16], "texture": "#base"},
|
||||||
|
"west": {"uv": [6, 15, 10, 16], "texture": "#base"},
|
||||||
|
"up": {"uv": [2, 6, 14, 10], "texture": "#base"},
|
||||||
|
"down": {"uv": [2, 6, 14, 10], "texture": "#base"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 157 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user