@SideOnly(Side.CLIENT)
public class RenderPigman extends RenderLiving
{
private static final ResourceLocation Skin = new ResourceLocation(PigmanMod.modid + ":" + "textures/entities/pigman.png");
public RenderPigman(ModelPigman par1ModelBase, float par2)
{
super(par1ModelBase, par2);
I believe you should use when assigning the resource location:
new ResourceLocation(modid, "path.png");
So if your textures are at: source/resources/assets/modid/textures/entities/pigman.png (Like you wrote in the class) you should use:
= new ResourceLocation(modid, "textures/entities/pigman.png");
@SideOnly(Side.CLIENT)
public class RenderPigman extends RenderLiving
{
private static final ResourceLocation Texture = new ResourceLocation(PigmanMod.modid, "textures/entities/pigman.png");
// The texture I want to use is at assets/pigman/textures/entities/pigman.png
// PigmanMod.modid = "pigman"
public RenderPigman(ModelBiped model, float par2)
{
super(model, par2);
The exact path to the pigman texture is /forge-1.6.4-9.11.1.964-src/src/main/java/assets/pigman/textures/entities/pigman.png. I have made blocks, items, armor; and they work just fine though. Why is this not working?
It still does not work. On the bright side, the pigman texture is now at /forge-1.6.4-9.11.1.964-src/src/main/resources/assets/pigman/textures/entities/pigman.png. I also don't see any missing texture error in the console output either. Why? What else could cause the pigman texture not to display?
I have been trying to make eight new mobs, and it sucks that all of them seem to have the same problem. If I can figure out why one is not working, I can probably fix all of them. Here is some more of my code.
My Mod Main Class
public class PigmanMod {
@SidedProxy(clientSide="pigman.ClientProxyClass", serverSide="pigman.MyCommonProxy")
public static MyCommonProxy proxy;
public static final String modid = "pigman";
public static Block BlockCryingObsidian;
public static Block Beam;
public static Block BlockKK;
public static Block BlockRuby;
public static Item NotchHelmet;
public static Item KKHelmet;
public static Item KKChestPlate;
public static Item KKLeggings;
public static Item KKBoots;
public static Item RottonPork;
public static Item KKShard;
public static Item Ruby;
public static int RubyID;
//public static Entity EntityPigman;
//public static Entity EntityHuman;
//public static Entity EntityZombieNew;
//public static Entity EntityZombiePig;
//public static Entity EntityKillerKirby;
//public static Entity EntityNotch;
//public static Entity EntityNewSnowman;
public static int NotchHelmetID;
public static int KKHelmetID;
public static int KKChestplateID;
public static int KKLeggingsID;
public static int KKBootsID;
public static int KKShardID;
public static int RottonPorkID;
public static int BeamID;
public static int BlockCryingObsidianID;
public static int BlockKKID;
public static int BlockRubyID;
public static Item custommonsterplacer;
public static EnumArmorMaterial KKArmor = EnumHelper.addArmorMaterial("KKArmor", 8, new int[] { 3, 7, 6, 3 }, 30);
public static EnumArmorMaterial NotchArmor = EnumHelper.addArmorMaterial("NotchArmor", 8, new int[] { 3, 7, 6, 3 }, 30);
public static CreativeTabs tabCustom = new CreativeTabs("Pigman") {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return (PigmanMod.KKShard);
}
};
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
public class ClientProxyClass extends MyCommonProxy {
public void registerRenderInformation()
{
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public void registerTiles(){
}
public void registerBlocks(){
}
public void registerItems(){
}
public void registerArmor(){
RenderingRegistry.addNewArmourRendererPrefix("KKArmor");
RenderingRegistry.addNewArmourRendererPrefix("NotchArmor");
}
public void registerEntities(){
RenderingRegistry.registerEntityRenderingHandler(EntityPigman.class, new RenderPigman(new ModelBiped(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityNotch.class, new RenderNotch(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityHuman.class, new RenderHuman(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityHerobrine.class, new RenderHerobrine(new ModelHerobrine(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityZombieNew.class, new RenderZombieNew(new ModelBiped(), 0.18F));
RenderingRegistry.registerEntityRenderingHandler(EntityKillerKirby.class, new RenderKillerKirby(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityZombiePig.class, new RenderEntityZombiePig(new ModelPig(), new ModelPig() , 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityNewSnowman.class, new RenderNewSnowman(new ModelSnowManNew(), 0.3F));
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
return null;
}
}
My custom entity list (for usage with my custom mob spawner)
public class CustomEntityList {
/** Provides a mapping between entity classes and a string */
public static Map stringToClassMapping = new HashMap();
/** Provides a mapping between a string and an entity classes */
public static Map classToStringMapping = new HashMap();
/** provides a mapping between an entityID and an Entity Class */
public static Map IDtoClassMapping = new HashMap();
/** provides a mapping between an Entity Class and an entity ID */
private static Map classToIDMapping = new HashMap();
/** Maps entity names to their numeric identifiers */
private static Map stringToIDMapping = new HashMap();
/** This is a HashMap of the Creative Entity Eggs/Spawners. */
public static HashMap entityEggs = new LinkedHashMap();
/**
* adds a mapping between Entity classes and both a string representation and an ID
*/
public static void addMapping(Class par0Class, String par1Str, int par2)
{
stringToClassMapping.put(par1Str, par0Class);
classToStringMapping.put(par0Class, par1Str);
IDtoClassMapping.put(Integer.valueOf(par2), par0Class);
classToIDMapping.put(par0Class, Integer.valueOf(par2));
stringToIDMapping.put(par1Str, Integer.valueOf(par2));
}
/**
* Adds a entity mapping with egg info.
*/
public static void addMapping(Class par0Class, String par1Str, int par2, int par3, int par4)
{
addMapping(par0Class, par1Str, par2);
entityEggs.put(Integer.valueOf(par2), new EntityEggInfo(par2, par3, par4));
}
/**
* Create a new instance of an entity in the world by using the entity name.
*/
public static Entity createEntityByName(String par0Str, World par1World)
{
Entity entity = null;
try
{
Class oclass = (Class)stringToClassMapping.get(par0Str);
if (entity != null)
{
try
{
entity.readFromNBT(par0NBTTagCompound);
}
catch (Exception e)
{
FMLLog.log(Level.SEVERE, e,
"An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
par0NBTTagCompound.getString("id"), oclass.getName());
entity = null;
}
}
else
{
par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0NBTTagCompound.getString("id"));
}
return entity;
}
/**
* Create a new instance of an entity in the world by using an entity ID.
*/
public static Entity createEntityByID(int par0, World par1World)
{
Entity entity = null;
if (entity == null)
{
par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0);
}
return entity;
}
/**
* gets the entityID of a specific entity
*/
public static int getEntityID(Entity par0Entity)
{
Class oclass = par0Entity.getClass();
return classToIDMapping.containsKey(oclass) ? ((Integer)classToIDMapping.get(oclass)).intValue() : 0;
}
/**
* Return the class assigned to this entity ID.
*/
public static Class getClassFromID(int par0)
{
return (Class)IDtoClassMapping.get(Integer.valueOf(par0));
}
/**
* Gets the string representation of a specific entity.
*/
public static String getEntityString(Entity par0Entity)
{
return (String)classToStringMapping.get(par0Entity.getClass());
}
public static String getStringFromID(int par0)
{
Class oclass = getClassFromID(par0);
return oclass != null ? (String)classToStringMapping.get(oclass) : null;
}
The common proxy contains the void method "registerRenderers". Since it is extending it, I believe all methods listed in the client proxy will be able to activated in one go.
My common proxy
package pigman;
public class MyCommonProxy {
public void registerRenderers()
{
}
}
The custom mob spawner (used to create the spawn eggs) Also my custom entity list is to provide the necessary mobs to create spawn eggs for.
if (entity != null)
{
if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName());
}
if (!par2EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
}
return true;
}
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par2World.isRemote)
{
return par1ItemStack;
}
else
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
if (movingobjectposition == null)
{
return par1ItemStack;
}
else
{
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
{
return par1ItemStack;
}
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
{
return par1ItemStack;
}
package pigman.render;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import pigman.PigmanMod;
import pigman.entities.EntityPigman;
import pigman.entities.ModelPigman;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.util.ResourceLocation;
@SideOnly(Side.CLIENT)
public class RenderPigman extends RenderLiving
{
private static final ResourceLocation Skin = new ResourceLocation(PigmanMod.modid + ":" + "textures/entities/pigman.png");
public RenderPigman(ModelPigman par1ModelBase, float par2)
{
super(par1ModelBase, par2);
}
public void renderPlayer(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6,
float par8, float par9)
{
doRender((EntityPigman)par1EntityLivingBase, par2, par4, par6, par8, par9);
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.doRender((EntityPigman)par1Entity, par2, par4, par6, par8, par9);
}
@Override
protected void bindEntityTexture(Entity par1Entity) {
}
protected ResourceLocation getEntityTexture(Entity par1Entity) {
this.bindTexture(Skin);
return Skin;
}
}
new ResourceLocation(modid, "path.png");
So if your textures are at: source/resources/assets/modid/textures/entities/pigman.png (Like you wrote in the class) you should use:
= new ResourceLocation(modid, "textures/entities/pigman.png");
Good luck!
And don't do bindTexture(Skin).
package pigman.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import pigman.PigmanMod;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
@SideOnly(Side.CLIENT)
public class RenderPigman extends RenderLiving
{
private static final ResourceLocation Texture = new ResourceLocation(PigmanMod.modid, "textures/entities/pigman.png");
// The texture I want to use is at assets/pigman/textures/entities/pigman.png
// PigmanMod.modid = "pigman"
public RenderPigman(ModelBiped model, float par2)
{
super(model, par2);
}
protected ResourceLocation getEntityTexture(Entity par1Entity) {
return Texture;
}
}
Just move your assets folder in /src/main/resources, and you should be fine.
My Mod Main Class
package pigman;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.EnumHelper;
import pigman.blocks.*;
import pigman.items.*;
import pigman.entities.*;
import pigman.render.*;
import net.minecraft.world.World;
@Mod(modid=PigmanMod.modid,name = "Pigman",version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class PigmanMod {
@SidedProxy(clientSide="pigman.ClientProxyClass", serverSide="pigman.MyCommonProxy")
public static MyCommonProxy proxy;
public static final String modid = "pigman";
public static Block BlockCryingObsidian;
public static Block Beam;
public static Block BlockKK;
public static Block BlockRuby;
public static Item NotchHelmet;
public static Item KKHelmet;
public static Item KKChestPlate;
public static Item KKLeggings;
public static Item KKBoots;
public static Item RottonPork;
public static Item KKShard;
public static Item Ruby;
public static int RubyID;
//public static Entity EntityPigman;
//public static Entity EntityHuman;
//public static Entity EntityZombieNew;
//public static Entity EntityZombiePig;
//public static Entity EntityKillerKirby;
//public static Entity EntityNotch;
//public static Entity EntityNewSnowman;
public static int NotchHelmetID;
public static int KKHelmetID;
public static int KKChestplateID;
public static int KKLeggingsID;
public static int KKBootsID;
public static int KKShardID;
public static int RottonPorkID;
public static int BeamID;
public static int BlockCryingObsidianID;
public static int BlockKKID;
public static int BlockRubyID;
public static Item custommonsterplacer;
public static EnumArmorMaterial KKArmor = EnumHelper.addArmorMaterial("KKArmor", 8, new int[] { 3, 7, 6, 3 }, 30);
public static EnumArmorMaterial NotchArmor = EnumHelper.addArmorMaterial("NotchArmor", 8, new int[] { 3, 7, 6, 3 }, 30);
public static CreativeTabs tabCustom = new CreativeTabs("Pigman") {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return (PigmanMod.KKShard);
}
};
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
BeamID = config.getBlock("Beam",823).getInt();
BlockCryingObsidianID = config.getBlock("Crying Obsidian",810).getInt();
BlockRubyID = config.getBlock("Ruby Block",810).getInt();
BlockKKID = config.getBlock("KK Block",812).getInt();
NotchHelmetID = config.getItem("Notch Mask",750).getInt();
KKHelmetID = config.getItem("KK Helmet", 501).getInt();
KKChestplateID = config.getItem("KK Chestplate", 502).getInt();
KKLeggingsID = config.getItem("KK Leggings", 503).getInt();
KKBootsID = config.getItem("KK Boots", 504).getInt();
KKShardID = config.getItem("KK Shard", 505).getInt();
RubyID = config.getItem("Ruby", 506).getInt();
RottonPorkID = config.getItem("Rotten Pork", 820).getInt();
config.save();
}
@EventHandler
public void load(FMLInitializationEvent event)
{
proxy.registerRenderers();
KKHelmet = new KKArmor(2055, KKArmor, 0, 0).setUnlocalizedName("KKHelmet");
KKChestPlate = new KKArmor(2056, KKArmor, 0, 1).setUnlocalizedName("KKChestPlate");
KKLeggings = new KKArmor(2057, KKArmor, 0, 2).setUnlocalizedName("KKLeggings");
KKBoots = new KKArmor(2058, KKArmor, 0, 3).setUnlocalizedName("KKBoots");
BlockCryingObsidian = new BlockCryingObsidian(BlockCryingObsidianID, Material.rock).setUnlocalizedName("CryingObsidian");
Beam = new Beam(BeamID, Material.iron).setUnlocalizedName("Beam");
BlockKK = new BlockKK(BlockKKID, Material.iron).setUnlocalizedName("KKBlock");
BlockRuby= new BlockRuby(BlockRubyID, Material.iron).setUnlocalizedName("RubyBlock");
NotchHelmet = new NotchArmor(2059, NotchArmor, 0, 0).setUnlocalizedName("NotchHelmet");
KKShard = new KKShard(KKShardID).setUnlocalizedName("KKShard");
Ruby = new Ruby(RubyID).setUnlocalizedName("Ruby");
custommonsterplacer = new CustomMonsterPlacer(8001).setTextureName("pigman:custommonsterplacer").setUnlocalizedName("custommonsterplacer").setCreativeTab(tabCustom);
RottonPork = new RottonPork(RottonPorkID).setUnlocalizedName("RottonPork");
EntityRegistry.registerModEntity(EntityPigman.class, "Pigman", 1, this, 401, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityNotch.class, "Notch", 1, this, 402, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityZombiePig.class, "Zombie Pig",1, this, 400, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityHuman.class, "Human", 1, this, 403, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityNewSnowman.class, "Snowman", 1, this, 404, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityKillerKirby.class, "KillerKirby", 1, this, 405, 3, true);
EntityRegistry.addSpawn(pigman.entities.EntityPigman.class, 15, 2, 4, EnumCreatureType.creature, BiomeGenBase.plains);
EntityRegistry.addSpawn(pigman.entities.EntityHuman.class, 18, 2, 4, EnumCreatureType.creature,BiomeGenBase.plains);
EntityRegistry.addSpawn(pigman.entities.EntityZombiePig.class, 16, 2, 4, EnumCreatureType.monster,BiomeGenBase.plains);
EntityRegistry.addSpawn(pigman.entities.EntityNewSnowman.class, 17, 2, 4, EnumCreatureType.monster,BiomeGenBase.taiga);
EntityRegistry.addSpawn(pigman.entities.EntityKillerKirby.class, 19, 2, 4, EnumCreatureType.monster,BiomeGenBase.plains);
PigmanRecipes.addRecipes();
LanguageRegistry.addName(KKShard, "KK Shard");
LanguageRegistry.addName(KKHelmet, "KK Helmet");
LanguageRegistry.addName(KKChestPlate, "KK Chestplate");
LanguageRegistry.addName(KKLeggings, "KK Leggings");
LanguageRegistry.addName(RottonPork, "Rotten Pork");
LanguageRegistry.addName(KKBoots, "KK Boots");
LanguageRegistry.addName(custommonsterplacer, "Spawn");
LanguageRegistry.addName(NotchHelmet, "Notch Mask");
LanguageRegistry.addName(Ruby, "Ruby");
LanguageRegistry.instance().addStringLocalization("entity.Pigman.name","Pigman");
LanguageRegistry.instance().addStringLocalization("entity.ZombiePig.name","Zombie Pig");
LanguageRegistry.instance().addStringLocalization("entity.Notch.name","Notch");
LanguageRegistry.instance().addStringLocalization("entity.Human.name","Human");
LanguageRegistry.instance().addStringLocalization("entity.Snowman.name","Snowman");
LanguageRegistry.instance().addStringLocalization("entity.KillerKirby.name","KillerKirby");
GameRegistry.registerBlock(BlockCryingObsidian, modid + BlockCryingObsidian.getUnlocalizedName().substring(5));
GameRegistry.registerBlock(Beam, modid + Beam.getUnlocalizedName().substring(5));
GameRegistry.registerBlock(BlockRuby, modid + BlockRuby.getUnlocalizedName().substring(5));
GameRegistry.registerBlock(BlockKK, modid + BlockKK.getUnlocalizedName().substring(5));
LanguageRegistry.addName(BlockCryingObsidian, "Crying Obsidian");
LanguageRegistry.addName(Beam, "Beam");
LanguageRegistry.addName(BlockKK, "KK Block");
LanguageRegistry.addName(BlockRuby, "Block of Ruby");
}
}
My Client Proxy
package pigman;
import pigman.entities.EntityHerobrine;
import pigman.entities.EntityHuman;
import pigman.entities.EntityKillerKirby;
import pigman.entities.EntityNewSnowman;
import pigman.entities.EntityNotch;
import pigman.entities.EntityPigman;
import pigman.entities.EntityZombieNew;
import pigman.entities.EntityZombiePig;
import pigman.entities.ModelHerobrine;
import pigman.entities.ModelSnowManNew;
import pigman.render.RenderEntityZombiePig;
import pigman.render.RenderHerobrine;
import pigman.render.RenderHuman;
import pigman.render.RenderKillerKirby;
import pigman.render.RenderNewSnowman;
import pigman.render.RenderNotch;
import pigman.render.RenderPigman;
import pigman.render.RenderZombieNew;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class ClientProxyClass extends MyCommonProxy {
public void registerRenderInformation()
{
}
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public void registerTiles(){
}
public void registerBlocks(){
}
public void registerItems(){
}
public void registerArmor(){
RenderingRegistry.addNewArmourRendererPrefix("KKArmor");
RenderingRegistry.addNewArmourRendererPrefix("NotchArmor");
}
public void registerEntities(){
RenderingRegistry.registerEntityRenderingHandler(EntityPigman.class, new RenderPigman(new ModelBiped(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityNotch.class, new RenderNotch(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityHuman.class, new RenderHuman(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityHerobrine.class, new RenderHerobrine(new ModelHerobrine(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityZombieNew.class, new RenderZombieNew(new ModelBiped(), 0.18F));
RenderingRegistry.registerEntityRenderingHandler(EntityKillerKirby.class, new RenderKillerKirby(new ModelBiped(), 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityZombiePig.class, new RenderEntityZombiePig(new ModelPig(), new ModelPig() , 0.3F));
RenderingRegistry.registerEntityRenderingHandler(EntityNewSnowman.class, new RenderNewSnowman(new ModelSnowManNew(), 0.3F));
}
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
return null;
}
}
My custom entity list (for usage with my custom mob spawner)
package pigman.entities;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import pigman.PigmanMod;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityLeashKnot;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityMinecartMobSpawner;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityEnderEye;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.item.EntityExpBottle;
import net.minecraft.entity.item.EntityFallingSand;
import net.minecraft.entity.item.EntityFireworkRocket;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecartChest;
import net.minecraft.entity.item.EntityMinecartEmpty;
import net.minecraft.entity.item.EntityMinecartFurnace;
import net.minecraft.entity.item.EntityMinecartHopper;
import net.minecraft.entity.item.EntityMinecartTNT;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityGiantZombie;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMagmaCube;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.entity.projectile.EntityWitherSkull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLLog;
public class CustomEntityList {
/** Provides a mapping between entity classes and a string */
public static Map stringToClassMapping = new HashMap();
/** Provides a mapping between a string and an entity classes */
public static Map classToStringMapping = new HashMap();
/** provides a mapping between an entityID and an Entity Class */
public static Map IDtoClassMapping = new HashMap();
/** provides a mapping between an Entity Class and an entity ID */
private static Map classToIDMapping = new HashMap();
/** Maps entity names to their numeric identifiers */
private static Map stringToIDMapping = new HashMap();
/** This is a HashMap of the Creative Entity Eggs/Spawners. */
public static HashMap entityEggs = new LinkedHashMap();
/**
* adds a mapping between Entity classes and both a string representation and an ID
*/
public static void addMapping(Class par0Class, String par1Str, int par2)
{
stringToClassMapping.put(par1Str, par0Class);
classToStringMapping.put(par0Class, par1Str);
IDtoClassMapping.put(Integer.valueOf(par2), par0Class);
classToIDMapping.put(par0Class, Integer.valueOf(par2));
stringToIDMapping.put(par1Str, Integer.valueOf(par2));
}
/**
* Adds a entity mapping with egg info.
*/
public static void addMapping(Class par0Class, String par1Str, int par2, int par3, int par4)
{
addMapping(par0Class, par1Str, par2);
entityEggs.put(Integer.valueOf(par2), new EntityEggInfo(par2, par3, par4));
}
/**
* Create a new instance of an entity in the world by using the entity name.
*/
public static Entity createEntityByName(String par0Str, World par1World)
{
Entity entity = null;
try
{
Class oclass = (Class)stringToClassMapping.get(par0Str);
if (oclass != null)
{
entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
return entity;
}
public static Entity createEntityFromNBT(NBTTagCompound par0NBTTagCompound, World par1World)
{
Entity entity = null;
if ("Minecart".equals(par0NBTTagCompound.getString("id")))
{
switch (par0NBTTagCompound.getInteger("Type"))
{
case 0:
par0NBTTagCompound.setString("id", "MinecartRideable");
break;
case 1:
par0NBTTagCompound.setString("id", "MinecartChest");
break;
case 2:
par0NBTTagCompound.setString("id", "MinecartFurnace");
}
par0NBTTagCompound.removeTag("Type");
}
Class oclass = null;
try
{
oclass = (Class)stringToClassMapping.get(par0NBTTagCompound.getString("id"));
if (oclass != null)
{
entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
if (entity != null)
{
try
{
entity.readFromNBT(par0NBTTagCompound);
}
catch (Exception e)
{
FMLLog.log(Level.SEVERE, e,
"An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
par0NBTTagCompound.getString("id"), oclass.getName());
entity = null;
}
}
else
{
par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0NBTTagCompound.getString("id"));
}
return entity;
}
/**
* Create a new instance of an entity in the world by using an entity ID.
*/
public static Entity createEntityByID(int par0, World par1World)
{
Entity entity = null;
try
{
Class oclass = getClassFromID(par0);
if (oclass != null)
{
entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
if (entity == null)
{
par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0);
}
return entity;
}
/**
* gets the entityID of a specific entity
*/
public static int getEntityID(Entity par0Entity)
{
Class oclass = par0Entity.getClass();
return classToIDMapping.containsKey(oclass) ? ((Integer)classToIDMapping.get(oclass)).intValue() : 0;
}
/**
* Return the class assigned to this entity ID.
*/
public static Class getClassFromID(int par0)
{
return (Class)IDtoClassMapping.get(Integer.valueOf(par0));
}
/**
* Gets the string representation of a specific entity.
*/
public static String getEntityString(Entity par0Entity)
{
return (String)classToStringMapping.get(par0Entity.getClass());
}
public static String getStringFromID(int par0)
{
Class oclass = getClassFromID(par0);
return oclass != null ? (String)classToStringMapping.get(oclass) : null;
}
static
{
addMapping(EntityItem.class, "Item", 1);
addMapping(EntityLiving.class, "Mob", 48);
addMapping(EntityMob.class, "Monster", 49);
addMapping(EntityGiantZombie.class, "Giant", 53, 44975, 7969893);
addMapping(EntityKillerKirby.class, "KillerKirby", 405, 44975, 7969893);
addMapping(EntityPigman.class, "Pigman", 401,15771042 , 14377823);
addMapping(EntityZombiePig.class, "ZombiePig", 400, 15373203, 5009705);
addMapping(EntityNotch.class, "Notch", 402, 15720061, 5653556);
addMapping(EntityHuman.class, "Human", 403, 15720061, 5653556);
addMapping(EntityNewSnowman.class, "Snowman", 404, 2243405, 7375001);
addMapping(EntityDragon.class, "EnderDragon", 63,1447446, 0);
}
}
Also
EntityRegistry.registerModEntity(EntityPigman.class, "Pigman", 1, this, 401, 3, true);
EntityRegistry.registerModEntity(pigman.entities.EntityNotch.class, "Notch", 1, this, 402, 3, true);
You need to set different ids.
And your CustomEntityList is just a pointless copy of EntityList.
My common proxy
public class MyCommonProxy {
public void registerRenderers()
{
}
}
The custom mob spawner (used to create the spawn eggs) Also my custom entity list is to provide the necessary mobs to create spawn eggs for.
import java.util.Iterator;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import pigman.PigmanMod;
import pigman.entities.CustomEntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.Facing;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class CustomMonsterPlacer extends Item {
@SideOnly(Side.CLIENT)
private Icon theIcon;
public CustomMonsterPlacer(int par1)
{
super(par1);
this.setHasSubtypes(true);
this.setCreativeTab(PigmanMod.tabCustom);
}
public String getItemDisplayName(ItemStack par1ItemStack)
{
String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
String s1 = CustomEntityList.getStringFromID(par1ItemStack.getItemDamage());
if (s1 != null)
{
s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name");
}
return s;
}
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
{
EntityEggInfo entityegginfo = (EntityEggInfo)CustomEntityList.entityEggs.get(Integer.valueOf(par1ItemStack.getItemDamage()));
return entityegginfo != null ? (par2 == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215;
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par3World.isRemote)
{
return true;
}
else
{
int i1 = par3World.getBlockId(par4, par5, par6);
par4 += Facing.offsetsXForSide[par7];
par5 += Facing.offsetsYForSide[par7];
par6 += Facing.offsetsZForSide[par7];
double d0 = 0.0D;
if (par7 == 1 && Block.blocksList[i1] != null && Block.blocksList[i1].getRenderType() == 11)
{
d0 = 0.5D;
}
Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), (double)par4 + 0.5D, (double)par5 + d0, (double)par6 + 0.5D);
if (entity != null)
{
if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName());
}
if (!par2EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
}
return true;
}
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par2World.isRemote)
{
return par1ItemStack;
}
else
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
if (movingobjectposition == null)
{
return par1ItemStack;
}
else
{
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
{
return par1ItemStack;
}
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
{
return par1ItemStack;
}
if (par2World.getBlockMaterial(i, j, k) == Material.water)
{
Entity entity = spawnCreature(par2World, par1ItemStack.getItemDamage(), (double)i, (double)j, (double)k);
if (entity != null)
{
if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName());
}
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
}
}
}
return par1ItemStack;
}
}
}
public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6)
{
if (!CustomEntityList.entityEggs.containsKey(Integer.valueOf(par1)))
{
return null;
}
else
{
Entity entity = null;
for (int j = 0; j < 1; ++j)
{
entity = CustomEntityList.createEntityByID(par1, par0World);
if (entity != null && entity instanceof EntityLivingBase)
{
EntityLiving entityliving = (EntityLiving)entity;
entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
entityliving.onSpawnWithEgg((EntityLivingData)null);
par0World.spawnEntityInWorld(entity);
entityliving.playLivingSound();
}
}
return entity;
}
}
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
return true;
}
@SideOnly(Side.CLIENT)
public Icon getIconFromDamageForRenderPass(int par1, int par2)
{
return par2 > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(par1, par2);
}
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
Iterator iterator = CustomEntityList.entityEggs.values().iterator();
while (iterator.hasNext())
{
EntityEggInfo entityegginfo = (EntityEggInfo)iterator.next();
par3List.add(new ItemStack(par1, 1, entityegginfo.spawnedID));
}
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
super.registerIcons(par1IconRegister);
this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_overlay");
}
}
Thanks for pointing out the id issues. I will take care of that.