zh_cn:tutorial:crops
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:crops [2024/08/27 04:55] – solidblock | zh_cn:tutorial:crops [2025/04/01 12:05] (current) – fix typo solidblock | ||
---|---|---|---|
Line 55: | Line 55: | ||
===== 注册你的作物和种子物品 ===== | ===== 注册你的作物和种子物品 ===== | ||
- | 现在需要注册作物和用作种子的物品。种子模型和类(包括为方便而用的静态 '' | + | 现在需要注册作物和用作种子的物品。种子模型和类(包括为方便而用的静态 '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | // 对于 1.21.2 之前的版本: | ||
public static final CropBlock CUSTOM_CROP = register(" | public static final CropBlock CUSTOM_CROP = register(" | ||
+ | | ||
+ | // 对于 1.21.2 及之后的版本: | ||
+ | public static final Block CUSTOM_CROP = register(" | ||
</ | </ | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | // 对于 1.21.2 之前的版本: | ||
public static final Item CUSTOM_SEEDS = register(" | public static final Item CUSTOM_SEEDS = register(" | ||
+ | | ||
+ | // 对于 1.21.2 及之后的版本: | ||
+ | public static final Item CUSTOM_SEEDS = register(" | ||
+ | </ | ||
+ | |||
+ | > 在[[blocks|添加方块]]教程中,我们写的 '' | ||
+ | > <code java TutorialBlocks.java> | ||
+ | // ... | ||
+ | public static final Block CUSTOM_CROP = registerBlockOnly(" | ||
+ | | ||
+ | // ... | ||
+ | | ||
+ | private static Block registerBlockOnly(String path, Function< | ||
+ | final Identifier identifier = Identifier.of(" | ||
+ | final RegistryKey< | ||
+ | |||
+ | return Blocks.register(registryKey, | ||
+ | } | ||
</ | </ | ||
- | 你很可能还需要 '' | + | 你很可能还需要 '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 92: | Line 115: | ||
</ | </ | ||
- | 最后,您还需要为您的作物创建方块状态,以给作物的每个生长阶段都注册单独的模型。 | + | 最后,您还需要为您的作物创建方块状态映射,以给作物的每个生长阶段都分配单独的模型。 |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 124: | Line 147: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | > 种子物品也需要对应的物品模型和物品模型映射(对于 1.21.4 及之后的版本),具体做法参见 [[items]],这里不作详细描述。 | ||
===== 战利品表 ===== | ===== 战利品表 ===== |
zh_cn/tutorial/crops.1724734505.txt.gz · Last modified: 2024/08/27 04:55 by solidblock