It's still not released but I've made significant progress. It can be seen here.
Repixture used to be based on an ancient Mobs Redo fork but this is now gone in the developer version. I've created a completely new Mobs API from scratch, specifically for Repixture. Mobs Redo has good default features but is extremely unflexible and has a clunky code base, so it needed to go.
You may wonder, why yet another Mobs API while there are so many others? Well, I've looked at the other ones but either they had bad performance, were poorly to extend, or lacked many essential features, or they were not documented at all. I really tried to *not* reinvent the wheel but eventually I caved and did it anyway.
rp_mobs
rp_mobs is the core of the new Repixture mobs system. I want to talk about some of the (probably?) innovative approaches:
- (almost) everything is optional: Mobs only run the code and features they need;
- Offer a common baseline: Important features that many mobs need are available by default
- Flexibility: I make very little assumptions about mobs so the actual mobs aren't contrained in what they can do
- I reimplemented most key features of Mobs Redo like breeding, capturing
- Player-like: Mobs need to support features that players have: Drowning, node damage, disable_jump, climbing, fall-damage, etc.
- Documentation! The lack of documentation was the most frustrating part of the other mob "APIs" so I want to do better than them
The task system
The heart of rp_mobs is the task system. Every mob has a number of task queues which in turn contain tasks which in turn contain microtasks. Microtasks contain the actual code and it can be basically anything.
Tasks are for high-level goals, like "find some food" while microtasks are the sequence of concrete steps to reach that goal, like "walk to coordinate XYZ", "jump", etc. Microtasks and tasks run sequentially, i.e. in the same order you put them in.
Task queues are different. They are completely independent from each other and run in parrallel. It turned out adding this feature allowed me to simplify the code a lot. This allows me to run things like checking/scanning the environment while simultanously walking around, while making random animal noises and potentially more all in parrallel and cleanly separated. This idea is loosely inspired by operating systems.
Templates
If the only thing the mod offers would be the task system, that wouldn't be enough. I think a good Mob API needs to have a readily-availble set of movement primitives ready to use. And features that many mobs will need. Otherwise, mobs need to reinvent the wheel over and over again (the mobkit approach) which is not my goal. That's why I added a number of simple template functions that can be added as microtasks.
Most templates are about movement, but there's also a template that plays a mob sound in random intervals, emulating the "random" sound in Mobs Redo.
Progress so far
rp_mobs works pretty nice, the documentation is written and I have been able to re-implement all the mobs from the current Repixture version. I consider it to be almost feature-complete.
But there are still some small bugs with the movement. Still, I think rp_mobs is now definitely in a state that I could say the hard rework already has paid off. The ancient Mobs Redo fork is finally gone which was the main goal.
In Repixture, I am currently in the process of working on the villager behavior and teaching it to walk, pathfind, etc. but this technically isn't part of rp_mobs anymore.
Weak points
I think the biggest weakness in rp_mobs right now is physics. I am piss-poor in maths so there aren't any truly elaborate movement helpers or functions, but those that exist are good enough to emulate the current Repixture mobs. The mobs will not have a "smooth-looking" movement unless you code such microtasks yourself. But that's an acceptable weakness for now, my primary goal is to replace Mobs Redo (done) and make a release (not done). Maybe I could later copy code from the other mods (attributed, of course). ;-)
I believe another weakness might be the learning curve. The API documentation is long and I wonder how hard the barrier of entry is for others. I wonder where it could be simplified, if at all. But I also believe a lot of the complexity is simply unavoidable.
Check it out!
If you want to check out the current development state of rp_mobs, check out these links:
- API documentation: https://codeberg.org/Wuzzy/Repixture/sr ... obs/API.md
- Code: https://codeberg.org/Wuzzy/Repixture/sr ... ds/rp_mobs
So what's your opinion on that so far?
Did you read the documentation and did you like it?
What do you think about the presented concepts?
Was I right to start a new mob API?
Any other questions?