Custom Mob Stopping Certain Spawner?

Discussion in 'Spigot Plugin Development' started by KuramaStone, May 10, 2017.

  1. Hello! I have created a custom EntityZombie and it is working just fine with the exception of two things. One is that does not save into the world, so when a chunk unloads it is lost forever. The second, which is the focus of this post, is that it stops Zombie Spawner and Zombie eggs from working. Zombies can be called with /summon or by spawning naturally. The code is below, so does anyone see a reason why it would be doing this?

    Here is where I register the Entity.
    Code (Text):
        @Override
        public void onEnable() {      
            registerGolem(HarvestGolem.class, "HarvestGolem", 54);
            registerGolem(SeekerGolem.class, "SeekerGolem", 54);
            registerGolem(GuardGolem.class, "GuardGolem", 54);
            registerGolem(MinerGolem.class, "MinerGolem", 54);
            registerGolem(BreederGolem.class, "BreederGolem", 54);
           
            getServer().getPluginManager().registerEvents(new GolemCreationListener(), this);
        }
    and Here is actual Register:
    Code (Text):
        public void registerGolem(Class<? extends EntityGolem> customClass, String name, int id) {
            try {
                List<Map<?, ?>> dataMap = new ArrayList<Map<?, ?>>();
                for (Field f : EntityTypes.class.getDeclaredFields()) {
                    if (f.getType().getSimpleName().equals(Map.class.getSimpleName())) {
                        f.setAccessible(true);
                        dataMap.add((Map<?, ?>) f.get(null));
                    }
                }

                if (dataMap.get(2).containsKey(id)) {
                    dataMap.get(0).remove(name);
                    dataMap.get(2).remove(id);
                }

                Method method = EntityTypes.class.getDeclaredMethod("a", Class.class, String.class, int.class);
                method.setAccessible(true);
                method.invoke(null, customClass, name, id);

            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }