Spawning a player and monitoring it?

Discussion in 'Plugin Development' started by Kazzababe, Nov 25, 2012.

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

    Kazzababe

    How do you spawn a custom player with specific armor and then monitor its health, position, etc.
    Also, how would I make it so it doesnt move at all? Its for a custom pvp plugin but I've never messed around with this kind of thing before, so any help is appreciated. Thanks :D
     
  2. Offline

    willeb96

    You mean like an NPC?
    Look at the source for the plugin Citizens :)
     
  3. Offline

    Kazzababe

    I could be mistaken and I most likely am, but I don't think Citizens monitors NPc health.
     
  4. Offline

    willeb96

    Oh, so you know how to spawn an NPC but not how to look up its health?

    ((double) npc.getHealth() / 2) + " hearts"?
     
  5. Offline

    Kazzababe

    No. I don't know how to spawn the entity or get the health.
     
  6. Offline

    gomeow

    To spawn an entity and monitor its health:
    Code:java
    1. Zombie z = (Zombie) world.spawnEntity(location, EntityType.Zombie);
    2. int health = z.getHealth();
     
  7. Offline

    Kazzababe

    NPC. I just want a simple method to spawn an NPC and monitor its health. Like citizens but about 100 times shorter and less complicated.
     
  8. Offline

    willeb96

    Sorry, but I think it actually is pretty complicated to spawn NPCs.
     
  9. Offline

    gomeow

    I heard of something called NPCSpawnerlib. You could look into that
     
  10. Offline

    tom1000o

    theres an EntityType.Player right? maby mess around with that?
     
  11. Offline

    jojohnson1

    This is what i'm doing at the moment. My code is
    Code:
    e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.PLAYER);
    but you can't spawn it like that, it throws an IllegalArgumentsException...
    In the source code, they tell you this:
    Code:
    /**
        * Spawn with {@link World#strikeLightning(org.bukkit.Location)}.
        */
    but as we can see, there is only one argument, the Location... And 4 different EntityTypes available... Anybody an idea how to do that?
    And by the way: The Citizens Source code is not really clear, they took the important part of the code out of it...
     
  12. Offline

    fireblast709

    Citizens probably spawns a net.minecraft.server.EntityPlayer
     
Thread Status:
Not open for further replies.

Share This Page