Jump to content

[1.8] Multiple Custom Entities


Snipehawk

Recommended Posts

Hello,

I am making a mod for Minecraft 1.8 and am wondering why I cannot create multiple mobs using my method..

The problem is that in my common proxy only the first "Entity Creator" is being read/used (Only Spartan Soldier is implemented into game but when order is switched around only Samurai is being implemented)

 

Here is my Common Proxy:

 

 

 

package adamisaac.empiresmod.proxy;

 

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import adamisaac.empiresmod.EntityCreator;

import adamisaac.empiresmod.empireEntity.EntitySamurai;

import adamisaac.empiresmod.empireEntity.EntitySpartanSoldier;

import adamisaac.empiresmod.empireRender.RenderSamurai;

import adamisaac.empiresmod.empireRender.RenderSpartanSoldier;

import adamisaac.empiresmod.init.EmpiresModItems;

 

public class CommonProxy  {

public void preInit(FMLPreInitializationEvent e) {

 

EmpiresModItems.createItems();

 

//ModBlocks.createBlocks();

}

 

public void init(FMLInitializationEvent e) {

 

 

 

EntityCreator.createMob(EntitySpartanSoldier.class, new RenderSpartanSoldier(), "SpartanSoldier", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

EntityCreator.createMob(EntitySamurai.class, new RenderSamurai(), "Samurai", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

 

//ModCrafting.initCrafting();

;

}

 

public void postInit(FMLPostInitializationEvent e) {

 

}

}

 

 

 

Here is my method class:

 

 

 

package adamisaac.empiresmod;

import net.minecraft.client.renderer.entity.Render;

import net.minecraft.entity.EntityList;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraftforge.fml.common.registry.EntityRegistry;

public class EntityCreator {

 

public static void createMob(Class entityClass, Render render, String entityName, EnumCreatureType type, int probability, int minSpawn, int maxSpawn, BiomeGenBase [] biomes, int solidColor, int spotColor, boolean hasSpawnEgg){

int id = EntityRegistry.findGlobalUniqueEntityId();

EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);

EntityRegistry.registerModEntity(entityClass, entityName, solidColor, EmpiresMod.instance, 64, 1, true);

EntityRegistry.addSpawn(entityName, probability, minSpawn, maxSpawn, type, biomes);

RenderingRegistry.registerEntityRenderingHandler(entityClass, render);

 

if (hasSpawnEgg) {

EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, solidColor, spotColor));

}

 

 

}

}

 

 

 

Any help would be appreciated!

Link to comment
Share on other sites

Right, had it in the main class before, but wasn't working so I decided to throw it in my Proxy in desperation  :-\

 

It is in my main class now, but still isn't working.. Any ideas?

 

 

 

package adamisaac.empiresmod;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.ItemModelMesher;

import net.minecraft.client.resources.model.ModelBakery;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.item.Item;

import net.minecraft.item.Item.ToolMaterial;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraftforge.common.util.EnumHelper;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.Mod.Instance;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import adamisaac.empiresmod.empireEntity.EntitySamurai;

import adamisaac.empiresmod.empireEntity.EntitySpartanSoldier;

import adamisaac.empiresmod.empireRender.RenderSamurai;

import adamisaac.empiresmod.empireRender.RenderSpartanSoldier;

import adamisaac.empiresmod.init.EmpireBow;

import adamisaac.empiresmod.init.EmpiresModItems;

import adamisaac.empiresmod.proxy.CommonProxy;

 

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)

public class EmpiresMod {

 

public static final String MODID = "ep";

public static final String MODNAME = "Empires Mod";

public static final String VERSION = "1.0.0";

 

@Instance

public static EmpiresMod instance = new EmpiresMod();

 

 

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

public static final EmpiresModTab tabEmpiresMod = new EmpiresModTab("tabEmpiresMod");

public static EmpiresMod modInstance;

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent e) {

proxy.preInit(e);

 

}

 

    @EventHandler

    public void preLoad(FMLPreInitializationEvent event)

    {

        EmpiresModItems.egyptianBow = new EmpireBow().setUnlocalizedName("egyptianBow");

        GameRegistry.registerItem(EmpiresModItems.egyptianBow, "egyptianBow_standby");

     

    }

   

    @EventHandler

    public void load(FMLInitializationEvent event)

    {

   

   

        if(event.getSide().isClient())

        {

        ModelBakery.addVariantName(EmpiresModItems.egyptianBow, new String[] {"ep:textures/items/egyptianBow_standby.png", "ep:textures/items/egyptianBow_pulling_0.png", "ep:textures/items/egyptianBow_pulling_1.png", "ep:textures/items/egyptianBow_pulling_2.png"});

 

            registerItem(EmpiresModItems.egyptianBow, 0, "ep:textures/items/egyptianBow_standby.png");

            registerItem(EmpiresModItems.egyptianBow, 1, "ep:textures/items/egyptianBow_pulling_0.png");

            registerItem(EmpiresModItems.egyptianBow, 2, "ep:textures/items/egyptianBow_pulling_1.png");

            registerItem(EmpiresModItems.egyptianBow, 3, "ep:textures/items/egyptianBow_pulling_2.png");

        }

    }

 

    @SideOnly(Side.CLIENT)

    public static void registerItem(Item item, int metadata, String itemName)

    {

        ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();

        mesher.register(item, metadata, new ModelResourceLocation(itemName, "inventory"));

    }

