User Tools

Site Tools


tutorial:spawn_egg

Differences

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

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
tutorial:spawn_egg [2021/07/18 18:01] – created spawn egg page (feel free to make changes if you would like to) daviddevsdumbstufftutorial:spawn_egg [2023/01/15 01:31] – [Giving the Spawn Egg a Texture] solidblock
Line 7: Line 7:
 <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 FabricItemSettings().group(ItemGroup.MISC));
 } }
 </code> </code>
-The spawn egg item takes an entity type, a primary and secondary color, and an item settings option.\\ It also uses decimal coloring for the spawn egg colors. Not hexadecimal, just decimal.\\ +:!:This example is used for versions //before// 1.19.3, as Minecraft 1.19.3 directly added iron golem spawn eggs. However, you can create spawn eggs for other entity types. In 1.19.3, remember to remove the ''group'' method invoke. 
-You can also [[https://convertingcolors.com/|convert your color]] to a decimal color if you would like.+ 
 +The spawn egg item takes an entity type, a primary and secondary color, and an item settings option.
  
 After you've done that, you will need to register your item: After you've done that, you will need to register your item:
Line 17: Line 18:
 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); 
 +                // For versions above 1.19.3, replace ''Registry.ITEM'' with ''Registries.ITEM''.
  }  }
 } }
Line 28: Line 30:
 =====Giving the Spawn Egg a Texture===== =====Giving the Spawn Egg a Texture=====
 If you ran the game now, your spawn egg wouldn't have a texture, so to give it a texture you would need to do as follows: If you ran the game now, your spawn egg wouldn't have a texture, so to give it a texture you would need to do as follows:
-<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 34: Line 36:
 </file> </file>
  
-Make sure to also add this to your lang file. +Make sure to also add this to your [[lang]] file. 
-<file javascript src/main/resources/assets/modid/lang/en_us.json>+<file javascript src/main/resources/assets/tutorial/lang/en_us.json>
 { {
-    "item.modid.iron_golem_spawn_egg": "Iron Golem Spawn Egg"+    "item.tutorial.iron_golem_spawn_egg": "Iron Golem Spawn Egg"
 } }
 </file> </file>
tutorial/spawn_egg.txt · Last modified: 2023/01/15 01:33 by solidblock