I've started working on a mod over the past couple of days and I've run into some trouble.
I'm using the newest version of Forge.
When I try to add an entity, in this case a new cow, everything works out fine but my cow is invisible! He makes noise and I can hear him walking around but I just cant seem him.
Its using FML not ModLoader. If your using forge you may as well use forge's methods. Plus that code registers the Entity for SSP and SMP.
Also I forgot that you need to register the render information for the entity Just pop this in you ClientProxy file.
RenderingRegistry.registerEntityRenderingHandler(EntitySpaceCow.class, new RenderSpaceCow(new ModelCow, 0.5f));
I'm sorry to ask, but what is the ClientProxy file?
If it's outside of the mod files I created wont it give me incompatibility issues with other FML mods?
Sorry for not explaining that very well. Inside your package for your mod you should have two separate files named CommonProxy.class which is used by your mod for SSP and SMP stuff (gui stuff etc) and a ClientProxy for handling stuff only for the client.
Since this is fairly confusing for beginners, I will give you the relevant code for the Proxy files;
CommonProxy:
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.World;
import cpw.mods.fml.common.network.IGuiHandler;
public class CommonProxy implements IGuiHandler
{
public static void registerRenderInformation()
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
}
ClientProxy
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
public class ClientProxy extends CommonProxy
{
@SideOnly(Side.CLIENT)
public static void registerRenderInformation()
{
RenderingRegistry.registerEntityRenderingHandler(EntitySpaceCow.class, new RenderSpaceCow(new ModelCow, 0.5f));
}
}
Also, inside your mods main file, in the load method (@init) you would add this after adding the proxy class.
ClientProxy.registerRenderInformation();
Feel free to ask me if you have any more questions.
Okay, so what I've done is created two classes: CommonProxy and ClientProxy. I pasted the code in and came up with a couple errors.
Exception in thread "Minecraft main thread" java.lang.Error: Unresolved compilation problems:
Syntax error on token "new", delete this token
ModelCow cannot be resolved to a variable
I really appreciate you helping me and I feel really bad that I have to keep coming back with more problems and questions, but I have no idea what to do here.
//Registers the Space Cow as a Global Animal.
EntityRegistry.registerGlobalEntityID(EntitySpaceCow.class, "Space Cow", ModLoader.getUniqueEntityId());
// Adds a spawn variable.
ModLoader.addSpawn(EntitySpaceCow.class, 100, 5, 10, EnumCreatureType.creature);
public void addRenderer(Map map)
{
map.put(EntitySpaceCow.class, new RenderSpaceCow(new ModelCow(), 12.5F));
}
EntitySpaceCow.java
package net.minecraft.src;
public class EntitySpaceCow extends EntityLiving
{
public EntitySpaceCow(World par1World)
{
super(par1World);
//Defines what texture to use in the source.
texture = "/Slimedog/CosmoCraft/Textures/Creatures/SpaceCow.png";
}
@Override
public int getMaxHealth() {
return 10;
}
protected String getLivingSound()
{
return "mob.cow";
}
protected String getHurtSound()
{
return "mob.cowhurt";
}
protected String getDeathSound()
{
return "mob.cowhurt";
}
protected float getSoundVolume()
{
return 0.4F;
}
//end public class
}
package net.minecraft.src;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
public class ClientProxy extends CommonProxy
{
@SideOnly(Side.CLIENT)
public static void registerRenderInformation()
{
// Tells the client to render the Space Cow?
RenderingRegistry.registerEntityRenderingHandler(EntitySpaceCow.class, new RenderSpaceCow(new ModelCow(), 0.5F));
}
}
CommonProxy.java
package net.minecraft.src;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.World;
import cpw.mods.fml.common.network.IGuiHandler;
public class CommonProxy implements IGuiHandler
{
public static void registerRenderInformation()
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
}
Thanks for all of your suggestions Crunchy, and I appreciate you trying to help.
If anyone else notices what is wrong please post it!
I've had the same problem with my Miku mob. I made her appear when I made EntityMiku extend EntityAnimal instead of EntityLiving. I think that will make your mob appear. Let me know if it does.
Rollback Post to RevisionRollBack
The ending has not yet been written... Atrus | Myst 1 Opening
I've started working on a mod over the past couple of days and I've run into some trouble.
I'm using the newest version of Forge.
When I try to add an entity, in this case a new cow, everything works out fine but my cow is invisible! He makes noise and I can hear him walking around but I just cant seem him.
Here is my code.
My Mod_ File:
EntitySpaceCow.java
RenderSpaceCow.java
I'm sure it's something super simple, but I just can't figure it out...
Thanks for the help!
Follow me on twitter! @dreinsteinium
I replaced my code with that and nothing has changed. What is the difference between that code and mine?
Follow me on twitter! @dreinsteinium
I'm sorry to ask, but what is the ClientProxy file?
If it's outside of the mod files I created wont it give me incompatibility issues with other FML mods?
Follow me on twitter! @dreinsteinium
Okay, so what I've done is created two classes: CommonProxy and ClientProxy. I pasted the code in and came up with a couple errors.
I really appreciate you helping me and I feel really bad that I have to keep coming back with more problems and questions, but I have no idea what to do here.
Follow me on twitter! @dreinsteinium
I changed it to this:
It cleared up all of the errors I was getting but it still hasn't fixed the fact that my cows are invisible lol.
Freakin cows are seeming to be more work then they are really worth lol
Follow me on twitter! @dreinsteinium
mod_File
EntitySpaceCow.java
RenderSpaceCow.java
ClientProxy.java
CommonProxy.java
Thanks for all of your suggestions Crunchy, and I appreciate you trying to help.
If anyone else notices what is wrong please post it!
Follow me on twitter! @dreinsteinium
The model is supposed to be a normal cow
Follow me on twitter! @dreinsteinium
Atrus | Myst 1 Opening