Jump to content

When Mobs attack


Recommended Posts

Hi

 

I've got quite a happy bear wandering about my lands now. The problem is that the entity extends EntityAnimal and all the good code for attacking and getting angry if someone attacks it is in EntityMob which is down a different tree of classes.

 

I can bring the functions I need in via composition, but I wondered how Minecraft knows to call them? Is it to do with the enumCreatureType in AddSpawn? Or is it based on which class you extend via inheritance?

 

Thanks!

 

Graham

Link to comment
Share on other sites

Gah! This is driving me mad! I can make the mob create and render and behave and everything as an EntityAnimal, but when I change it to EntityMob, it doesn't render at all - it just pops in and immediately vanishes.

 

I know I've seen a tutorial somewhere about adding mobs which based them on a creeper but my google-fu is weak today and I can't find it!

 

What are the differences between the two Entity types?

 

Thanks!

 

Graham

Link to comment
Share on other sites

I've been working on some wild animal entities myself.  I found I got pretty good results by copying methods from EntityWolf.  Basically it is an EntityAnimal that also attacks and stuff.  You can remove the stuff about taming if you don't want your bear to be tamable.

 

Anyway, I suggest looking at EntityWolf.  I was able to make tiger entities that do everything I was interested in doing.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Cheers! When I originally made the bear, I copied it over from wolf but didn't make it tameable and it crashed whenever it was punched. So I went back to a vanilla mob and forgot about wolf. Now I'm adding in wolf-code one bit at a time and testing it.

 

So far, I'm using DataWatcher 16 bit 2 to set angry and I think it'd want to attack me when I punch it, but it just doesn't do any damage. Instead it kind of hops around madly for a bit then noses right up to me.

 

So I'm nearly there!

 

Thanks

 

Graham

Link to comment
Share on other sites

OK - so now I have two questions.

 

Firstly how to do you make a mob actually inflict damage? It comes up to me, follows me, growls, but doesn't hurt.

 

Secondly, where in the model/renderer is the bounding box? Because a bear is bigger than a wolf but at the moment it seems to be rendering halfway through things.

 

Thanks!

Link to comment
Share on other sites

OK - so now I have two questions.

 

Firstly how to do you make a mob actually inflict damage? It comes up to me, follows me, growls, but doesn't hurt.

 

Secondly, where in the model/renderer is the bounding box? Because a bear is bigger than a wolf but at the moment it seems to be rendering halfway through things.

 

Thanks!

 

For the bounding box, it is actually just in the Entity class.  You use the setSize() method.  Interestingly, the X and Z are both set to width value, so you can't control them independently.

 

For the damage, I remember having a similar problem when I did my Tiger.  Have you set the attackDamage attribute?  You can see my tutorial on attributes here: http://jabelarminecraft.blogspot.com/p/introduction-living-entities-i.html

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

Announcements



×
×
  • Create New...

Important Information

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