方块
创建一个基本方块
blocks:
default:fairy_flower:
behavior:
type: bush_block
settings:
template: settings:surface_decoration
overrides:
item: default:fairy_flower
loot:
template: loot_table:normal_block
params:
item: default:fairy_flower
state:
base: tripwire
id: 0
vanilla-state: 0
models:
- path: "minecraft:block/custom/fairy_flower_1"
weight: 100
- path: "minecraft:block/custom/fairy_flower_2"
weight: 5
generation:
parent: "minecraft:block/custom/fairy_flower_1"
textures:
"0": "minecraft:block/custom/fairy_flower_2"
- path: "minecraft:block/custom/fairy_flower_3"
weight: 5
generation:
parent: "minecraft:block/custom/fairy_flower_1"
textures:
"0": "minecraft:block/custom/fairy_flower_3"
- path: "minecraft:block/custom/fairy_flower_4"
weight: 5
generation:
parent: "minecraft:block/custom/fairy_flower_1"
textures:
"0": "minecraft:block/custom/fairy_flower_4"
- path: "minecraft:block/custom/fairy_flower_5"
weight: 1
generation:
parent: "minecraft:block/custom/fairy_flower_1"
textures:
"0": "minecraft:block/custom/fairy_flower_5"
创建一个有变种的方块
blocks:
default:spirit_log:
behavior:
type: falling_block
loot:
template: loot_table:normal_block
params:
item: default:spirit_log
settings:
template: settings:log
overrides:
item: default:spirit_log
map-color: 16
luminance: 8
states:
base: note_block
properties:
axis:
type: axis
default-value: y
appearances:
axisY:
vanilla-state: 0
model:
path: "minecraft:block/custom/spirit_log"
generation:
parent: "minecraft:block/cube_column"
textures:
"end": "minecraft:block/custom/spirit_log_top"
"side": "minecraft:block/custom/spirit_log"
axisX:
vanilla-state: 1
model:
x: 90
y: 90
path: "minecraft:block/custom/spirit_log_horizontal"
generation:
parent: "minecraft:block/cube_column_horizontal"
textures:
"end": "minecraft:block/custom/spirit_log_top"
"side": "minecraft:block/custom/spirit_log"
axisZ:
vanilla-state: 2
model:
x: 90
path: "minecraft:block/custom/spirit_log_horizontal"
generation:
parent: "minecraft:block/cube_column_horizontal"
textures:
"end": "minecraft:block/custom/spirit_log_top"
"side": "minecraft:block/custom/spirit_log"
variants:
axis=x:
appearance: axisX
id: 0
axis=y:
appearance: axisY
id: 1
axis=z:
appearance: axisZ
id: 2
将物品链接到方块
与其他插件不同,这个插件的设计中,物品和方块是分开的。就像 Minecraft 的设计一样,有些方块在库存中以2D物品的形式出现,但放置后会变成3D 的。有些方块放置前后看起来一样,而另一些方块,比如末地传送门方块,甚至没有对应的物品形态。
你会注意到在这种情况下,物品也叫 spirit_log
,但这和方块配置中的 spirit_log
并不冲突,因为这两个 ID 本质上是注册在不同的注册表中的。
items:
default:spirit_log:
material: paper
custom-model-data: 1000
data:
display-name: "<lang:block.spirit_log>"
model:
path: "minecraft:item/custom/spirit_log"
generation:
parent: "minecraft:block/custom/spirit_log"
behavior:
type: block_item
block: default:spirit_log
在这个例子中,我们创建了一个与方块关联的物品,它的模型继承自方块的模型,因此看起来和方块一样。在这里,我们使用了 placeable_block
行为,这是插件提供的默认行为之一,提供了类似于原版 Minecraft 系统的方块放置机制。当然,还有很多其他类型的机制可供选择,包括通过 API 注册的自定义机制,以满足各种需求。
最后更新于