How to spawn monsters?

Discussion in 'Plugin Development' started by blindstone, Jul 2, 2012.

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

    blindstone

    Was just wondering if someone could give me a bit of insight on how to spawn monsters. But also having the ability to modify there health, add potion effects and detect if they were killed. Anyone have any ideas?

    ive been looking at world.spawn(loc, Zombie.class) but then how would I get the zombie i wanted to modify?

    Thanks in advance!
     
  2. Offline

    MrTheNewGuy

    use this code
    Code:
    player.getWorld().spawnCreature(location, EntityType.CREEPER);
     
  3. Offline

    blindstone

    ok, but how would I modify such things as health for that entity?
     
  4. Offline

    MrTheNewGuy

    how?
    on a command or if you spawn it?
     
  5. Creeper creeper= world.spawn(loc, Creeper.class);
    creeper.setHealth(10);

    something like that can you use
    written fronm my head, may be wrong
     
  6. Offline

    MrTheNewGuy

    on your way it shoud be
    Code:
    Creeper creeper = (Creeper) world.spawnCreature(loaction, EntityType.CREEPER);
                creeper.setHealth(1);
    But you where very close. xD
     
  7. I verifed the code is working after I posted it and it was working, and whit my way, you dont need to cast it, because I use generics
     
  8. Offline

    blindstone

    thanks ferrybig! your way worked. unfortuently there is a limit on the health to how high it can be. Also i guess you cant add potioneffects to mobs
     
  9. because an mob extends a livingEntity, you can call addPotion on him
     
  10. Offline

    blindstone

    how would I go about doing this?
     
  11. Offline

    MrTheNewGuy

    creeper.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,
    time, level));

    i have tested it and it works
     
  12. Offline

    blindstone

    whats the time value done by, ticks? (which works out to what in seconds, appriciate this guys you are extreamly helpful!
     
  13. Offline

    Whatshiywl

    ugh i know 20 ticks is one second and that's all i know xD
     
  14. Yeah but I think in 1.3 you should be able to set their health higher.
     
  15. Offline

    KeybordPiano459

    Code:
    Creeper creeper = (Creeper) world.spawnCreature(loaction, EntityType.CREEPER);
                creeper.setHealth(1);
    Just two notes:
    1. You spelled 'location' wrong
    2. When I try this, it gives me an error, saying that I should create a field, variable, parameter, or constant. How do I fix this?
     
  16. Offline

    LexLaiden

    Dude! you have to declare a Location and set its value.
     
    Codex Arcanum likes this.
  17. Offline

    blindstone

    just use spawn instead of spawncreature, and you shouldnt have to cast it.

    Code:
    Creeper creep = world.spawn(location, Creeper.class);
    . not that it matters i dont think.
    still havent figured out about the potions, but im still playing with it!
     
  18. Offline

    KeybordPiano459

    How do I declare a location?
     
  19. Offline

    blindstone

    Code:
    Location loc = new Location(world, X,Y,Z);
     
  20. Offline

    Armadillo

    For people reading in the future. spawnCreature() has been replaced with spawnEntity().
     
Thread Status:
Not open for further replies.

Share This Page