1
0

feat: 新增基础路方块

This commit is contained in:
2022-07-03 21:33:18 +08:00
parent c25a224af5
commit 317f579f2e
66 changed files with 611 additions and 0 deletions

View File

@@ -0,0 +1,210 @@
// priority: 0
console.info(`${global.LOG_PREFIX} 注册 wheat_plus 相关内容`);
/** 模组 ID */
const modID = 'wheat_plus';
/**
* @description 设置方块碰撞箱属性
* @param {Internal.BlockBuilder} block
* @param {'full'|'half'} type
*/
const setBlockBoxProps = function (block, type) {
if (type === 'full') {
block.box(0, 0, 0, 16, 16, 16, true);
block.fullBlock(true);
block.opaque(true);
} else if (type === 'half') {
block.box(0, 0, 0, 16, 8, 16, true);
block.fullBlock(false);
block.opaque(false);
}
};
// 注册方块
onEvent('block.registry', (event) => {
console.info(`${global.LOG_PREFIX} 注册方块 - 开始`);
/** 模型文件基础路径 */
const modelPathBase = `${modID}:block/`;
/** 纹理文件基础路径 */
const texturePathBase = `${modID}:block/`;
/** 路方块基础属性 */
const roadBlockAttrs = {
hardness: 8.0,
lightLevel: 0,
material: 'rock',
renderType: 'cutout',
resistance: 16.0,
};
/** 普通路方块 */
const roadBlocksNormal = [
{
name: 'road_blank',
label: '路 - 空白',
texturePath: 'transparent',
hasNormal: true,
hasSlant: false,
},
{
name: 'road_line_single_white',
label: '路 - 单白线',
texturePath: 'road/line/single_white',
hasNormal: true,
hasSlant: true,
},
{
name: 'road_line_single_yellow',
label: '路 - 单黄线',
texturePath: 'road/line/single_yellow',
hasNormal: true,
hasSlant: true,
},
{
name: 'road_line_double_white',
label: '路 - 双白线',
texturePath: 'road/line/double_white',
hasNormal: true,
hasSlant: true,
},
{
name: 'road_line_double_yellow',
label: '路 - 双黄线',
texturePath: 'road/line/double_yellow',
hasNormal: true,
hasSlant: true,
},
];
roadBlocksNormal.forEach((config) => {
/** 方块 ID包含模组 ID */
const id = `${modID}:${config.name}`;
/** 方块名称文本 */
const label = (config.label || 'Unknown');
/** 纹理文件相对路径 */
const texturePath = config.texturePath;
// 完整,直线
if (config.hasNormal) {
const block = event.create(`${id}_full`, 'basic');
block.displayName(`${label},完整,直线`);
setBlockBoxProps(block, 'full');
if (texturePath) {
block.modelJson = {
parent: `${modelPathBase}road/base_full`,
textures: {
content: `${texturePathBase}${texturePath}`,
side: `${texturePathBase}${texturePath}`
}
};
}
for (let attr in roadBlockAttrs) {
block[attr](roadBlockAttrs[attr]);
}
}
// 完整,斜线
if (config.hasSlant) {
const block = event.create(`${id}_full_slant`, 'basic');
block.displayName(`${label},完整,斜线`);
setBlockBoxProps(block, 'full');
if (texturePath) {
block.modelJson = {
parent: `${modelPathBase}road/base_full`,
textures: {
content: `${texturePathBase}${texturePath}_slant`,
side: `${texturePathBase}${texturePath}`
}
};
}
for (let attr in roadBlockAttrs) {
block[attr](roadBlockAttrs[attr]);
}
}
// 一半,直线
if (config.hasNormal) {
const block = event.create(`${id}_half`, 'basic');
block.displayName(`${label},一半,直线`);
setBlockBoxProps(block, 'half');
if (texturePath) {
block.modelJson = {
parent: `${modelPathBase}road/base_half`,
textures: {
content: `${texturePathBase}${texturePath}`,
side: `${texturePathBase}${texturePath}`
}
};
}
for (let attr in roadBlockAttrs) {
block[attr](roadBlockAttrs[attr]);
}
}
// 一半,斜线
if (config.hasSlant) {
const block = event.create(`${id}_half_slant`, 'basic');
block.displayName(`${label},一半,斜线`);
setBlockBoxProps(block, 'half');
if (texturePath) {
block.modelJson = {
parent: `${modelPathBase}road/base_half`,
textures: {
content: `${texturePathBase}${texturePath}_slant`,
side: `${texturePathBase}${texturePath}`
}
};
}
for (let attr in roadBlockAttrs) {
block[attr](roadBlockAttrs[attr]);
}
}
});
console.info(`${global.LOG_PREFIX} 注册方块 - 完成`);
});
// 注册物品
onEvent('item.registry', (event) => {
console.info(`${global.LOG_PREFIX} 注册物品 - 开始`);
// event.create('example_item').displayName('Example Item');
console.info(`${global.LOG_PREFIX} 注册物品 - 完成`);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,13 @@
matchTiles=wheat_plus:block/road/line/double_white
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2

View File

@@ -0,0 +1,19 @@
matchTiles=wheat_plus:block/road/line/double_white_slant
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2
# corner
ctm.4=5
ctm.5=6
ctm.16=7
ctm.17=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,13 @@
matchTiles=wheat_plus:block/road/line/double_yellow
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2

View File

@@ -0,0 +1,19 @@
matchTiles=wheat_plus:block/road/line/double_yellow_slant
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2
# corner
ctm.4=5
ctm.5=6
ctm.16=7
ctm.17=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

View File

@@ -0,0 +1,13 @@
matchTiles=wheat_plus:block/road/line/single_white
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2

View File

@@ -0,0 +1,19 @@
matchTiles=wheat_plus:block/road/line/single_white_slant
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2
# corner
ctm.4=5
ctm.5=6
ctm.16=7
ctm.17=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

View File

@@ -0,0 +1,13 @@
matchTiles=wheat_plus:block/road/line/single_yellow
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2

View File

@@ -0,0 +1,19 @@
matchTiles=wheat_plus:block/road/line/single_yellow_slant
method=ctm_compact
faces=top
# tile index:
# 0-4,5, 6, 7, 8
tiles=0-4,tl,tr,bl,br
# side
ctm.1=3
ctm.3=3
ctm.12=2
ctm.36=2
# corner
ctm.4=5
ctm.5=6
ctm.16=7
ctm.17=8

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

View File

@@ -0,0 +1,41 @@
{
"credit": "Created by Frost-ZX using Blockbench.",
"parent": "block/block",
"textures": {
"particle": "wheat_plus:block/road/base",
"texture": "wheat_plus:block/road/base",
"side": "wheat_plus:block/road/base_bevel_side",
"content": "wheat_plus:block/road/content"
},
"elements": [
{
"name": "Content",
"from": [0, -1.9, -2],
"to": [16, -1.9, 14],
"rotation": {"angle": -45, "axis": "x", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#content"}
}
},
{
"name": "Bevel",
"from": [0, -2, -2],
"to": [16, -2, 14],
"rotation": {"angle": -45, "axis": "x", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
},
{
"name": "Main",
"from": [0, -4, 0],
"to": [16, 12, 16],
"faces": {
"east": {"uv": [0, 0, 16, 16], "texture": "#side"},
"south": {"uv": [0, 0, 16, 16], "texture": "#texture"},
"west": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#side"},
"down": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
}
]
}

View File

@@ -0,0 +1,41 @@
{
"credit": "Created by Frost-ZX using Blockbench.",
"parent": "block/block",
"textures": {
"particle": "wheat_plus:block/road/base",
"texture": "wheat_plus:block/road/base",
"side": "wheat_plus:block/road/base_bevel_side"
},
"elements": [
{
"name": "Bevel",
"from": [0, -2, -2],
"to": [16, -2, 14],
"rotation": {"angle": -45, "axis": "x", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
},
{
"name": "Bevel",
"from": [-6, 6, 0],
"to": [10, 6, 16],
"rotation": {"angle": -45, "axis": "z", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
},
{
"name": "Main",
"from": [0, -4, 0],
"to": [16, 12, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#side"},
"east": {"uv": [0, 0, 16, 16], "texture": "#side"},
"south": {"uv": [0, 0, 16, 16], "texture": "#texture"},
"west": {"uv": [0, 0, 16, 16], "texture": "#texture"},
"down": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
}
]
}

View File

@@ -0,0 +1,39 @@
{
"credit": "Created by Frost-ZX using Blockbench.",
"parent": "block/block",
"textures": {
"particle": "wheat_plus:block/road/base",
"texture": "wheat_plus:block/road/base",
"side": "wheat_plus:block/road/base_bevel_side"
},
"elements": [
{
"name": "Bevel",
"from": [-6, 6, 0],
"to": [10, 6, 16],
"rotation": {"angle": -45, "axis": "z", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#side"}
}
},
{
"name": "Bevel",
"from": [0, -2, -2],
"to": [16, -2, 14],
"rotation": {"angle": -45, "axis": "x", "origin": [0, 0, 0], "rescale": true},
"faces": {
"up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#side"}
}
},
{
"name": "Main",
"from": [0, -4, 0],
"to": [16, 12, 16],
"faces": {
"south": {"uv": [0, 0, 16, 16], "texture": "#side"},
"west": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#side"},
"down": {"uv": [0, 0, 16, 16], "texture": "#texture"}
}
}
]
}

View File

@@ -0,0 +1,76 @@
{
"credit": "Created by Frost-ZX using Blockbench.",
"parent": "block/block",
"ambientocclusion": false,
"textures": {
"particle": "wheat_plus:block/road/base",
"base": "wheat_plus:block/road/base",
"content": "wheat_plus:block/road/content",
"side": "wheat_plus:block/transparent"
},
"elements": [
{
"name": "content",
"from": [0, 16.1, 0],
"to": [16, 16.1, 16],
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#content"}
}
},
{
"name": "base",
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "north"},
"east": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "east"},
"south": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "south"},
"west": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "west"},
"up": {"uv": [0, 0, 16, 16], "texture": "#base"},
"down": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "down"}
}
},
{
"name": "north",
"from": [0, 0, -0.1],
"to": [16, 16, -0.1],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#side", "cullface": "north"}
}
},
{
"name": "south",
"from": [0, 0, 16.1],
"to": [16, 16, 16.1],
"faces": {
"south": {"uv": [0, 0, 16, 16], "texture": "#side", "cullface": "south"}
}
},
{
"name": "west",
"from": [-0.1, 0, 0],
"to": [-0.1, 16, 16],
"faces": {
"west": {"uv": [0, 0, 16, 16], "texture": "#side", "cullface": "west"}
}
},
{
"name": "east",
"from": [16.1, 0, 0],
"to": [16.1, 16, 16],
"faces": {
"east": {"uv": [0, 0, 16, 16], "texture": "#side", "cullface": "east"}
}
}
],
"groups": [
0,
1,
{
"name": "side",
"origin": [0, 0, 0],
"color": 0,
"children": [2, 3, 4, 5]
}
]
}

