public static void registerEntities(Class entityClass, String name){
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long x = name.hashCode();
Random random = new Random(x);
int MainColor = random.nextInt() * 16777215;
int SubColor = random.nextInt() * 16777215;
One thing to note is that you should only use one of the entity registration methods. Either use the global ID (old way which has potential for ID conflicts, but has advantage of built-in spawn egg association) or the mod entity registration. Since you want the spawn egg (it is a bit of a pain to make a custom one but I have tutorial if you really need it) you probably should stick with the global ID registration. So I don't think you need the registerModEntity() line.
Ok cool thanks. I deleted that and the game loads up fine and all, however when i try to spawn the entity it just goes away as soon as i spawn it. Any Ideas??
Well half of the problem was the being in peaceful but i did have another problem with the rendering. i'll post the finished code and they can compare the difference because i forgot what i did.
The Entity Handler Class
public class EntityHandler{
public static void registerMonster(Class entityClass, String name)
{
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long seed = name.hashCode();
Random rand = new Random(seed);
int primaryColor = rand.nextInt() * 16777215;
int secondaryColor = rand.nextInt() * 16777215;
Here is where the entity is registered
@EventHandler
public void Init(FMLInitializationEvent event){
//Recipies
GameRegistry.addRecipe(new ItemStack (SPick), new Object [] {"XXX", " Y ", " Y ", 'X', Sapphire, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (SAxe), new Object [] {"XX ", "XY ", " Y ", 'X', Sapphire, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (SHoe), new Object [] {"XX ", " Y ", " Y ", 'X', Sapphire, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (SSpade), new Object [] {" X ", " Y ", " Y ", 'X', Sapphire, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (SSword), new Object [] {" X ", " X ", " Y ", 'X', Sapphire, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (RPick), new Object [] {"XXX", " Y ", " Y ", 'X', RedRuby, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (RAxe), new Object [] {"XX ", "XY ", " Y ", 'X', RedRuby, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (RHoe), new Object [] {"XX ", " Y ", " Y ", 'X', RedRuby, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (RSpade), new Object [] {" X ", " Y ", " Y ", 'X', RedRuby, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (RSword), new Object [] {" X ", " X ", " Y ", 'X', RedRuby, 'Y', Items.stick});
GameRegistry.addRecipe(new ItemStack (SHelmet), new Object [] {"XXX", "X X", 'X', Sapphire});
GameRegistry.addRecipe(new ItemStack (SChest), new Object [] {"X X", "XXX", "XXX", 'X', Sapphire});
GameRegistry.addRecipe(new ItemStack (SLeggings), new Object [] {"XXX", "X X", "X X", 'X', Sapphire});
GameRegistry.addRecipe(new ItemStack (SBoots), new Object [] {"X X", "X X", 'X', Sapphire});
//Smelting
GameRegistry.addSmelting(new ItemStack(ROre), new ItemStack (RedRuby), 10f);
GameRegistry.addSmelting(new ItemStack(SOre), new ItemStack (Sapphire), 10f);
//Entities
EntityHandler.registerEntities(EntityVampire.class, "Vampire");
}
Here is the EntityHandler class
public class EntityHandler {
public static void registerEntities(Class entityClass, String name){
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long x = name.hashCode();
Random random = new Random(x);
int MainColor = random.nextInt() * 16777215;
int SubColor = random.nextInt() * 16777215;
EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
EntityRegistry.registerModEntity(entityClass, name, entityID, GemsModMain.instance, 64, 1, true);
EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, MainColor, SubColor));
}
}
And here is the EntityVampire class
public class EntityVampire extends EntityMob{
public EntityVampire(World world) {
super(world);
this.experienceValue = 50;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D);
}
}
Also it isnt Rendered yet i was just trying to successfully get it in the game before giving it a model. It tells me that there are errors
Here
and here
Elemental Essences Download Link
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!
The Entity Handler Class
public class EntityHandler{
public static void registerMonster(Class entityClass, String name)
{
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long seed = name.hashCode();
Random rand = new Random(seed);
int primaryColor = rand.nextInt() * 16777215;
int secondaryColor = rand.nextInt() * 16777215;
EntityRegistry.addSpawn(entityClass, 50, 2, 4, EnumCreatureType.monster, BiomeGenBase.desert, BiomeGenBase.extremeHills, BiomeGenBase.hell, BiomeGenBase.forest, BiomeGenBase.birchForest, BiomeGenBase.forestHills, BiomeGenBase.birchForestHills, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills);
EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor));
}
}
The Entity Class
public class EntityVampire extends EntityMob{
public EntityVampire(World world) {
super(world);
this.experienceValue = (int) 34.0f;
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25465481654899D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D);
}
@Override
protected Item getDropItem()
{
return Item.getItemFromBlock(GemsModMain.SOre);
}
@Override
protected void dropRareDrop(int par1)
{
switch (this.rand.nextInt(3))
{
case 0:
this.dropItem(GemsModMain.Sapphire, 1);
break;
case 1:
this.dropItem(GemsModMain.RedRuby, 1);
}
}
}