I'm starting a basic AI plugin. I thought I'd share my approach and see what you think.
First off, I'm using HOOK_WORLD_TICK to trigger activity.
I only fire off my routine if the last time I triggered was more than 250ms ago, and was for another world.
I then iterate through each entity in that world and check that it is a mob. If it is a mob and within 25 blocks of a player character in that world I store it and some parameters in a table.
I then house clean the table for entities that are out of range or no longer in the game.
I then loop through the table and make them do things.
a) get to safety (out of water, lava, sunlight, etc...)
b) move towards target player
c) move towards villager
d) attack target player or villager
This is just my starting list.
Here's the start of the project. It only has the part that stores the mobs right now.
https://github.com/planetx/AI
First off, I'm using HOOK_WORLD_TICK to trigger activity.
I only fire off my routine if the last time I triggered was more than 250ms ago, and was for another world.
I then iterate through each entity in that world and check that it is a mob. If it is a mob and within 25 blocks of a player character in that world I store it and some parameters in a table.
I then house clean the table for entities that are out of range or no longer in the game.
I then loop through the table and make them do things.
a) get to safety (out of water, lava, sunlight, etc...)
b) move towards target player
c) move towards villager
d) attack target player or villager
This is just my starting list.
Here's the start of the project. It only has the part that stores the mobs right now.
https://github.com/planetx/AI