zh_cn:tutorial:tags
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:tags [2022/03/05 02:40] – [标签示例] xtexchooser | zh_cn:tutorial:tags [2023/08/15 01:30] (current) – [常见标签和模组标签] wjz_p | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== 标签示例 ===== | ===== 标签示例 ===== | ||
- | 文件位置:'' | + | 文件位置:'' |
<code javascript> | <code javascript> | ||
{ | { | ||
" | " | ||
" | " | ||
- | "examplemod: | + | "tutorial: |
] | ] | ||
} | } | ||
Line 15: | Line 15: | ||
如需注册标签并在代码中使用,你需要这样使用: | 如需注册标签并在代码中使用,你需要这样使用: | ||
+ | === 1.19.3 及以上 === | ||
+ | < | ||
+ | public class ModBlockTags { | ||
+ | public static final TagKey< | ||
+ | } | ||
+ | </ | ||
- | ==== 1.18.2及更高==== | + | === 1.19.2 及以下 |
- | <code java> | + | <yarncode |
- | import net.minecraft.block.Block; | + | public class ModBlockTags |
- | import net.minecraft.tag.TagKey; | + | public static final TagKey<class_2248> EXAMPLE_ORES = class_6862.method_40092(class_2378.BLOCK_KEY, new class_2960("tutorial", " |
- | import net.minecraft.util.Identifier; | + | |
- | import net.minecraft.util.registry.Registry; | + | |
- | + | ||
- | public class BlockTags | + | |
- | public static final TagKey<Block> EXAMPLE_ORES = TagKey.of(Registry.BLOCK_KEY, new Identifier("examplemod", " | + | |
} | } | ||
- | </code> | + | </yarncode> |
+ | === 1.18.1 及以下(需要 Fabric API) === | ||
+ | < | ||
+ | public class ModBlockTags { | ||
+ | public static final Tag< | ||
+ | } | ||
+ | </ | ||
- | ==== 1.18.1及以下(需要 Fabric API) | + | === 1.17 及以下,不含 1.17.1(需要 Fabric API) === |
- | <code java> | + | <yarncode |
- | import net.fabricmc.fabric.api.tag.TagRegistry; | + | public class ModBlockTags |
- | import net.minecraft.block.Block; | + | public static final Tag<class_2248> EXAMPLE_ORES = TagRegistry.block(new |
- | import net.minecraft.tag.Tag; | + | |
- | import net.minecraft.util.Identifier; | + | |
- | + | ||
- | public class BlockTags | + | |
- | public static final Tag<Block> EXAMPLE_ORES = TagRegistry.block(new | + | |
} | } | ||
- | </code> | + | </yarncode> |
+ | |||
+ | 注意 '' | ||
===== 常见标签和模组标签 ===== | ===== 常见标签和模组标签 ===== | ||
- | 如果你的标签仅仅适用于你的模组,其他的模组不太可能有类似物品,或则你尤其只需要将你的模组的物品包含到标签中,则使用 '' | + | 如果你的标签仅仅适用于你的模组,其他的模组不太可能有类似物品,或者你尤其只需要将你的模组的物品包含到标签中,则使用 '' |
======= 创建新的常用标签 ======= | ======= 创建新的常用标签 ======= |
zh_cn/tutorial/tags.1646448006.txt.gz · Last modified: 2022/03/05 02:40 by xtexchooser