zh_cn:tutorial:crops
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
zh_cn:tutorial:crops [2021/11/09 11:16] – created breakice | zh_cn:tutorial:crops [2022/12/16 02:44] – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 添加你的自定义作物 ====== | + | ====== 添加自定义作物 ====== |
- | 这篇教程会教会你如何添加一个像是小麦和胡萝卜那样的作物。如果你想创建属于你的作物的话,你需要以下物品: | + | 本教程将教会您如何添加像小麦和胡萝卜那样的作物。创建自定义的作物时,需要做以下这些事情: |
- | * 自定义的种子 | + | * 自定义的种子物品 |
- | | + | * 作物方块和种子物品的注册表 |
- | * 作物方块的类 | + | * 作物方块类 |
* 为你的作物设计的方块状态和模型 | * 为你的作物设计的方块状态和模型 | ||
===== 创建作物类 ===== | ===== 创建作物类 ===== | ||
- | 为了创建自定义作物我们需要先创建一个方块类。 你需要用你的作物名命名你的类并且让他继承 '' | + | 为创建自定义作物,我们需要先创建一个方块类。你需要用你的作物名称命名你的类,并且继承 '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 31: | Line 31: | ||
</ | </ | ||
- | Once you've configured that, you need to define your seed item and add an outline shape. We haven' | + | 配置完成后,你需要定义你的种子物品并添加外观性状。我们还没有添加种子物品,因此暂时先使用其他的。下面的代码,使用长方体形状、种子物品和外观形状应该是这样子: |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 59: | Line 59: | ||
</ | </ | ||
- | ===== Registering your Crop and Seed Item ===== | + | ===== 注册您的作为和种子物品 |
- | Now we need to register our crop and the item to use for our seed. The seed model and class will not be covered in this tutorial but you can refer to the [[tutorial:items|Item]] page. It is important you add '' | + | 现在需要注册作物和用作种子的物品。本教程不介绍种子模型和类,请参考 |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 72: | Line 72: | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | Registry.register(Registry.BLOCK, new Identifier(" | + | Registry.register(Registries.BLOCK, new Identifier(" |
- | Registry.register(Registry.ITEM, new Identifier(" | + | Registry.register(Registries.ITEM, new Identifier(" |
} | } | ||
Line 79: | Line 79: | ||
</ | </ | ||
- | You also probably want the '' | + | 你很可能还需要 |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | @Environment(EnvType.CLIENT) | ||
public class TutorialModClient implements ClientModInitializer { | public class TutorialModClient implements ClientModInitializer { | ||
| | ||
Line 90: | Line 91: | ||
</ | </ | ||
- | ===== Creating our Blockstate and Models | + | ===== 创建方块状态和模型 |
- | Now that we have finished the registry and code, we can add our models. The example below shows a simple growth stage model that uses the '' | + | 我们已经完成了注册和代码,现在需要添加模型。下面的例子展示了使用 |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 102: | Line 103: | ||
</ | </ | ||
- | Lastly you will want to create a blockstate for your crop which registers your model for each age of your crop: | + | 最后,您还需要为您的作物创建方块状态,以给作物的每个生长阶段都注册单独的模型。 |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 135: | Line 136: | ||
</ | </ | ||
- | ===== Crop Block Finished! | + | ===== 大功告成! |
- | If you completed all parts of this tutorial correctly, you should now have a working crop! Your crop will be usable with bone meal and can only be placed on farmland with your seed item. | + | 如果你正确完成了本教程的所有部分,那么你现在就应该有一个生效的作物了!这个作物可以用骨粉催熟,并且只能用种子物品放置在耕地上。 |
zh_cn/tutorial/crops.txt · Last modified: 2023/11/18 08:44 by solidblock