NpcSpawner lib - spawn basic NPCs

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

Thread Status:
Not open for further replies.
  1. @killgoblen
    1. you have to use a scheduler and run the damage method every second.
    2.if this is the problem i think it is, you have to despawn npc's onDisable
    3.not your fault :p
    4.same
    5.really Haven't tested
    also, my npc's pathfind up hill's fine, but when they do get stuck the server crashes >.<
     
  2. Offline

    Top_Cat

    @tips48 @killgoblen 1. The damage method is running on a scheduler, however not if you reload it will only run for new npcs.
    2, 3, 4. Yes, I fixed it so that it despawns all npcs and cancels the task when the plugin reloads.
    5. Still can't get that to happen, I went 400 blocks away and logged off and on and they were still there
     
  3. Offline

    killgoblen

    That's so weird... Maybe my server is just too lazy to keep track of NPCs. :p

    If you want to see it for yourself, get on my server (204.236.238.82), type /npc <name>, and go far away then go back. It'll be gone!
     
  4. 1.yep :p
    2.AWESOME! xD
    5.Well thats sweet, even though i never noticed and it doesn't apply for my plugin anyway :p
     
  5. Offline

    killgoblen

    @Top_Cat

    Thanks for visiting my server. Remember when I said that it must just work for you? THAT'S TRUE!!

    As soon as you left, I flew away from your NPC, and when I returned, It was gone!! GRAHH! *Facepalm*

    I'll re-download the lib from Github and hope that solves the problem.
    Yep. Still doesn't work. The async task nags are fixed, though! Thanks!

    Ok so I've figured it out. NPCs farther from spawn despawn, but closer to spawn, they don't. Will test it a little more.

    Ah-ha! Got it! If an NPC has an X or Z Co-ordinate greater than 128, they will despawn as I've said. If their Z-co-ord is greater than 128, they become invulnerable when their chunk is unloaded and reloaded.

    And when you said that NPCs keep their chunks loaded, is that just the chunks they are in, or an area of chunks around them like players?
     
  6. Offline

    Top_Cat

    @killgoblen Finally I was able to reproduce this issue :D. A [diamond] for you, so I added some code to re-add the npcs to the world when chunks load. Please test it and tell me if it fixes the issues.

    Sorry I couldn't stay long when I joined but I went back later and had a look around at the cathedral you got going, it's nice :p

    To answer your question about NPCs keeping chunks loaded, it can't be happening at all any more otherwise we wouldn't have these issues, no idea when it changed but they now can be unloaded.

    Also I added a getInventory() method so you can set armor etc for the NPCs and they will drop all items in their inventory on death.
     
  7. Offline

    killgoblen

    @Top_Cat
    Thank you so much! Can't test now, my power is out after a really bad storm and will likely be out until tomorrow.

    Anyway the cathedral (and the rest of what you saw) wasn't me. I'm not artistic enough for that. I'm the official nerd of the server (plugin dev) :p
     
  8. Offline

    desmin88

    @Top_Cat
    They probably didn't despawn because you put them near/in spawn, where chunks don't unload.
     
  9. Offline

    killgoblen

    So what would be the best way to save NPCs to be persistent between reloads? This would include inventories.

    Does anyone know of any good tutorials on making a class Serializable, so I could make my own class that extends NPCEntity and is serializable?
     
  10. Offline

    Top_Cat

    @killgoblen Surely a reload is supposed to restart the plugin not make it persist? If you want that kind of thing maybe save them all in a database and reload it on reload.
     
  11. Offline

    killgoblen

    @Top_Cat:

    Maybe I worded that wrong. I meant to make NPCs still be in the world after the server is restarted or reloaded.

    So if I made an SQLite database with every NPC stored in it, then went through it and individually spawned each one in onEnable(), would that make sense, or should I use a more efficient method?

    On an unrelated note, would it help performance in any significant way if NPCs were not always loaded in RAM, and were instead fetched from an SQL table as needed?
     
  12. Hi and thx for all your work.
    Can you please check this ;

    2011-07-15 14:46:33 [SEVERE] Unexpected exception
    java.lang.IndexOutOfBoundsException: Index: 424, Size: 425
    at java.util.ArrayList.rangeCheck(ArrayList.java:571)
    at java.util.ArrayList.get(ArrayList.java:349)
    at net.minecraft.server.AxisAlignedBB.b(SourceFile:27)
    at net.minecraft.server.AxisAlignedBB.clone(SourceFile:193)
    at net.minecraft.server.Entity.move(Entity.java:368)
    at net.minecraft.server.EntityLiving.a(EntityLiving.java:582)
    at net.minecraft.server.EntityLiving.v(EntityLiving.java:704)
    at net.minecraft.server.EntityMonster.v(EntityMonster.java:26)
    at net.minecraft.server.EntitySkeleton.v(EntitySkeleton.java:45)
    at net.minecraft.server.EntityLiving.m_(EntityLiving.java:218)
    at net.minecraft.server.EntityMonster.m_(EntityMonster.java:30)
    at net.minecraft.server.World.entityJoinedWorld(World.java:1190)
    at net.minecraft.server.WorldServer.entityJoinedWorld(WorldServer.java:48)
    at net.minecraft.server.World.playerJoinedWorld(World.java:1172)
    at net.minecraft.server.World.cleanUp(World.java:1102)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:447)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)

    This happen sometimes while player join server, and make a deadly crash.
    An other thing, random creature spawn a couple of time exactly on the spawned npc... (may be link)

    Cya , and sorry it's not my native language.
     
  13. Offline

    Top_Cat

    @killgoblen Something like that yeah.

    @kTrn That doesn't look like it has anything to do with this, that relates to a Skeleton not an NPC :/
     
  14. Thanks for answer,
    I think that Skeleton was the entity WHO pass thrue the npc.
    I alse saw a friend do the same thing this afternoon, that was randomly and not repeatable.

    OK i see where the crash is comming from!
    The thread who clean the dead entity, call R() method and throw an unexpected(and uncatched from source code side) exception.
    I dont need to kill my npcs, so i put on comment this thread and now all is working fine.. my own cleaning system do this job fine. already 300 npcs at the same chunk with lesser need of memory.

    check this i show some work with your lib (loc 8:30")

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  15. Offline

    killgoblen

    Hey! Thanks for all the work you have done, but I'm still getting an error. Remember that concurrentModficationException in post #183? I still get that when I kill several NPCs with the same name at the same time.
     
  16. Offline

    Graindcafe

    Is this library still works ?
     
  17. Offline

    Top_Cat

  18. Offline

    Graindcafe

    Thank you :)

    In fact I was interested by the spawn monster function that seems to be missing in your forks... My goal is to move a zombie, have you an idea? Can your library help me ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  19. Offline

    Top_Cat

    To move a zombie, spawn one using World.spawnCreature(location, type) and set it's location. There is no need for libraries past bukkit.
     
  20. Offline

    Graindcafe

    No, I want it to walk to a position. I spawn it to a location then, I want it to walk to another one. I don't think I can do this only with bukkit, there is no "setLocation" or "moveTo"
     
  21. Offline

    Top_Cat

    Sadly not, but this lib is not what you want either. You can use the nms and something like this to set a zombie's target to a point:

    Code:
    ((EntityCreature)zombie).pathEntity = ((CraftWorld) world).getHandle().a(vehicle, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 16.0f);
     
  22. Offline

    Graindcafe

    What's the nms ? I think it's well that I want because I've try to do what you tell me to do, but I don't know how to spawn a EntityZombie.
    Thank you very much for your help :)
     
  23. Offline

    Top_Cat

    You'll probably get further if you join the #bukkit dev channel on irc.esper.net
     
  24. Offline

    killgoblen

    Sooooo... I noticed that this is becoming rather inactive. I was planning on using it to make a massive plugin, but before I do, I was wondering if this is still going to be updated if necessary. If not, could someone direct me to another way to spawn NPCs? Thanks for any help!
     
  25. Offline

    Top_Cat

    If you find a problem, I will fix it :)
     
  26. Offline

    killgoblen

    Ok, thanks! Do you think you could, at some point, explain what some of the parts of this lib actually do? I like understanding what I'm working with or I feel like I'm at the mercy of the technology gods. XD
     
  27. Offline

    muCkk

    Hey,
    is there a way to spawn a dead NPC? I need to have a corpse lying around. Sometime there is a bug in Minecraft which causes dead Skeletons to stay. That would be exactly what i need ;).
    (I hope nobody asked that before, I didn't read all pages)
     
  28. Offline

    killgoblen

    @Top_Cat: With the plugin I am making, I want to make a custom NPC class with some new fields and methods. I tried making one that extends NPCEntity, but I'm not sure how to then spawn one. I want to avoid editing the NPCLib code to make it easier to update NPCLib when needed. Any advice?
     
  29. @Top_Cat I dont know if you still have anything to do with this lib, but if you have, is there a way to get a Player or LivingEntity from a NPC?
     
  30. Offline

    Top_Cat

    Same way as any minecraft entity... Entity.getBukkitEntity()
     
Thread Status:
Not open for further replies.

Share This Page