NpcSpawner lib - spawn basic NPCs

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

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

    Lolmewn

    Hooray! Thank you!
     
  2. Offline

    okami35

    Ni ideas about eclipse? I don't understand why i have some errors when I import your lib in eclipse...

    Thank you
     
  3. Offline

    Top_Cat

    It hasn't been in that namespace for months, https://github.com/Top-Cat/NPCLib/
     
  4. Offline

    Lolmewn

  5. Offline

    Top_Cat

     
  6. Offline

    Lolmewn

    Oh, right.
    Misunderstood you there.
     
  7. Offline

    Abrupt

    is this still being updated? seems to not work with craftbukkit build 1337. NetworkManager.a(Packet) no longer exists, but NetworkManager.queue(Packet) does, I'm assuming the function was renamed from a(Packet) to queue(Packet)?

    the other thing was with BServer.getSpawnProtectionRadius(). they changed it so you must now retrieve the spawn radius like this: mcServer.server.getSpawnRadius().
     
  8. Offline

    Top_Cat

    Yes it's being updated, and I have no idea how those were missed...

    EDIT: In face I found a few diffs between our branches :/
     
  9. Offline

    orange451

    Any ieda on why it crashes the server somtimes when an NPC is created yet?
     
  10. Offline

    randomman159

    This is working pretty well for me. But anyone have any idea how i can make the NPC's head follow a nearby player? Also, i was wondering whether there was some way to make the NPC just randomly wander.

    Thanks :)
     
  11. Offline

    subanoomic

    Hi at all,

    with the Top Cat's newest npc lib from github I use to get errors like this very often:

    Code:
    2011-11-16 16:30:18 [INFO] caught npc lib exception:
    2011-11-16 16:30:18 [SEVERE] java.lang.IndexOutOfBoundsException: Index: 52039, Size: 52039
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.rangeCheck(ArrayList.java:571)
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.get(ArrayList.java:349)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:81)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.f_(Entity.java:690)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.aa(Entity.java:221)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.EntityLiving.aa(EntityLiving.java:124)
    2011-11-16 16:30:18 [SEVERE]    at org.martin.bukkit.npclib.NPCManager$1.run(NPCManager.java:45)
    2011-11-16 16:30:18 [SEVERE]    at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    2011-11-16 16:30:18 [SEVERE]    at java.lang.Thread.run(Thread.java:679)
    2011-11-16 16:30:18 [INFO] caught npc lib exception:
    2011-11-16 16:30:18 [SEVERE] java.lang.IndexOutOfBoundsException: Index: 52040, Size: 52040
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.rangeCheck(ArrayList.java:571)
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.get(ArrayList.java:349)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:81)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.f_(Entity.java:690)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.aa(Entity.java:221)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.EntityLiving.aa(EntityLiving.java:124)
    2011-11-16 16:30:18 [SEVERE]    at org.martin.bukkit.npclib.NPCManager$1.run(NPCManager.java:45)
    2011-11-16 16:30:18 [SEVERE]    at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    2011-11-16 16:30:18 [SEVERE]    at java.lang.Thread.run(Thread.java:679)
    2011-11-16 16:30:18 [INFO] caught npc lib exception:
    2011-11-16 16:30:18 [SEVERE] java.lang.IndexOutOfBoundsException: Index: 52041, Size: 52041
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.rangeCheck(ArrayList.java:571)
    2011-11-16 16:30:18 [SEVERE]    at java.util.ArrayList.get(ArrayList.java:349)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.AxisAlignedBB.b(SourceFile:81)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.f_(Entity.java:690)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.Entity.aa(Entity.java:221)
    2011-11-16 16:30:18 [SEVERE]    at net.minecraft.server.EntityLiving.aa(EntityLiving.java:124)
    2011-11-16 16:30:18 [SEVERE]    at org.martin.bukkit.npclib.NPCManager$1.run(NPCManager.java:45)
    2011-11-16 16:30:18 [SEVERE]    at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    2011-11-16 16:30:18 [SEVERE]    at java.lang.Thread.run(Thread.java:679)
    
    This results in the fact that people can't connect to the server anymore and I need to restart the server in order to be able to connect again. Does someone have similar issues? @Top_Cat, do you know what might be the problem and can you fix it?
     
  12. Offline

    okami35

    Hello, just a question,
    How do you do to load a npc texture?
     
  13. Offline

    Top_Cat

    You don't/can't, textures are client side.
     
  14. Offline

    okami35

    Ok, so i will try with spout, it would be possible.
    Thank you for your help.

    edit:
    I have a problem, when i hit a npc, the method

    public void onEntityDamage(EntityDamageEvent event) {
    }

    is never called
    Do you know where is the problem?

    Thank you
     
  15. Offline

    Top_Cat

    Have you registered the event?
     
  16. Offline

    okami35

    Yes of course, i put:

    Code:
    public void onEntityDamage(EntityDamageEvent event) {
    plugin.log.info("test");
    
    ...
    }
    And it works perfectly, but when i attack a npc, nothing.

    Than you for your help
     
  17. Offline

    randomman159


    Anyone know about the head following thing? I need it pretty quickly
     
  18. Offline

    Evangon

    I'm going to be the stupid one: How do I import this into Eclipse.
     
  19. Offline

    randomman159

    @Evangon, it's just put into the project, as if it were your code. drag the "org" folder into your "src" folder, then refresh the project in eclipse.
     
  20. Offline

    Top_Cat

    In onPlayerMove check if a player is close, if they are use the pitch and yaw properties in location and the moveNPC method in the manager
     
  21. Offline

    okami35

    I have another problem with EntityTarget, first this is my code:
    Code:
    public void onEntityTarget(EntityTargetEvent event) {
            if (event instanceof NpcEntityTargetEvent) {
                NpcEntityTargetEvent nevent = (NpcEntityTargetEvent)event;
                if(event.getEntity() instanceof NPCEntity) {
                Player p = (Player)event.getTarget();
                NPCEntity npc = (NPCEntity)event.getEntity();
                p.sendMessage(npc.getName()+": Bienvenu sur Endoria "+p.getName());
                }
                else
                    plugin.log.info("Error");
            }
        }
    And

    Code:
    public void onEnable() {
            // TODO Auto-generated method stub
            npcman = new NPCManager(this);
            PluginManager pm = getServer().getPluginManager();
            entlistener entl = new entlistener(this);
            pm.registerEvent(Event.Type.ENTITY_DAMAGE, entl, Event.Priority.Normal, this);
            pm.registerEvent(Event.Type.ENTITY_TARGET, entl, Event.Priority.Normal, this);
            log.info(prefixe+"Charge, by okami");
        }
    
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(sender instanceof Player) {
                Player player = (Player)sender;
            if(label.equalsIgnoreCase("npc") && args.length == 1) {
                Location loc = player.getLocation();
                NPCEntity npc = npcman.spawnNPC(args[0], loc);
                npc_list.add(npc);
                player.sendMessage("Vous avez fait spawn un npc");
                return true;
            }
     
    ...
    
    }
    But when i right clik on a npc, i have an "Error", because in the method OnTargetEntity, event.getEntity can't be cast as a NPCEntity...
    Do you know where come from the problem?

    Thank you for your help.
     
  22. Offline

    Lolmewn

    Sooo.. 1.0 update soon I hope?
     
  23. Offline

    Abrupt

    sooo... there's no recommended build out?
     
  24. Offline

    Lolmewn

    But there's a build out.
    And I need it <3
     
  25. Offline

    Top_Cat

    Copy of the error would be useful ;)
     
  26. Offline

    okami35

    I have no error, i just have "Error" because it can't cast event.getEntity in NPCEntity:

    Code:
     if(event.getEntity() instanceof NPCEntity) {
                Player p = (Player)event.getTarget();
                NPCEntity npc = (NPCEntity)event.getEntity();
                p.sendMessage(npc.getName()+": Bienvenu sur Endoria "+p.getName());
                }
                else
                    plugin.log.info("Error");
    But i am sure i click on a npc^^

    Thank you for your help
     
  27. Offline

    Top_Cat

    Ah, NPCEntities are nms entities so you need to use getHandle() on the getEntity()
     
  28. Offline

    jeremytrains

    Hi. I am using eclipse and I have placed the java files in the .../[workspace name]/NPCWarehouse/src directory and it shows up on the workspace........with a million errors. In the java build path I have bukkit, craftbukkit, and permissions. The errors are in BasicHumanNPC, CHumanNPC, NPCNetHandler, NPCNetworkManager, and NPCSpawner. (Too many errors to list the exact code). CAN ANYBODY HELP ME?!?!?!?!?
     
  29. Offline

    Abrupt

    well, if you took the time to read the thread you'd realize that that isn't the up to date code.
    https://github.com/Top-Cat/NPCLib
     
  30. Offline

    jeremytrains

    Sorry, I must have missed that part. Oops.... Sorry for the trouble, but thank you.

    Im sorry, I cant find the new thread about the new code. Are there any events associated with this plugin? (onNpcRightClick, onNpcAttack, ect.) or are they the same as before?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
Thread Status:
Not open for further replies.

Share This Page