[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

    @someguyonthestreet I think you can set the npc visible or not. or try to add some potion effects to it. with the teleportation I had once that the y is set higher each time. perhaps that can solve it
     
  2. how would you do both of them?
     
  3. Offline

    fullwall

  4. Offline

    guitargun

    @fullwall thx. I will look into this. how can I access this humancontroller?
     
  5. Offline

    suitinacow

    is there a way to set a NPC based on a file instead of a username? i have 10 different skins for multiple classes in my rpg server and need to set them to NPC's.. i cant buy 10 new accounts
     
  6. Offline

    sebagius7110

    How would I use an NPCRightClickEvent to open a GUI if the name is equal to "JJ" (without quotes)
     
  7. Offline

    guitargun

    @fullwall I tried looking into that human controller but I am stuck.... I got the gameprofile etc. form another class but I can't figure out how to use that profile with the npc itself. looking into the code you provided it looks impossible to add a third party gameprofile and it is only possible with a gameprofile playername... which is not what I want to use in this case since that connects to an existing minecraft account.
     
  8. Offline

    fullwall

    @guitargun - you can add the "textures" property manually to the attached gameprofile.
     
  9. Offline

    guitargun

    @fullwall so if I am correct I need to get the bukkitentity (returns player) get its gameprofile then attach the texture to it?

    so I did this:
    Code:
            String url = returnUrl(name);
            CraftPlayer pl  = (CraftPlayer) player;
            GameProfile prof =  pl.getProfile();
            PropertyMap pm = prof.getProperties();
          
            if(pm == null){
                throw new IllegalArgumentException("Profile doesn't contain a property map");
            }
          
            pm.put("textures", new Property("textures",  Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url + "\"}}}")));
    still doesn't work

    also how can I acces this npc's gameprofile? I tried a few casts but they didn't work,.
     
    Last edited: Aug 3, 2015
  10. Offline

    fullwall

  11. Offline

    Malpika

    Hi, I have this problem :(

    This does not work, NPC does not walk, he teleports to that point. However if I put an entity, the NPC walk
    Code:
    npc.getNavigator().setTarget(new Location(p.getWorld(), 0, 0, 0));
    And this is a log. Thank you :)

    Code:
    [13:06:37] [Server thread/ERROR]: Error occurred while enabling agar v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: Trait class must have a no-arguments constructor
        at net.citizensnpcs.api.trait.TraitInfo.create(TraitInfo.java:74) ~[?:?]
        at com.desi.Main.onEnable(Main.java:84) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:341) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:313) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:406) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:370) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:325) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:235) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:503) [craftbukkit-1.8.7.jar:git-Bukkit-d27e6d0]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_71]
    [13:06:37] [Server thread/INFO]: [Essentials] Enabling Essentials vTeamCity
     
    Last edited: Aug 28, 2015
  12. Offline

    fullwall

    @Malpika - your trait class should have a constructor without any arguments like this:

    public Example(){super("example");}

    The NPC teleports if he is too far away from the destination.
     
  13. Offline

    SeamusMcFreak

    Why is this not working? They are no console errors or no IDE errors.
    Code:
    @EventHandler
        public void onNPCClick(NPCClickEvent e){
            Player p = e.getClicker();
            p.sendMessage("STOP");
        }
    Main.class:
    Code:
    public void onEnable(){
            registerEvents();
        }
        public void registerEvents() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(new Events(), this);
        
        }
    }
     
    Last edited by a moderator: Jan 29, 2016
  14. Offline

    ALonelyBoy

    Hi. I did manage to create the bot and i did manage to make it attack enemys. But i can't make the trait work for me. I did everything like you did in the tutorial and i also tryed some other ways to fix it but nothing rly worked like i wanted it to do. Could someone send an example on how to create a trait and also pls put some things in it just to be sure. ;)
     
  15. Offline

    WolfKingNick

    how would i set its skin?
     
  16. Offline

    LRK

    @fullwall or somebody else:

    How can I make a NPC use the rod ?
    I already tried spawning a fishing_hook and animating Item use but everything ended up in an error.
    Any help would be great!
     
  17. Offline

    936796603

    How to let npc get equipment

    this is my error info
    QQ图片20180731144414.png
    QQ图片20180731144417.png
     
    Last edited by a moderator: Jul 31, 2018
Thread Status:
Not open for further replies.

Share This Page