I've currently got my render, model, and entity classes ready for my mob, but I can't seem to spawn it in game with the summon command. It works for vanilla mobs but not mine.
I looked up the issue and I found that I need to do some register entity thing?
How do I "register" my mob, and how can I make my mod know to run this register mob event?
Yeah like any item or block you've made, you need to register them so that they are actually added. Just because you made the classes, MC has no idea they even exist!
Use EntityRegistry.registerModEntity to register an entity, and then on the client side use RenderingRegistry.registerEntityRenderingHandler to register the entity's render.
I've made a ModMobs.java to put all my mobs, and I've basically copied the code from my ModItems.java which has the init thing you mentioned for my items. I've tried changing the code to suit my mob instead of an item, but there are a few issues here and there.
Could you please show me an example of a mobs init and register code?
This goes into ModMobs: It takes an entity class, an entity name (not display name!), the 0 is the id and needs to be different for any of your mobs, your modid. The last to args are the spawn egg colors.
RenderingRegistry.registerEntityRenderingHandler(EntityGargoyle.class, new EntityGargoyleRF());
This goes into the client proxy. It takes the entity class and the render factory class.
I changed the code to suit my mob, but it doesn't work. Both lines are simply giving me a syntax error, but I can't possibly see where they would be. Here's what I put in:
It says: "Syntax error on token "registerEntityRenderingHandler", invalid AnnotationName" from registEntity onwards.
One issue I think is that I don't have a render factory class, and have never heard of one. It is possible that I have the same class with a different name perhaps? Could you explain its function for more clarity.
It is possible that this code applies to a different version of forge?
They do both need to be put inside a method, for the ClientProxy you usually have PreInit / Init /PostInit. For the ModEntities class call the method whatever you want and call it in PreInit of your main class.
That is certainly the problem from the first error,I don't know the second one, but try what I say, it is probably the same issue.
The function of the RenderFactory class is to instantiate the render class for your mob. If I understood it correctly this is necessary because of the order things are loaded.
This is an example:
package anagkai.biodiversity.entities.renderer;
import anagkai.biodiversity.entities.EntityArmadillo;
import anagkai.biodiversity.entities.models.ModelAnteater;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraftforge.fml.client.registry.IRenderFactory;
public class EntityArmadilloRF implements IRenderFactory<EntityArmadillo>{
@Override
public RenderArmadillo createRenderFor(RenderManager manager) {
return new RenderArmadillo(manager, new ModelAnteater(), 0.5F);
}
}
I'm doing 1.10. I think this should still in 1.11, but obviously I can't promise it.
HI there,
I've currently got my render, model, and entity classes ready for my mob, but I can't seem to spawn it in game with the summon command. It works for vanilla mobs but not mine.
I looked up the issue and I found that I need to do some register entity thing?
How do I "register" my mob, and how can I make my mod know to run this register mob event?
Thank you.
Yeah like any item or block you've made, you need to register them so that they are actually added. Just because you made the classes, MC has no idea they even exist!
Use EntityRegistry.registerModEntity to register an entity, and then on the client side use RenderingRegistry.registerEntityRenderingHandler to register the entity's render.
These should be all done in the preInit stage.
I understand.
I've made a ModMobs.java to put all my mobs, and I've basically copied the code from my ModItems.java which has the init thing you mentioned for my items. I've tried changing the code to suit my mob instead of an item, but there are a few issues here and there.
Could you please show me an example of a mobs init and register code?
Thank you.
This goes into ModMobs: It takes an entity class, an entity name (not display name!), the 0 is the id and needs to be different for any of your mobs, your modid. The last to args are the spawn egg colors.
This goes into the client proxy. It takes the entity class and the render factory class.
I changed the code to suit my mob, but it doesn't work. Both lines are simply giving me a syntax error, but I can't possibly see where they would be. Here's what I put in:
Its says: "Syntax error on token(s), misplaced construct(s)" over the whole line.
and
It says: "Syntax error on token "registerEntityRenderingHandler", invalid AnnotationName" from registEntity onwards.
One issue I think is that I don't have a render factory class, and have never heard of one. It is possible that I have the same class with a different name perhaps? Could you explain its function for more clarity.
It is possible that this code applies to a different version of forge?
Thank you.
They do both need to be put inside a method, for the ClientProxy you usually have PreInit / Init /PostInit. For the ModEntities class call the method whatever you want and call it in PreInit of your main class.
That is certainly the problem from the first error,I don't know the second one, but try what I say, it is probably the same issue.
The function of the RenderFactory class is to instantiate the render class for your mob. If I understood it correctly this is necessary because of the order things are loaded.
This is an example:
I'm doing 1.10. I think this should still in 1.11, but obviously I can't promise it.