Resource Custom entity creation (1.13.2)

Discussion in 'Spigot Plugin Development' started by Parozzz, Jan 9, 2019.

  1. Hey all,
    this resource is a kinda simple resource that allows you to register custom entities and override spawn for them.
    You can find the resource here on GitHub https://github.com/Parozzz/CustomEntitySaver

    Here an example on how to use it (Included in the GitHub repo).
    Code (Java):

    public final class ExampleCustomEntity extends EntityPig
    {
        private static CustomEntityType<ExampleCustomEntity> entityTypes;
        public static void register()
        {
            entityTypes = CustomEntitySaver.registerEntity("example_custom_pug", CreatureType.PIG, ExampleCustomEntity.class, ExampleCustomEntity::new, true);
        }

        public ExampleCustomEntity(World world)
        {
            super(world);
        }

        /**
         * This is very important to override, otherwise your entity won't be saved and reverted to a vanilla one.
         * @return The custom EntityTypes.
         */

        @Override
        public EntityTypes getEntityType()
        {
            return entityTypes.getNMSEntityTypes();
        }
    }
     
    It is very important that you override the Entity#getEntityType method otherwise your entity won't be saved on restart and will be replaced by a vanilla entity.

    N.B.: This won't allow you to replace the spawn of mob inside structure unfortunately since they are hardcoded.


    Unfortunately, I haven't got much time to add more docs and/or create a maven repository for this, might to it in the future.

    EDIT1:
    I've also added a method to allow you to revert the spawn to vanilla mobs.
     
    #1 Parozzz, Jan 9, 2019
    Last edited: Jan 9, 2019
    • Useful Useful x 3
  2. Reserved.
     
    • Agree Agree x 1
  3. I won't bump this resource too much. I would like some feedback though or if someone has a better way / I have forgot something.
     
  4. Yes, it's very infortunate :(
    Tip: you can override the vanilla entity spawn by cancel it and summon your entity at the good location

    Edit : your resource is very useful. Thanks you to share it with the community :D
     

Share This Page