View File

@@ -0,0 +1,76 @@
{
"credit": "Created by Frost-ZX using Blockbench.",
"parent": "block/block",
"ambientocclusion": false,
"textures": {
"particle": "wheat_plus:block/road/base",
"base": "wheat_plus:block/road/base",
"content": "wheat_plus:block/road/content",
"side": "wheat_plus:block/transparent"
},
"elements": [
{
"name": "content",
"from": [0, 8.1, 0],
"to": [16, 8.1, 16],
"faces": {
"up": {"uv": [0, 0, 16, 16], "texture": "#content"}
}
},
{
"name": "base",
"from": [0, 0, 0],
"to": [16, 8, 16],
"faces": {
"north": {"uv": [0, 8, 16, 16], "texture": "#base", "cullface": "north"},
"east": {"uv": [0, 8, 16, 16], "texture": "#base", "cullface": "east"},
"south": {"uv": [0, 8, 16, 16], "texture": "#base", "cullface": "south"},
"west": {"uv": [0, 8, 16, 16], "texture": "#base", "cullface": "west"},
"up": {"uv": [0, 0, 16, 16], "texture": "#base"},
"down": {"uv": [0, 0, 16, 16], "texture": "#base", "cullface": "down"}
}
},
{
"name": "north",
"from": [0, 0, -0.1],
"to": [16, 8, -0.1],
"faces": {
"north": {"uv": [0, 8, 16, 16], "texture": "#side", "cullface": "north"}
}
},
{
"name": "south",
"from": [0, 0, 16.1],
"to": [16, 8, 16.1],
"faces": {
"south": {"uv": [0, 8, 16, 16], "texture": "#side", "cullface": "south"}
}
},
{
"name": "west",
"from": [-0.1, 0, 0],
"to": [-0.1, 8, 16],
"faces": {
"west": {"uv": [0, 8, 16, 16], "texture": "#side", "cullface": "west"}
}
},
{
"name": "east",
"from": [16.1, 0, 0],
"to": [16.1, 8, 16],
"faces": {
"east": {"uv": [0, 8, 16, 16], "texture": "#side", "cullface": "east"}
}
}
],
"groups": [
0,
1,
{
"name": "side",
"origin": [0, 0, 0],
"color": 0,
"children": [2, 3, 4, 5]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB