Modding 1.4.7: Adding a custom mob to Dungeons

In this tutorial I will show you how to add a custom mob to the Dungeons without editing any source code. This can be any kind of mob and for this tutorial I will be using the EntityTutorial mob. All of the code has to be added in your mod file. This is the file I will start with.


package tutorial;

import net.minecraft.entity.Entity;
importnet.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
importnet.minecraft.entity.EnumCreatureType;
importnet.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.SidedProxy;
importcpw.mods.fml.common.event.FMLInitializationEvent;
importcpw.mods.fml.common.network.NetworkMod;
importcpw.mods.fml.common.registry.EntityRegistry;
importcpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = “Tutorial_Tutorialmod”, name = “Tutorial”, version = “1.0”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
publicclass Tutorial
{
       @SidedProxy(clientSide = “tutorial.ClientProxyTutorial”, serverSide = “tutorial.CommonProxyTutorial”)
       publicstatic CommonProxyTutorial proxy;
      
       staticintstartEntityId = 300;
      
       @Init
       publicvoid load(FMLInitializationEvent event)
       {
             proxy.registerRenderThings();
            
             EntityRegistry.registerModEntity(EntityTutorial.class, “Tutorial”, 1, this, 80, 3, true);
            
             EntityRegistry.addSpawn(EntityTutorial.class, 10, 2, 4, EnumCreatureType.monster, BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.forest);
            
              LanguageRegistry.instance().addStringLocalization(“entity.Tutorial_Tutorialmod.Tutorial.name”, “Tutorial”);
            
             registerEntityEgg(EntityTutorial.class, 0x7A65CF, 0x4DF200);
       }
      
       publicstaticint getUniqueEntityId()
       {
             do
             {
                    startEntityId++;
             }
             while(EntityList.getStringFromID(startEntityId) != null);
                   
             returnstartEntityId;
       }
      
       publicstaticvoid registerEntityEgg(Class <? extends Entity> entity, int primaryColor, int secondaryColor)
       {
             int id = getUniqueEntityId();
             EntityList.IDtoClassMapping.put(id, entity);
             EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
       }
}

To add your custom mob to the vanilla dungeons without editing any file you can simply use this line of code.


DungeonHooks.addDungeonMob(“Tutorial”, 50);


You will have to add this line inside of the load method and you will have to import net.minecraftforge.common.DungeonHooks.
There are 2 parameters in this method. The first one is the name of the mob. This has to be exactly the same as the second parameter from your registerModEntity line. If you make it any different it will not work.
The second parameter in the addDungeonMob method is the rarity. The chance for zombies is 200 and for skeletons and spiders 100. The higher the number the more often you will see it in the dungeon.
The whole file should now look like this.


package tutorial;

import net.minecraft.entity.Entity;
importnet.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
importnet.minecraft.entity.EnumCreatureType;
importnet.minecraft.world.biome.BiomeGenBase;
importnet.minecraftforge.common.DungeonHooks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.SidedProxy;
importcpw.mods.fml.common.event.FMLInitializationEvent;
importcpw.mods.fml.common.network.NetworkMod;
importcpw.mods.fml.common.registry.EntityRegistry;
importcpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = “Tutorial_Tutorialmod”, name = “Tutorial”, version = “1.0”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
publicclass Tutorial
{
       @SidedProxy(clientSide = “tutorial.ClientProxyTutorial”, serverSide = “tutorial.CommonProxyTutorial”)
       publicstatic CommonProxyTutorial proxy;
      
       staticintstartEntityId = 300;
      
       @Init
       publicvoid load(FMLInitializationEvent event)
       {
             proxy.registerRenderThings();
            
             EntityRegistry.registerModEntity(EntityTutorial.class, “Tutorial”, 1, this, 80, 3, true);
            
             EntityRegistry.addSpawn(EntityTutorial.class, 10, 2, 4, EnumCreatureType.monster, BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.forest);
            
              LanguageRegistry.instance().addStringLocalization(“entity.Tutorial_Tutorialmod.Tutorial.name”, “Tutorial”);
            
             registerEntityEgg(EntityTutorial.class, 0x7A65CF, 0x4DF200);
      
             DungeonHooks.addDungeonMob(“Tutorial”, 50);
       }
      
       publicstaticint getUniqueEntityId()
       {
             do
             {
                    startEntityId++;
             }
             while(EntityList.getStringFromID(startEntityId) != null);
                   
             returnstartEntityId;
       }
      
       publicstaticvoid registerEntityEgg(Class <? extends Entity> entity, int primaryColor, int secondaryColor)
       {
             int id = getUniqueEntityId();
             EntityList.IDtoClassMapping.put(id, entity);
             EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
       }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">