EntityRegistrer | from 1.6.x to 1.11.x 1.0

Register custom entities easily, without weird NMS behaviours!

  1. Arektor
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    [​IMG] Donations will help me to keep up the work. It's a way for you to support me, and saying me thanks ;)

    WARNING FOR 1.11 USERS: The 1.11 support is not fully optimized, and does not yet support the /reload command. YOU WILL NOT GET ANY SUPPORT WHEN USING /reload


    What is EntityRegistrer?

    EntityRegistrer is an API I wrote while having issues with custom entities overriding vanilla ones on server restart / chunk reload.
    It allows you to register custom insentient entities, as non-insentient ones does not need to be registered and can instantly be spawned, like ArmorStand or EnderCrystal, without having any weird NMS behaviour aside.



    How are you bypassing these issues?

    After some attempts, I found out that you do not need to register the entity in the BiomeBase lists. Doing this will cause overriding issues that you probably don't want to have.

    However, without registering them in these lists, when the chunk is reloaded or server restarted, the entity will just disappear.

    So here is how this API works:


    1. When a chunk is unloaded, check for any custom entity in it, and save its NBT in the plugin folder, then remove it.
    2. When a chunk is loaded, check if its folder exists in the plugin folder. If yes, respawn every custom entity saved as files in the chunk folder.
    3. When a custom entity is registered, add it in the EntityTypes lists, then check every saved entity file of the loaded chunks of every world. If it is a file of an instance of this entity, spawn it.
    4. When a custom entity is unregistered, save all instance of it and remove them from all the worlds.
    By doing so, custom entities will only be spawned if they are registered. If they are not, they are saved as files in the plugin folder, and will be respawned if registered again.

    This way, if you fail and start the server without the plugin, load chunks where some custom entities should be, then close it, put the plugin back and restart, your custom entities will still be there.
    .



    Is there any documentation?

    There is no proper documentation as of today, however I managed to provide a temp one right here, into spoilers. There is an internal javadoc to tell you what does this method and what are the params, I'm gonna host it somewhere soon.
    But that's better than nothing, I guess.

    EntityRegistrer#register(String name, int id, EntityType type, Class<?> nmsClass, Class<?> customClass)

    EntityRegistrer#register(String name, EntityAppearence appearence, EntityType type, Class<?> nmsClass, Class<?> customClass)

    EntityRegistrer#unsafeRegister
    (String name, int id, EntityType type, Class<?> nmsClass, Class<?> customClass)

    EntityRegistrer#unsafeRegister
    (String name, EntityAppearence appearence, EntityType type, Class<?> nmsClass, Class<?> customClass)

    EntityRegistrer#unregister(String name)

    Coming soon, still empty yet

    public void A_();
    Method called every tick.

    public void m();
    Method called every tick.

    public void m();
    Method called every tick.

    public void m();
    Method called every tick.

    public void t_();
    Method called every tick.

    public void t_();
    Method called every tick.

    public void s_();
    Method called every tick.

    public void h();
    Method called every tick.

    public void h();
    Method called every tick.

    public void h();
    Method called every tick.

    public void h();
    Method called every tick.

    public void l_();
    Method called every tick.

    public void l_();
    Method called every tick.

    public void l_();
    Method called every tick.




    [​IMG] Donator wall

    1. Nobody yet

    Wanna make a donation? You can write down your username when making it, and your server IP if you wish to, or website URL.



    You can access the source code of this API, as well as look at an example of its usage, on the GitHub repo:

    [​IMG]
    Gabrielmaennl5 and Spidev like this.

Recent Updates

  1. 1.11 Support Bugfix