Minor announcement - NMS code (blogpost) (Patreon)
Content
Hello everyone,
Today, for the first time in the nearly 6 years EliteMobs I’ve been working on EliteMobs for and for the first time in the 7 years I’ve been doing Minecraft plugins, I’ve released a set of features which depend on NMS code.
This is a landmark moment for me, and one that I wanted to make note of in a blogpost. That I have not written NMS code in the last 7 years is not a coincidence, it has been a sticking point, a line in the sand beyond which things would take “too much effort” to justify doing.
However, thanks to your support, and years of bettering myself as a developer, today I crossed that line.
As such, I’ve created a library which I am currently calling SimpleMinecraftPathfinding, and which I might later rename to SimpleMinecraftGoalManager or something like that.
For those confused about what NMS code is: NMS is the source code of Minecraft, in this case of the server software part of Minecraft. Spigot and Paper have APIs based on this code, which are documented, maintained and supported by the community of which I am a part of.
APIs like Spigot and Paper do not cover every possible feature Minecraft has, and it would be unreasonable to expect them to have full 100% coverage. However, there are some key things that are simply impossible to do. To name two relevant here: custom entities and influencing pathfinding.
Using the Spigot API (which I do, since I make Spigot plugins), it is simply impossible to make custom entities and to influence where they go. You can make entities and change things about them, and you can do a few tricks to nudge them into a spot or teleport them, but fully custom entities with fully custom AI is not possible. It is marginally more possible with Paper, but I really did not want to force people to switch to Paper while still publishing on Spigot.
However, writing NMS code is like making a deal with the devil; with this great power, comes a great headache. Each Minecraft server version has to be maintained individually, including upgrades from minor versions such as 1.19 to 1.19.1. NMS code is much more powerful, but also entirely undocumented, very easy to use incorrectly and very easy to crash servers with.
Hence my refusal to use it up until now. A good NMS setup requires a very robust project structure, and I don’t think it can be much better than the one that I ended up using thanks to some advice from the Spigot community.
For those wondering, it is a multi-module project with a core for the interface, a dist for the packaging and each individual Minecraft version using Minecraft remappings which get reobfuscated on compile. I would say this is the modern standard way of approaching this issue, perhaps a little better than the average as I am using the Mojang remappings. I am shading this library in and will be uploading the repository on a sonatype maven repo. As with everything else, it will be open source for the public release.
Which brings me to how this will be used:
NMS code has one big weakness, that being that it requires updating with every Minecraft server version. I do not want to limit your ability to update your Minecraft servers due to EliteMobs being on an older version that is no forwards compatible, which has always been the biggest selling point of only using the API.
You will notice that I did not add the NMS code to EliteMobs but rather to a library that I created. This is intentional, and the objective will be to make the features that this library allows us to implement to be “optional”, and still have the plugin work mostly normally even if it has not updated.
As for the actual uses of what I just released: to test the implementation, the first feature and currently the one on 8.4.5-SNAPSHOT-1 is a new soft leash for regional bosses. This makes sure that if the boss is detected to be over 1/3 of the maximum range that it is allowed to go and not in combat it will start walking back to its spawn point, instead of the slow teleportation they used to do.
As you might imagine, I will also be adding this to the Elite Scripts as a possible action, and I also plan to implement a patrol routine for some of the bosses in some of the dungeons to make those dungeons feel more alive and populated with smarter creatures.
Most of all, this will be used in more than just EliteMobs. After releasing the next set of dungeons, I plan to focus my efforts on developing and releasing EternalTD, a tower defense game in Minecraft, the prototype for which is already available on Patreon.
This tower defense system will be using the same pathfinding library to make the mobs move around the world.
It is also my hope that one day I will develop a free alternative to ModelEngine. If that comes to pass, I plan to use that and the pathfinding library I created to create fully unique new mobs with their own custom behavior, integrating them seamlessly into the world like a mod. Think a version of the Mo’ Creatures Mod for Minecraft servers.
But those are just potential plans for the future. For now, I hope you enjoy the new feature, I’m off to work on the dungeons.
Happy adventuring,
- MagmaGuy