zh_cn:tutorial:spawn_egg
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
zh_cn:tutorial:spawn_egg [2022/01/01 14:58] – created xtexchooser | zh_cn:tutorial:spawn_egg [2023/01/15 01:32] – [给刷怪蛋一个纹理] solidblock | ||
---|---|---|---|
Line 6: | Line 6: | ||
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, | + | public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, |
} | } | ||
</ | </ | ||
- | 刷怪蛋物品创建时需要提供实体类型、主要的和次要的颜色和物品设置。\\ 对于颜色,应使用十进制颜色而不是十六进制。\\ 如果您愿意,您也可以[[https:// | + | : |
+ | |||
+ | 刷怪蛋物品创建时需要提供实体类型、主要的和次要的颜色和物品设置。 | ||
在完成后,你需要注册这个物品: | 在完成后,你需要注册这个物品: | ||
Line 15: | Line 17: | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, | + | public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, |
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | Registry.register(Registry.ITEM, | + | Registry.register(Registry.ITEM, |
+ | // 对于 1.19.3 以上的版本,请将 Registry.ITEM 替换为 Registries.ITEM。 | ||
} | } | ||
} | } | ||
Line 26: | Line 29: | ||
=====给刷怪蛋一个纹理===== | =====给刷怪蛋一个纹理===== | ||
如果您现在运行游戏,您的刷怪蛋将没有纹理,因此要为其添加纹理,您需要执行以下操作: | 如果您现在运行游戏,您的刷怪蛋将没有纹理,因此要为其添加纹理,您需要执行以下操作: | ||
- | <file javascript src/ | + | <file javascript src/ |
{ | { | ||
" | " | ||
Line 32: | Line 35: | ||
</ | </ | ||
- | 同时确保添加翻译到语言文件: | + | 同时确保添加翻译到[[lang|语言]]文件: |
- | <file javascript src/ | + | <file javascript src/ |
+ | { | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | <file javascript src/ | ||
{ | { | ||
- | "item.modid.iron_golem_spawn_egg": | + | "item.tutorial.iron_golem_spawn_egg": |
} | } | ||
</ | </ |
zh_cn/tutorial/spawn_egg.txt · Last modified: 2023/01/15 01:33 by solidblock