Mob Spawning

Discussion in 'Plugin Development' started by Deckerz, Aug 16, 2012.

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

    Deckerz

    What is the code so when hostile mobs try to spawn it replaces all of them with zombies?

    I've tried this and it just spams errors:

    Code:java
    1. package me.zombie;
    2.  
    3. import org.bukkit.entity.EntityType;
    4. import org.bukkit.entity.Monster;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.EventPriority;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.entity.CreatureSpawnEvent;
    9. import org.bukkit.plugin.PluginManager;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class zombie extends JavaPlugin implements Listener{
    13.  
    14. public void onEnable() {
    15. PluginManager pm = getServer().getPluginManager();
    16. pm.registerEvents(this, this);
    17.  
    18.  
    19. }
    20.  
    21. public void onDisable() {
    22.  
    23. }
    24. @EventHandler (priority = EventPriority.NORMAL)
    25. public void onCreatureSpawn(CreatureSpawnEvent e)
    26. {
    27.  
    28. if (e.getEntity() instanceof Monster)
    29. {
    30. e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.ZOMBIE);
    31. e.getEntity().remove();
    32.  
    33. return;
    34. }
    35. }
    36. }
    37.  
     
  2. Offline

    XbannisherX

    Code:
    @EventHandler(priority = EventPriority.HIGH)
    public void onCreatureSpawnEvent(CreatureSpawnEvent event){
    World w2 = event.getEntity().getWorld();
    w2.setMonsterSpawnLimit(350);
    EntityType type = event.getEntity().getType();
    if(type == EntityType.CAVE_SPIDER ||
    type == EntityType.ZOMBIE ||
    type == EntityType.SKELETON ||
    type == EntityType.SPIDER ||
    type == EntityType.GIANT ||
    type == EntityType.SILVERFISH){
    Location loc = event.getEntity().getLocation();
    event.getEntity().remove();
    World w = loc.getWorld();
    w.spawnEntity(loc, EntityType.CREEPER);
    }
    }
    }
    you can edit that for your own purpose ^^
    this replaces all hostile mobs by creepers
     
    Huffmanbran and ScrubHunter like this.
  3. Offline

    Deckerz

    That just stops them i want were they should spawn to be replaced with zombies
     
  4. Offline

    XbannisherX

    i edit it
     
  5. Offline

    Deckerz

    ???
     
  6. Offline

    XbannisherX

    Code:
    @EventHandler(priority = EventPriority.HIGH)
    public void onCreatureSpawnEvent(CreatureSpawnEvent event){
    World w2 = event.getEntity().getWorld();
    w2.setMonsterSpawnLimit(350);
    EntityType type = event.getEntity().getType();
    if(type == EntityType.CAVE_SPIDER ||
    type == EntityType.ZOMBIE ||
    type == EntityType.SKELETON ||
    type == EntityType.SPIDER ||
    type == EntityType.GIANT ||
    type == EntityType.SILVERFISH){
    Location loc = event.getEntity().getLocation();
    event.getEntity().remove();
    World w = loc.getWorld();
    w.spawnEntity(loc, EntityType.CREEPER);
    }
    }
    }
     
    Shortninja66 likes this.
Thread Status:
Not open for further replies.

Share This Page