[Lib] Spawning Basic NPCs

Discussion in 'Resources' started by BurnBlader, Oct 13, 2013.

Thread Status:
Not open for further replies.
  1. Hi, its BurnBlader. I've seen so many people how to spawn a NPC, so I decided to write a Library to spawn basic NPCs.

    To use it, just copy the Human class into your plugin, and you can use it.

    World world = player.getLocation();
    String name = "Bob";
    int id = new Random().nextInt(5000-1000)+1000;
    Location location = player.getLocation();
    int itemInHandId = player.getItemInHand().getTypeId();
    Human human = new Human(world, name, id, location, itemInHandId);
    That will spawn a player with the given parameters.

    If you have any questions or anything, please post them below!

    You can get the Human class here!

    Methods you can use:
    setItemInHand(int itemID);
    hideForPlayer(Player p);
    showForPlayer(Player p);
    addPotionColor(Color r);
    addPotionColor(int color);
    walk(double x, double y, double z);
    GrandmaJam, kevinspl2000 and DSH105 like this.
  2. BurnBlader Why are you sending the Packet29DestroyEntity when changing item in hand? Why not just use the Packet5EntityEquipment? I see you are using the destroy packet a lot while it can be done with another packet. And finally, you are sending the packet to all players. This will cause a npc in the nether and the end, first check if the player you send it too is in the same world. Other then that, good job!
    Phasesaber likes this.
  3. CaptainBern I was having an issue with that packet, but I'll try it again once I get a chance. Thanks :D
  4. Offline


    Mind if I do my best at making this use reflection?
    GrandmaJam likes this.
  5. Ultimate_n00b Take a look at my animationlib, it will help you.
  6. BurnBlader I just saw your code again. Ofcourse the Packet5EntityEquipment won't work. You have to use NMS itemstacks, not bukkit itemstacks :p

    BurnBlader Oh and also, you're destroying and respawning the npc when setting it crouched, block animation etc... Why not just use the Packet40EntityMetadata?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
  7. Offline


    I am new in handling with packets. Can anybody tell me what parameters are needed for the void walk()? I kow: 3 doubles, but what are they telling and what number need they?
  8. Offline


    Hey, X,Y,Z dosent work :(
  9. TimBone For the moment, walk() just makes them teleport, not walk. I'm working on getting them to move at the moment!
  10. Offline


    Okay, thanks a lot, that was what wondering me :)
  11. Offline


    Nice lib but whats about comment your code?
    Would be very helpful ;)
  12. Offline


    If this were a tutorial it would already have that, but since it's just a lib, it shouldn't have comments.
    Ultimate_n00b likes this.
  13. Added new methods.

    1. hideForPlayer(Player p);
    2. showForPlayer(Player p);
    3. addPotionColor(Color r);
    4. addPotionColor(int color);
    xTrollxDudex likes this.
  14. Offline


    How can I check if someone damaged the Human?
    if (instanceof Human) maybe? :confused:
  15. GaaTavares No, the server doesn't know about this npc. So nope, that won't work.
  16. Offline


    ahh ._.
  17. How would you change the skin to an actual player's skin?
  18. Offline


    Can you work on a health system? And so the actual entity can die?
  19. Offline


  20. I'll be updating this soon, and I'll make another version that allows the use of ProtocolLib for damaging, and possibly a health system.
  21. Offline


    Cool! I haven't done any plugin coding in a while, might get back into it and make a basic citizens alternative! :D
  22. Offline


    Flybelette likes this.
  23. Offline


    Eh. I'll look into it.
    DrJava likes this.
  24. Offline


    I've almost finished making this work with 1.7 although i am stuck on how to initialize the DataWatcher object now because they have changed it to require you to pass an Entity into its constructor.

    Does anyone know how i would go about doing this?

    Also, when i get it working i will post it here
  25. Offline


    Setting it to null should work fine, as you nor MC will ever use the actual DataWatcher.
Thread Status:
Not open for further replies.

Share This Page