NpcSpawner lib - spawn basic NPCs

Discussion in 'Resources' started by Redecouverte, Feb 3, 2011.

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


                    if (npc != null) {
                        npc.moveTo(l.getX()+3, l.getY(), l.getZ(), l.getYaw(), l.getPitch());
                        return true;
  2. Offline


    This needs to be properly updated for m1.3 ;)
  3. Offline


    it works fine for me
  4. Offline

    Ryan Carretta

    It looks like when running the latest CraftBukkit/Bukkit/client the client hangs and stops responding when the spawned NPC comes into the field of view.
  5. Offline


    I'm running it but I had to disable pm.registerEvent(Type.ENTITY_DAMAGEDBY_ENTITY, mEntityListener, Priority.Normal, this); as it was saying ENTITY_DAMAGEDBY_ENTITY cannot be resolved or is not a field.

    It also doesn't respond when I bounce on it and I am not sure if it is supposed to look at you, because if it is, it isn't working.
  6. Offline

    Ryan Carretta

    I don't think anything is supposed to look at you...what would make you assume that? You give it the x,y,z,yaw,pitch when you create the NPC. If you want to move it later you'd need to call the move() function provided. I couldn't get bounce to work, and the 'closest' only fired off once. I'm not sure if it requires another player to be closer and acts more as a latch than as a continuous event. I can't imagine what about this is causing my client to lock up and stop responding. [​IMG]
  7. Offline


    I didn't assume that, I said " I am not sure if it is supposed to look at you, because if it is, it isn't working."
  8. Offline


    The event ENTITY_DAMAGEDBY_ENTITY was changed in the newest bukkits, and therefore that doesn't work. If anybody wants to know, you have to change the code a bit to make it works. Use the onEntityDamage event, and do like so:
    public void onEntityDamage(EntityDamageEvent event)
     if( event instanceof EntityDamageByEntityEvent )
      EntityDamageByEntityEvent trueevent = (EntityDamageByEntityEvent) event;
    That's how I do it now atleast.
  9. Offline


    Does moveTo() use pathfinding or is it just teleport?
  10. Offline


    its just teleport
  11. Offline


    No it doesn't just Teleport, It 'Just' walks straight to it.

    And I'd found out a new Method of creating NPCS Shops. Will be testing this Tomorrow.
  12. Offline


    It actually walks to it? That's awesome - can you post a video of this?
  13. Offline


    Yes and no, I just tried it. It somehow fly's/walks to the current players position. Although you can see the walking animation.

    I think if you can like change the Vector settings and such that you can make it look like it walks.

    Notch is in my server :D
  14. Offline


    ^^ That is my Plugin, probably outdated now, it's a pathfinding NPC using a*, not the best and it has a few bugs but yeah it's a good ground if anyone wants to finish it (please release it on this forum if you do fix it up).

    /create <Key> <Name>
    /walkto <Key>

    /walkto makes that NPC walk towards you. hf.
  15. Offline


    Thanks for your code! I also did some improvements to this amazing code and I think I will setup a github account so people with improvements could add it. If the creator of this lib is ok with that.

    I will look into your code soon!
  16. Offline


    So, what part of the code adds the names above their heads?
  17. Offline


    The rendering of the names is handled client side. This library "fakes" a player connection, so to the clients the NPC is a normal player.
  18. I plan to make a Herobrine plugin with this. It looks convenient.
  19. Offline


    get this plug going man
  20. Offline


    Would you please update this? MobType is removed from the latest bukkit build. Thanks.
  21. Just change it yourself to the new creature class.
  22. Offline


    I was wondering if I can call up a player to right click the npc again to confirm something. Like from being inside an event right click already... It would be something like this.

    > Player Right clicks
    < NPC Tells requirements, and to right click again to confirm
    > Player Right clicks again
    < NPC does action

    So can I call up a Entity Target Event, inside of an Entity Target Event? If not then what can I do to get about the same result?
  23. Offline


    You need storage for what stage the players are up to. Use a hashmap or something.
  24. Offline



    Ok thank you for that, I might just have them execute a slash command to make it easier on myself since I am semi-new to java :p
  25. Offline


    How can I check if an NPC spawned with the NpcSpawner.SpawnBasicHumanNpc method still exists? After I move away from the NPC it gets despawned, and I want to add a check to respwan it when a player returns.
  26. Offline


    Use the NPCList.
  27. Offline


    I have done some more testing. It seems, that when the area with the NPC is unloaded, the NPC disappears. Unless it is in the spawn area - everything works fine there.

    I have added the following code to check where the NPC is and move it a little:
            BasicHumanNpc hnpc = plugin.HumanNPCList.get(args[1]);
            if(hnpc == null)
                sender.sendMessage("Npc not in list.");
                return false;
            HumanEntity hent = hnpc.getBukkitEntity();
            if(hent == null)
                sender.sendMessage("Npc has no bukkit entity.");
                return false;
            Location l = hent.getLocation();
            if(l == null)
                sender.sendMessage("Entity has no location.");
                return false;
            sender.sendMessage("Entity location: "+ l.getX() + ","+l.getY()+","+l.getZ());
            hnpc.moveTo(l.getWorld(), l.getX()+1, l.getY(), l.getZ(), l.getYaw(), l.getPitch());
    This is executed in a command. After I spawn the NPC the command works. The NPC moves 1 block and the coordinates are displayed. Then I warp to spawn and back. The command still returns good coordinates, but the NPC is nowhere to be seen. Why does this happen?

    I'm running CraftBukkit build 531 (git-Bukkit-0.0.0-516-gdf87bb3-b531jnks).
  28. Can someone tell me exactly how to install it? I have bukkit and craftbukkit imported, but i don't know how to add the library :S
  29. Offline


    Just add the source files from to your project.
  30. The source will require some modification as it refers to the deprecated MobType class.
Thread Status:
Not open for further replies.

Share This Page