What is the code to spawn mod?

Discussion in 'Plugin Development' started by oran10majar, Nov 8, 2013.

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

    oran10majar

    What is the code to spawn mob? & Items on the mob?
    In the title, mod =mob!
     
  2. Offline

    The_Doctor_123

    Use the spawnEntity method in World.
     
  3. Offline

    oran10majar

    I new in java, you have guide for me?
     
  4. Offline

    RealDope

    Code:JAVA
    1.  
    2. // Assumes you have a player object already
    3. player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.CREEPER);
    4. // Assumes you have a location object already
    5. location.getWorld().spawnEntity(location, EntityType.CREEPER);
    6.  
     
  5. Offline

    JPG2000

    oran10majar I would take a different approach. I would store it in a variable, so you have access to other methods.
    Code:java
    1. //Basic entity
    2. LivingEntity entity = (LivingEntity) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.CREEPER);
    3.  
    4. //Make sure you have a player variable
    5.  
    6. //That would spawn a creeper. Lets say you want a sheep, you could do EntityType.SHEEP but you wouldn't have access to dye color, so heres how:
    7.  
    8. Sheep sheep = (Sheep) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.SHEEP);
     
  6. Offline

    RealDope

    JPG2000
    Ehm...
    Not totally sure how that's a "different approach". It's pretty much exactly what I said but you're storing the entity, which he probably doesn't care about, considering he doesn't seem to understand Bukkit or Java at all.
     
  7. Offline

    JPG2000

    RealDope Well my different approach is not what you said. In your example, you don't have access to valuable methods, things that would help.
     
Thread Status:
Not open for further replies.

Share This Page