Fabric 教程
安装
- 启用 log4j 调试信息(英文)
基础
- 约定和术语
- 注册
- 开发工具
物品
方块和方块实体
数据生成
世界生成
命令
事件
实体
流体
Mixin 和 ASM
杂项
Yarn
贡献 Fabric
- FabLabs - 在提交 PR 之前起草新功能的试验场
标签是一组有类似属性的方块、物品或者流体,可以用在配方中,使得不同物品可以在配方中等价。关于标签的更多表述,可参考中文Minecraft Wiki。标签也可以用来分组不同模组的相同物品,以使得这些物品互相兼容。这些称为“常用标签”。
文件位置:src/main/resources/data/tutorial/tags/blocks/example_ores.json
{ "replace": false, "values": [ "tutorial:example_ore" ] }
“replace”
标签决定了模组是否要从标签中移除该文件中未提及的其他物品。不建议设为true,且破坏和其他模组的兼容性。文件路径的 blocks
也可以是 items
或者 fluids
,用于表示不同的类型。多个词语用下划线隔开,且标签名称使用复数形式(不可数名词除外)。
如需注册标签并在代码中使用,你需要这样使用:
public class ModBlockTags { public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(RegistryKeys.BLOCK, new Identifier("tutorial", "example_ores")); }
public class ModBlockTags { public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(Registry.BLOCK_KEY, new Identifier("tutorial", "example_ores")); }
public class ModBlockTags { public static final Tag<Block> EXAMPLE_ORES = TagFactory.BLOCK.create(new Identifier("tutorial", "example_ores")); }
public class ModBlockTags { public static final Tag<Block> EXAMPLE_ORES = TagRegistry.block(new Identifier("tutorial", "example_ores")); }
注意 TagRegistry
自从 Fabric API 0.46.0 已经弃用,此时已有 TagFactory
,但不支持 1.17。
如果你的标签仅仅适用于你的模组,其他的模组不太可能有类似物品,或则你尤其只需要将你的模组的物品包含到标签中,则使用 你的模组id:你的标签
,即上面的这个例子。如果你的模组添加其他模组也会添加的物品,你可以:
常用标签使用 c:你的标签
这样的语法,其中 c
代表了“常用”。创建文件时,使用文件路径 src/main/resources/data/c/tags/
中的 blocks
、items
或者 fluids
。多个词语用下划线隔开,且标签名称使用复数形式(不可数名词除外)。