Jump to content

[1.7.x] Adding attributes to vanilla mobs


Recommended Posts

I have encountered a problem, I have made a new item and such and its all working fine and dandy but I cant seem to figure out how to make the spider follow you when you hold the new item. Does anyone know how I can make the spider follow me while holding my spider queen crown item? Can I use the [glow=blue,2,300]EntityAITempt[/glow] and make the vanilla spider follow me when I hold the crown in my hand. I have spent hours trying everything I can think of. I would prefer if you respond you can give some example code. And i [glow=red,2,300]don't want to edit the vanilla classes[/glow]. Can you help? Thanks soo much in advance!

Link to comment
Share on other sites

I don't think you can use the tempt AI because I don't think spiders use the new AI.  You can check by printing out the returned value from the isAiEnabled() method.  Basically, some entities use the AI task list and others use the onUpdate() method to control them.  I think spiders use the latter.


In the case of an entity that uses onUpdate, you may be able to control it using the LivingUpdateEvent.  This is a cancelable event (meaning you can cancel the vanilla behavior and replace with your own).  So in that event you'd check if the event.entity was instanceof EntitySpider and if that is true then you'd check if the player is holding the item (that might be a bit tricky though as no player is returned in that event, so you'd want to look for EntityPlayer within a certain distance) and if so then you'd want to cancel the vanilla behavior and replace with your own.


The only issue is that you should copy a lot of the onUpdate() code to ensure that the behavior is still somewhat normal, and you'd want to implement proper pathfinding and such so that it moved properly.

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.

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.


  • Create New...

Important Information

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