Mobs don't hurt owners

Discussion in 'Plugin Development' started by Faith, Mar 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Faith

    How can I set a mob to not attack it's owner(Player who spawned it in with egg)

    What I have as of now:
    Code (open)
    Code:
    @EventHandler
        public void onCreatureSpawn(CreatureSpawnEvent event) {
            final Entity e=event.getEntity();
            Player spawner=null;
            if(spawner != null &&
                    e.getType() == EntityType.SKELETON ||
                    e.getType() == EntityType.CREEPER  ||               
                    e.getType() == EntityType.WITHER ||
                    e.getType() == EntityType.ZOMBIE ||
                    e.getType() == EntityType.SKELETON ||
                    e.getType() == EntityType.PIG_ZOMBIE ||
                    e.getType() == EntityType.SPIDER ||               
                    e.getType() == EntityType.CAVE_SPIDER ||
                    e.getType() == EntityType.BLAZE ||
                    e.getType() == EntityType.SKELETON ||
                    e.getType() == EntityType.ENDERMAN ||
                    e.getType() == EntityType.GHAST ||
                    e.getType() == EntityType.WITCH ||
                    e.getType() == EntityType.SILVERFISH ||
                    e.getType() == EntityType.IRON_GOLEM &&
                    ((CreatureSpawnEvent) e).getSpawnReason() == SpawnReason.EGG) {
               
            }
        }
     
  2. Offline

    MrNewbie

    Well I can't answer your question but for starters try setting Players spawner as a variable other then null.
     
  3. Offline

    Konato_K

    @Faith I guess EntityTargetLivingEntityEvent can work
     
  4. Offline

    nverdier

    Yup! And just cancel it if the owner is whatever.
     
  5. Offline

    Faith

  6. Offline

    nverdier

    @Faith Store the data in a Map.
     
Thread Status:
Not open for further replies.

Share This Page