User Tools

Site Tools


zh_cn:tutorial:spawn_egg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
zh_cn:tutorial:spawn_egg [2022/01/01 14:58] – created xtexchooserzh_cn:tutorial:spawn_egg [2023/01/15 01:33] (current) – [创建刷怪蛋] 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, 1289542811382189, new Item.Settings().group(ItemGroup.MISC));+    public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, 0xc4c4c40xadadad, new Item.Settings().group(ItemGroup.MISC));
 } }
 </code> </code>
-刷怪蛋物品创建时需要提供实体类型、主要的和次要的颜色和物品设置。\\ 对于颜色,应使用十进制颜色而不是十六进制。\\ 如果您愿意,您也可以[[https://convertingcolors.com/|转换颜色]]到十进制颜色+:!:这个例子适用于 1.19.3 //之前//的版本,因为 1.19.3 已经直接加入了铁傀儡的刷怪蛋。但是,你可以为其他实体类型创建刷怪蛋。在 1.19.3 中,记得移除掉 ''group'' 方法的调用。要在 1.19.3 中将刷怪蛋添加到物品组,请参见[[itemgroup|此教程]]。 
 + 
 +刷怪蛋物品创建时需要提供实体类型、主要的和次要的颜色和物品设置。
  
 在完成后,你需要注册这个物品: 在完成后,你需要注册这个物品:
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, 1289542811382189, new Item.Settings().group(ItemGroup.MISC));+ public static final Item IRON_GOLEM_SPAWN_EGG = new SpawnEggItem(EntityType.IRON_GOLEM, 0xc4c4c40xadadad, new FabricItemSettings().group(ItemGroup.MISC));
  
  @Override  @Override
  public void onInitialize() {  public void onInitialize() {
- Registry.register(Registry.ITEM, new Identifier("modid", "iron_golem_spawn_egg"), IRON_GOLEM_SPAWN_EGG);+ Registry.register(Registry.ITEM, new Identifier("tutorial", "iron_golem_spawn_egg"), IRON_GOLEM_SPAWN_EGG); 
 +                // 对于 1.19.3 以上的版本,请将 Registry.ITEM 替换为 Registries.ITEM。
  }  }
 } }
Line 26: Line 29:
 =====给刷怪蛋一个纹理===== =====给刷怪蛋一个纹理=====
 如果您现在运行游戏,您的刷怪蛋将没有纹理,因此要为其添加纹理,您需要执行以下操作: 如果您现在运行游戏,您的刷怪蛋将没有纹理,因此要为其添加纹理,您需要执行以下操作:
-<file javascript src/main/resources/assets/modid/models/item/iron_golem_spawn_egg.json>+<file javascript src/main/resources/assets/tutorial/models/item/iron_golem_spawn_egg.json>
 { {
   "parent": "item/template_spawn_egg"   "parent": "item/template_spawn_egg"
Line 32: Line 35:
 </file> </file>
  
-同时确保添加翻译到语言文件: +同时确保添加翻译到[[lang|语言]]文件: 
-<file javascript src/main/resources/assets/modid/lang/zh_cn.json>+<file javascript src/main/resources/assets/tutorial/lang/en_us.json> 
 +
 +    "item.tutorial.iron_golem_spawn_egg": "Iron Golem Spawn Egg" 
 +
 +</file> 
 +<file javascript src/main/resources/assets/tutorial/lang/zh_cn.json>
 { {
-    "item.modid.iron_golem_spawn_egg": "铁傀儡刷怪蛋"+    "item.tutorial.iron_golem_spawn_egg": "铁傀儡刷怪蛋"
 } }
 </file> </file>
zh_cn/tutorial/spawn_egg.1641049096.txt.gz · Last modified: 2022/01/01 14:58 by xtexchooser