Hi, I'm new to modding, been learning for a few months, and i've made a semi-successful mod. But i want to go the next step and add Mobs and entities, since i've only been dealing with basic armor, weapons, tools, items, crafting recipes, the works. But i have almost no idea where to start when it comes to adding a mob. I've delved into some of minecraft's code to see how entities 'work' but haven't been able to find anything solid enough that i can understand. I can't find any reliable forge-based tutorials for adding mobs either.
Any help would be appreciated, i'm really just looking for a way to add a simple mob or monster to the game that attacks players. Real basic stuff.
Things i know: 0%. i'm a genuis.
Things i want to know:
Best modeler for models (i'm currently using Tabula for 1.8)
How to render Entity models
How to add simple mobs
steps i need to take to add said mod to code
how to use this. statements for task's and whatnot.
What changed for mobs in-between 1.7.10 and 1.8 (are they rendered and dealt with the same way, or was the code re-written like blocks?)
1. Tabula is a good modeler, if you're familiar with it, continue to use it. Minecraft supports many file formats.
2. Entities need an entity class that defines what this entity does etc. (look here for an example) and they need a render class for rendering (look here) and a model class (here).
3. entities need to be registered by mapping the entity class to the renderer during the initialization event of your mod (example here).
Hi, I'm new to modding, been learning for a few months, and i've made a semi-successful mod. But i want to go the next step and add Mobs and entities, since i've only been dealing with basic armor, weapons, tools, items, crafting recipes, the works. But i have almost no idea where to start when it comes to adding a mob. I've delved into some of minecraft's code to see how entities 'work' but haven't been able to find anything solid enough that i can understand. I can't find any reliable forge-based tutorials for adding mobs either.
Any help would be appreciated, i'm really just looking for a way to add a simple mob or monster to the game that attacks players. Real basic stuff.
Things i know: 0%. i'm a genuis.
Things i want to know:
Best modeler for models (i'm currently using Tabula for 1.8)
How to render Entity models
How to add simple mobs
steps i need to take to add said mod to code
how to use this. statements for task's and whatnot.
What changed for mobs in-between 1.7.10 and 1.8 (are they rendered and dealt with the same way, or was the code re-written like blocks?)
Very little changed for rendering mobs in-between 1.7.10 and 1.8.x. A few methods were renamed in the Entity classes -- for example, onSpawnWithEgg was finally renamed to onInitialSpawn.
The easiest way to make a mob is to extend the most similar mob. If you have a zombie-like creature (even if it does not have a zombie model), extend EntityZombie. Once you have figured out the basics of customizing an already-coded mob, you can back up a bit to make your custom behavior. By this I mean that if you have a mob, instead of extending EntityZombie, you extend EntityCreature and implement IMob.
For a complicated example of how this works (but good examples of adding EntityAI tasks and such) you can look at my GolemBase class and its children classes. For custom behavior, you will almost always use either an EntityAI or do something in onLivingUpdate. For example, one golem uses onLivingUpdate to freeze water blocks nearby. Another overrides attackEntityAsMob to give a potion effect to the target entity.
A quick note on overriding methods like these: always, always, always call the super method. Otherwise your mob may skip important code that is buried in EntityLivingBase or some other base class.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
1. Tabula is a good modeler, if you're familiar with it, continue to use it. Minecraft supports many file formats.
2. Entities need an entity class that defines what this entity does etc. (look here for an example) and they need a render class for rendering (look here) and a model class (here).
3. entities need to be registered by mapping the entity class to the renderer during the initialization event of your mod (example here).
Very little changed for rendering mobs in-between 1.7.10 and 1.8.x. A few methods were renamed in the Entity classes -- for example, onSpawnWithEgg was finally renamed to onInitialSpawn.
The easiest way to make a mob is to extend the most similar mob. If you have a zombie-like creature (even if it does not have a zombie model), extend EntityZombie. Once you have figured out the basics of customizing an already-coded mob, you can back up a bit to make your custom behavior. By this I mean that if you have a mob, instead of extending EntityZombie, you extend EntityCreature and implement IMob.
For a complicated example of how this works (but good examples of adding EntityAI tasks and such) you can look at my GolemBase class and its children classes. For custom behavior, you will almost always use either an EntityAI or do something in onLivingUpdate. For example, one golem uses onLivingUpdate to freeze water blocks nearby. Another overrides attackEntityAsMob to give a potion effect to the target entity.
A quick note on overriding methods like these: always, always, always call the super method. Otherwise your mob may skip important code that is buried in EntityLivingBase or some other base class.
Wow Thanks! This is some really helpful information! I'll be sure to check up on all the examples whenever i get a snag. This was much more help than i could have hoped for!
I thought i had it. i really did. xD but i'm stuck at, well, adding my mob i guess. I have it's Class, Render, and model classes, but how do i register it? Sorry for being a bit slow and noob-ish, but truth be told i am a noob. I'm really just wing'in this whole Java thing xD
If you could provide more detailed instructions about the proper steps to take that would help allot, or even better point me in the direction of a completed tutorial for adding mobs (i haven't really found any good ones). I check up you're code allot but i couldn't really wrap my head around it all Dx
You will use that instance in your call to register the entity, which I have here.
Look at the registration for the most similar entity to your own in order to decide what arguments to give it. The args include render-distance and update frequency.
Edit: fixed links after a git commit that changed a package name
Been awhile, i've been working on some other things.
I just checked up on you're references and examples now and it looks like both you github links are 404: Page not found errors. Hopefully Jabelar's tutorials are enough for me until you fix those Thanks again
Been awhile, i've been working on some other things.
I just checked up on you're references and examples now and it looks like both you github links are 404: Page not found errors. Hopefully Jabelar's tutorials are enough for me until you fix those Thanks again
Yeah, if you looked above he had an 'EDIT' that explained he fixed the links. i had chked them before that and they were broke. basically right after he fixed them i posted that
Anyways back to my problems because they never end.
I'm still horribly stuck on registering my mob. I'm 99% sure that i did the mob class, render class, and everything correct, EXCEPT the registering of the mob using EntityRegister.registerModEntity, anytime i try and use this i crash. Where should i have this exactly? I've tried in my PreInit (i think, or Init) section of my Client proxies, but i dunno if i should put it in my Main class or somewhere else. There's something terribly obvious i'm missing... isn't there?
Yeah, if you looked above he had an 'EDIT' that explained he fixed the links. i had chked them before that and they were broke. basically right after he fixed them i posted that
Anyways back to my problems because they never end.
I'm still horribly stuck on registering my mob. I'm 99% sure that i did the mob class, render class, and everything correct, EXCEPT the registering of the mob using EntityRegister.registerModEntity, anytime i try and use this i crash. Where should i have this exactly? I've tried in my PreInit (i think, or Init) section of my Client proxies, but i dunno if i should put it in my Main class or somewhere else. There's something terribly obvious i'm missing... isn't there?
Entity registering is done from preInit, yes. I have a separate class for registering just because I have a lot of entities. Registering the rendering for the entities, by the way, is also done from preInit. You can look at my ClientProxy to see how I do that.
Post the exact code you are using to register your entities -- I can't help much if all I suggest are things you've already tried.
You should have a static int variable that increases every time you register an entity so that they all have different IDs. You should also have a public static instance of your mod container (the file that has @Mod)
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
That's the problem at the moment actually. I don't have any code to register my entities. it seems every example i look at is different.
So far the problem with using your mod's example is that, well i can't make any sense of all the extra helper functions and other classes and... oi. It's hard simply because, i have no idea what i'm doing. like, at all. So, i think i'll just wait on this whole thing. My project can go on without mobs for the time being, but i'll have to figure this all out eventually.
That's the problem at the moment actually. I don't have any code to register my entities. it seems every example i look at is different.
So far the problem with using your mod's example is that, well i can't make any sense of all the extra helper functions and other classes and... oi. It's hard simply because, i have no idea what i'm doing. like, at all. So, i think i'll just wait on this whole thing. My project can go on without mobs for the time being, but i'll have to figure this all out eventually.
I use this (some parts are deprecated, yes, but it still works so I keep using it)
public static final void createEntity(Class<? extends Entity> entityClass, Render<?> render, String entityName, EnumCreatureType creature, int spawnChance, int minSpawn, int maxSpawn, BiomeGenBase[] biomes, int primaryColor, int secondaryColor)
{
int id = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
EntityRegistry.addSpawn(entityName, spawnChance, minSpawn, maxSpawn, creature, biomes);
EntityRegistry.registerModEntity(entityClass, entityName, id, ShadowCreaturesMod.instance, 32, 7, true, primaryColor, secondaryColor);
RenderingRegistry.registerEntityRenderingHandler(entityClass, render);
}
Well that's fine and dandy, but won't using the EntityRegistery method cause a potential issue when using other mods that cause the entity ID pool to fill up? Orespawn and Superheros unlimited, along with some other big mods, use this method, and it ends up crashing when too many ID's are registered like this. Unless this is a different method and i'm just ranting about nothing relevant.
Well that's fine and dandy, but won't using the EntityRegistery method cause a potential issue when using other mods that cause the entity ID pool to fill up? Orespawn and Superheros unlimited, along with some other big mods, use this method, and it ends up crashing when too many ID's are registered like this. Unless this is a different method and i'm just ranting about nothing relevant.
If the ID pool is full, there's no way besides redefining the bytesize of an integer to solve taht problem.
Well that's fine and dandy, but won't using the EntityRegistery method cause a potential issue when using other mods that cause the entity ID pool to fill up? Orespawn and Superheros unlimited, along with some other big mods, use this method, and it ends up crashing when too many ID's are registered like this. Unless this is a different method and i'm just ranting about nothing relevant.
This is correct. Don't use UpcraftLP's method to start with or you will get in the habit of using it.
Specifically, this line is a problem:
int id = EntityRegistry.findGlobalUniqueEntityId(); // limited to 255
Since it is deprecated, UpcraftLP, it's time to move on. Please don't encourage beginners to use deprecated methods even if they automatically create a spawn egg for you.
I've heard that as of 1.8.9 and 1.9 you can add two hex color arguments to the EntityRegistry.registerModEntity method in order to have it make a spawn egg for you. Haven't tried it out yet, but it's worth a shot.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
This is correct. Don't use UpcraftLP's method to start with or you will get in the habit of using it.
Specifically, this line is a problem:
int id = EntityRegistry.findGlobalUniqueEntityId(); // limited to 255
Since it is deprecated, UpcraftLP, it's time to move on. Please don't encourage beginners to use deprecated methods even if they automatically create a spawn egg for you.
I've heard that as of 1.8.9 and 1.9 you can add two hex color arguments to the EntityRegistry.registerModEntity method in order to have it make a spawn egg for you. Haven't tried it out yet, but it's worth a shot.
Yeah, this is true, you can add a specific method to generate spawn-eggs like the deprecated method. I would know how to do it, if i could use the ModEntity method in the first place xD
Yeah, this is true, you can add a specific method to generate spawn-eggs like the deprecated method. I would know how to do it, if i could use the ModEntity method in the first place xD
What's hard about calling that method? It's not too complex Java syntax. Without a helper method, you just do this from preInit:
48 here is the render distance. 3 is the frequency of updates. true is whether to send velocity updates (for fast moving entities, I guess). Look at the javadocs for that method for details.
The numEntitiesRegistered part is slightly more complicated, but do you really want to hard-code an ID for every entity you register?
I've already described what the instance is and how to make it.
What questions do you possibly have?
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Hi, I'm new to modding, been learning for a few months, and i've made a semi-successful mod. But i want to go the next step and add Mobs and entities, since i've only been dealing with basic armor, weapons, tools, items, crafting recipes, the works. But i have almost no idea where to start when it comes to adding a mob. I've delved into some of minecraft's code to see how entities 'work' but haven't been able to find anything solid enough that i can understand. I can't find any reliable forge-based tutorials for adding mobs either.
Any help would be appreciated, i'm really just looking for a way to add a simple mob or monster to the game that attacks players. Real basic stuff.
Things i know: 0%. i'm a genuis.
Things i want to know:
Best modeler for models (i'm currently using Tabula for 1.8)
How to render Entity models
How to add simple mobs
steps i need to take to add said mod to code
how to use this. statements for task's and whatnot.
What changed for mobs in-between 1.7.10 and 1.8 (are they rendered and dealt with the same way, or was the code re-written like blocks?)
1. Tabula is a good modeler, if you're familiar with it, continue to use it. Minecraft supports many file formats.
2. Entities need an entity class that defines what this entity does etc. (look here for an example) and they need a render class for rendering (look here) and a model class (here).
3. entities need to be registered by mapping the entity class to the renderer during the initialization event of your mod (example here).
Very little changed for rendering mobs in-between 1.7.10 and 1.8.x. A few methods were renamed in the Entity classes -- for example, onSpawnWithEgg was finally renamed to onInitialSpawn.
The easiest way to make a mob is to extend the most similar mob. If you have a zombie-like creature (even if it does not have a zombie model), extend EntityZombie. Once you have figured out the basics of customizing an already-coded mob, you can back up a bit to make your custom behavior. By this I mean that if you have a mob, instead of extending EntityZombie, you extend EntityCreature and implement IMob.
For a complicated example of how this works (but good examples of adding EntityAI tasks and such) you can look at my GolemBase class and its children classes. For custom behavior, you will almost always use either an EntityAI or do something in onLivingUpdate. For example, one golem uses onLivingUpdate to freeze water blocks nearby. Another overrides attackEntityAsMob to give a potion effect to the target entity.
A quick note on overriding methods like these: always, always, always call the super method. Otherwise your mob may skip important code that is buried in EntityLivingBase or some other base class.
Wow Thanks! This is some really helpful information! I'll be sure to check up on all the examples whenever i get a snag. This was much more help than i could have hoped for!
I thought i had it. i really did. xD but i'm stuck at, well, adding my mob i guess. I have it's Class, Render, and model classes, but how do i register it? Sorry for being a bit slow and noob-ish, but truth be told i am a noob. I'm really just wing'in this whole Java thing xD
If you could provide more detailed instructions about the proper steps to take that would help allot, or even better point me in the direction of a completed tutorial for adding mobs (i haven't really found any good ones). I check up you're code allot but i couldn't really wrap my head around it all Dx
Thanks again!
Jabelar has a great tutorial for creating custom entities. Read through that - it really is helpful.
Registering mobs can be done like by calling EntityRegistry.registerModEntity with the correct arguments.
Make an instance of the class that has the @Mod annotation, and annotate that instance with @Mod.Instance
Example here.
You will use that instance in your call to register the entity, which I have here.
Look at the registration for the most similar entity to your own in order to decide what arguments to give it. The args include render-distance and update frequency.
Edit: fixed links after a git commit that changed a package name
Been awhile, i've been working on some other things.
I just checked up on you're references and examples now and it looks like both you github links are 404: Page not found errors. Hopefully Jabelar's tutorials are enough for me until you fix those Thanks again
For me the GitHub links work just fine...
Yeah, if you looked above he had an 'EDIT' that explained he fixed the links. i had chked them before that and they were broke. basically right after he fixed them i posted that
Anyways back to my problems because they never end.
I'm still horribly stuck on registering my mob. I'm 99% sure that i did the mob class, render class, and everything correct, EXCEPT the registering of the mob using EntityRegister.registerModEntity, anytime i try and use this i crash. Where should i have this exactly? I've tried in my PreInit (i think, or Init) section of my Client proxies, but i dunno if i should put it in my Main class or somewhere else. There's something terribly obvious i'm missing... isn't there?
Entity registering is done from preInit, yes. I have a separate class for registering just because I have a lot of entities. Registering the rendering for the entities, by the way, is also done from preInit. You can look at my ClientProxy to see how I do that.
Post the exact code you are using to register your entities -- I can't help much if all I suggest are things you've already tried.
You should have a static int variable that increases every time you register an entity so that they all have different IDs. You should also have a public static instance of your mod container (the file that has @Mod)
That's the problem at the moment actually. I don't have any code to register my entities. it seems every example i look at is different.
So far the problem with using your mod's example is that, well i can't make any sense of all the extra helper functions and other classes and... oi. It's hard simply because, i have no idea what i'm doing. like, at all. So, i think i'll just wait on this whole thing. My project can go on without mobs for the time being, but i'll have to figure this all out eventually.
I use this (some parts are deprecated, yes, but it still works so I keep using it)
To register the Entity Renderer I just call this:
Well that's fine and dandy, but won't using the EntityRegistery method cause a potential issue when using other mods that cause the entity ID pool to fill up? Orespawn and Superheros unlimited, along with some other big mods, use this method, and it ends up crashing when too many ID's are registered like this. Unless this is a different method and i'm just ranting about nothing relevant.
If the ID pool is full, there's no way besides redefining the bytesize of an integer to solve taht problem.
This is correct. Don't use UpcraftLP's method to start with or you will get in the habit of using it.
Specifically, this line is a problem:
Since it is deprecated, UpcraftLP, it's time to move on. Please don't encourage beginners to use deprecated methods even if they automatically create a spawn egg for you.
I've heard that as of 1.8.9 and 1.9 you can add two hex color arguments to the EntityRegistry.registerModEntity method in order to have it make a spawn egg for you. Haven't tried it out yet, but it's worth a shot.
Yeah, this is true, you can add a specific method to generate spawn-eggs like the deprecated method. I would know how to do it, if i could use the ModEntity method in the first place xD
What's hard about calling that method? It's not too complex Java syntax. Without a helper method, you just do this from preInit:
48 here is the render distance. 3 is the frequency of updates. true is whether to send velocity updates (for fast moving entities, I guess). Look at the javadocs for that method for details.
The numEntitiesRegistered part is slightly more complicated, but do you really want to hard-code an ID for every entity you register?
I've already described what the instance is and how to make it.
What questions do you possibly have?