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
Next 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:30] – [Creating the Spawn Egg] 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''.
  }  }
 } }
tutorial/spawn_egg.txt · Last modified: 2023/01/15 01:33 by solidblock