For that you can use EntityLiving#setAttackTarget(EntityLivingBase) and pass the entity you want to attack as argument. Obviusly you have to pass a specific entity instance existing in the world
EntityLiving#tasks and EntityLiving#targetTasks are public fields, you can add and remove AI tasks from these lists. To make an entity attack a specific type of entity, you'll want to add a EntityAINearestAttackableTarget to targetTasks with a priority of 2.
You can do this from EntityJoinWorldEvent.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
EntityLiving#tasks and EntityLiving#targetTasks are public fields, you can add and remove AI tasks from these lists. To make an entity attack a specific type of entity, you'll want to add a EntityAINearestAttackableTarget to targetTasks with a priority of 2.
You can do this from EntityJoinWorldEvent.
I cast event.entity to EntityLiving to add task and got crash.
Edit: I added checking if it zombie and ok! (Crash was cause EntityArrow can't cast to EntityLiving)
I cast event.entity to EntityLiving to add task and got crash.
Because not every Entity is an EntityLiving. You need to check if the Entity is an EntityLiving using the instanceof operator before casting to EntityLiving and adding the AI tasks.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
As Choonster mentions, you can apply this to vanilla mobs because the AI task lists are public scope. So you can clear the list, add your own tasks, etc.
Hello! I want change vanilla mob AI (for example make zombie attacking pigs (poor pigs xD)), so how to do it?
For that you can use EntityLiving#setAttackTarget(EntityLivingBase) and pass the entity you want to attack as argument. Obviusly you have to pass a specific entity instance existing in the world
sorry for my bad english I'm Italian
EntityLiving#tasks and EntityLiving#targetTasks are public fields, you can add and remove AI tasks from these lists. To make an entity attack a specific type of entity, you'll want to add a EntityAINearestAttackableTarget to targetTasks with a priority of 2.
You can do this from EntityJoinWorldEvent.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I cast event.entity to EntityLiving to add task and got crash.
Edit: I added checking if it zombie and ok! (Crash was cause EntityArrow can't cast to EntityLiving)
Thanks for answers!
Because not every Entity is an EntityLiving. You need to check if the Entity is an EntityLiving using the instanceof operator before casting to EntityLiving and adding the AI tasks.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
[redacted]
I have a tutorial that explains how the AI sytem works here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-custom-entity-ai.html
As Choonster mentions, you can apply this to vanilla mobs because the AI task lists are public scope. So you can clear the list, add your own tasks, etc.