[LIB] CitizensAPI - Create NPCs quickly and easily [MC 1.8.x]

Discussion in 'Resources' started by fullwall, Feb 6, 2013.

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

    guitargun

    I noticed that. I tried to use a a* library just need some more testing but it looks like it works
     
  2. Offline

    eyesniper2

    fullwall - Hey, I just have 2 quick questions. What is the best way to change just the skin of a citizen through the api? and how do you change the damage output of an NPC?
     
  3. Offline

    fullwall

  4. Offline

    eyesniper2

  5. Offline

    guitargun

    fullwall if I want to make a monster move to a location using the citizens api should I just use the npc.settarget using the data from the monster?
     
  6. Offline

    fullwall

  7. Offline

    guitargun


    also is there a way with citizens to make a zombie fire an arrow or something like that. (you can also fake it and just wait for the zombie to target a player/other entity then fire it by spawning and using vectors)
     
  8. Offline

    fullwall

    guitargun there are fireProjectile methods if that's what you mean. If you mean with arrows when attacking, you can set the AttackStrategy of the NavigatorParameters
     
  9. Offline

    fullwall

    SkillSam - how are they being mounted/dismounted?
     
  10. Offline

    guitargun


    oke I found a way to acces that AttackStrategy but I only see the handle(livingentity, livingentity). Am I supposed to fill the current entity and the target entity and set the attack range and it goes by itself or is it something else?
     
  11. Offline

    fullwall

    guitargun - you implement AttackStrategy yourself and it will be called with the two entities.
    SkillSam - if you set the passenger directly using NMS no event will be called. If you use Bukkit's methods then it will be called only if the NPC is a Vehicle. Teleport should respect cross-world teleporting.
     
  12. Offline

    fullwall

    SkillSam - maybe with non-standard mounts? I'll need more information on what NPC type is being mounted on etc.
     
  13. Offline

    fullwall

    SkillSam - how is the player dismounting off the slime? There shouldn't be a way once they're mounted (unless you're using controllable?).
     
  14. Offline

    fullwall

    SkillSam - maybe intercepting the packet would work. I'll investigate a bit.
     
  15. Offline

    nielsbwashere

    Hey fullwall
    I tried to make a trait; and when I tried to apply it it said: Cannot register null trait!
    Then after that I tried to make sure that my plugin will only load if Citizens is in; Since my plugin is loaded before citizens; it doesn't work... it always thinks that there is no Citizens since it is loaded before citizens...
    Can I fix that?

    I found how to fix the 'Cannot register null trait'; just use a scheduled event that is delayed by 1/20s which means that it will load after Citizens; now it says: Trait class must have a no-argument constructor... I don't even have a argument constructor? what is going on?

    Fixed it; it was a really weird bug; but I got it!
    Thanks fullwall for making the API!
     
  16. Offline

    guitargun

    fullwall

    everytime I load my server I recieve these errors
    Code:
    [11:26:50] [Craft Scheduler Thread - 0/WARN]: java.lang.RuntimeException: net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileNotFoundException: Server did not find the requested profile
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at net.citizensnpcs.npc.entity.HumanController$UUIDFetcher$1.onProfileLookupFailed(HumanController.java:209)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository.findProfilesByNames(YggdrasilGameProfileRepository.java:64)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at net.citizensnpcs.npc.entity.HumanController$UUIDFetcher.call(HumanController.java:205)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at net.citizensnpcs.npc.entity.HumanController$UUIDFetcher.call(HumanController.java:189)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at net.citizensnpcs.npc.entity.HumanController$SkinFetcher.run(HumanController.java:141)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    at java.lang.Thread.run(Unknown Source)
    [11:26:50] [Craft Scheduler Thread - 0/WARN]: Caused by: net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileNotFoundException: Server did not find the requested profile
    [11:26:50] [Craft Scheduler Thread - 0/WARN]:    ... 9 more
    is that a problem with my connection or is there a different problem?
     
  17. Offline

    fullwall

    guitargun - since when have you been getting that error?
     
  18. Offline

    Monkey_Swag

    nvmd, found it in the javadocs :)
     
  19. Offline

    nielsbwashere

    I'm doing a tutorial on my channel (nielsbwashere) that features this api :)
    I'm stuck at one thing though; swimming NPC's and/or wandering NPC's
    Is there an easy way I could make NPC's swim and/or wander around randomly?
    Thank you :D
    Also; it doesn't seem to work if I add equipment and or an inventory (trait)
    How do I make it update? Thanks :)
    (See the first episode HERE)
     
    Last edited: Dec 12, 2014
  20. Offline

    fullwall

    @nielsbwashere - swimming NPCs are possible through setting navigationparameters. Wandering around is achieved mainly by picking a random location to walk to.
     
  21. Offline

    nielsbwashere

    Sorry for the late reply :S It seems that bukkit forum doesn't email you if someone replies to you :p
    Thanks for your input!

    I didn't see that you could change things in navigation parameters :p so thanks!

    I have one more question: Somewhere online (I don't know where (I've been searching for ages)) I saw an example of checking if an entity can see another entity... do you happen to know how to do that?
     
    Last edited by a moderator: Jan 8, 2015
  22. Offline

    fullwall

  23. Offline

    eyesniper2

    @fullwall Just another quick question. What would be the best way to hook into the builder character and have them run builds when called from another plugin?
     
  24. Offline

    guitargun

    @fullwall I know with citizens you can change the skin to mismatch it from the original name. how do you do this in the api?
     
  25. Offline

    fullwall

    @eyesniper2 - https://github.com/jrbudda/Builder/blob/master/src/net/jrbudda/builder/BuilderTrait.java is the code, I guess you would set trait.schematic to your schematic and call StartBuild

    @guitargun - https://github.com/CitizensDev/Citi...n/java/net/citizensnpcs/api/npc/NPC.java#L313
    npc.data().set(NPC.PLAYER_SKIN_UUID_METADATA, name);

    npc.despawn(DespawnReason.PENDING_RESPAWN);
    npc.spawn(npc.getStoredLocation());

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

    guitargun

    @fullwall
    I recieve this message each time citizens tries to load the skin
    Code:
    [11:42:11] [Server thread/INFO]: [m<[0;31;22mguitargun[m> guitargun[m
    [11:42:11] [Craft Scheduler Thread - 60/WARN]: Exception in thread "Craft Scheduler Thread - 60"
    [11:42:11] [Craft Scheduler Thread - 60/WARN]: org.apache.commons.lang.UnhandledException: Plugin Citizens v2.0.13-SNAPSHOT (build 1157) generated an exception while executing task 441
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
        at net.citizensnpcs.npc.entity.HumanController$SkinFetcher.run(HumanController.java:152)
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71)
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
        ... 3 more
    
    is this something I can fix or not?
     
  27. Offline

    fullwall

    @guitargun - hard to know because you are using an old version.
     
  28. Offline

    guitargun

    @fullwall think that would explain it. I'll update citizens somewhat later today and see if I still have the same error
     
  29. Offline

    guitargun

  30. How would I make an npc invisible, code wise? and is there a gravity method because i want to keep teleporting to a specific spot but all it does is just fall down from where i spawned it
     
Thread Status:
Not open for further replies.

Share This Page