// TODO Auto-generated method stub

 

 

 

@EventHandler

public void init(FMLInitializationEvent e) {

EntityCreator.createMob(EntitySpartanSoldier.class, new RenderSpartanSoldier(), "SpartanSoldier", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

EntityCreator.createMob(EntitySamurai.class, new RenderSamurai(), "Samurai", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

proxy.init(e);

 

 

 

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent e) {

proxy.postInit(e);

}

}

 

 

 

 

 

Link to comment
Share on other sites

Remove the events from your proxies.

@EventHandler
   public void preInit(FMLPreInitializationEvent e) {
      proxy.preInit(e);
      
   }

 

What belongs in your proxies is this

if(event.getSide().isClient())
        {
            ModelBakery.addVariantName(EmpiresModItems.egyptianBow, new String[] {"ep:textures/items/egyptianBow_standby.png", "ep:textures/items/egyptianBow_pulling_0.png", "ep:textures/items/egyptianBow_pulling_1.png", "ep:textures/items/egyptianBow_pulling_2.png"});

             registerItem(EmpiresModItems.egyptianBow, 0, "ep:textures/items/egyptianBow_standby.png");
             registerItem(EmpiresModItems.egyptianBow, 1, "ep:textures/items/egyptianBow_pulling_0.png");
             registerItem(EmpiresModItems.egyptianBow, 2, "ep:textures/items/egyptianBow_pulling_1.png");
             registerItem(EmpiresModItems.egyptianBow, 3, "ep:textures/items/egyptianBow_pulling_2.png");
        }

Read a tutorial how and why to use proxies. After thats cleaned up move back to entities

 

Link to comment
Share on other sites

Thank you for your responses, I had already removed the events from my proxy, and okay thank you for the bow section. I am working on this mod with a friend and he created all the proxies/ has a good understanding of them. I got him to clean everything up so now our main class is pretty clean but neither of us know why it is only creating one of the two mobs..

 

Main Class:

 

 

package adamisaac.empiresmod;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.ItemModelMesher;

import net.minecraft.client.resources.model.ModelBakery;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.item.Item;

import net.minecraft.item.Item.ToolMaterial;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraftforge.common.util.EnumHelper;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.Mod.Instance;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import adamisaac.empiresmod.empireEntity.EntitySamurai;

import adamisaac.empiresmod.empireEntity.EntitySpartanSoldier;

import adamisaac.empiresmod.empireRender.RenderSamurai;

import adamisaac.empiresmod.empireRender.RenderSpartanSoldier;

import adamisaac.empiresmod.init.EmpireBow;

import adamisaac.empiresmod.init.EmpiresModItems;

import adamisaac.empiresmod.proxy.CommonProxy;

 

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)

public class EmpiresMod {

 

public static final String MODID = "ep";

public static final String MODNAME = "Empires Mod";

public static final String VERSION = "1.0.0";

 

@Instance

public static EmpiresMod instance = new EmpiresMod();

 

 

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

public static final EmpiresModTab tabEmpiresMod = new EmpiresModTab("tabEmpiresMod");

    //public static EmpiresMod modInstance;

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent e) {

proxy.preInit(e);

 

}

 

 

@EventHandler

public void init(FMLInitializationEvent e) {

 

EntityCreator.createMob(EntitySpartanSoldier.class, new RenderSpartanSoldier(), "SpartanSoldier", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

 

EntityCreator.createMob(EntitySamurai.class, new RenderSamurai(), "Samurai", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

proxy.init(e);

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent e) {

proxy.postInit(e);

}

}

 

 

 

 

EDIT

I fooled around a bit more duplicating the EntityCreator class naming it EntityCreator1 and the method createMob1 to see if there was something wrong with my EntityCreator class, but have discovered that it is in fact just that the code below the first EntitCreator line isnt being read in init...

Here is where I believe the problem is"

 

 

 

@EventHandler

public void init(FMLInitializationEvent e) {

 

EntityCreator.createMob(EntitySpartanSoldier.class, new RenderSpartanSoldier(), "SpartanSoldier", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

 

EntityCreator.createMob(EntitySamurai.class, new RenderSamurai(), "Samurai", EnumCreatureType.MONSTER, 10, 0, 5, new BiomeGenBase[] {BiomeGenBase.desert}, 0xFF00FB, 0xD69D00, true);

proxy.init(e);

 

}

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.