[Lib] [1.7.10] NPCFactory v1.4 - Create walking npcs with custom names and skins!

Discussion in 'Resources' started by lenis0012, May 26, 2014.

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

    lenis0012

    Hey everyone,

    A few days ago, i released a util called ProfileLoader.
    But it did not get the attention i was hoping for.
    So i decided to put it into use in this new resource called NPCFactory.
    It is inspired by Topcat's NPCLib but entirely remade from scratch to support 1.7.9 and offer some unique features.

    Features:
    • Create NPCs
    • Change invulnerability of npc
    • Change npc' yaw
    • Custom name and skin, does not have to match! (see here)
    • Custom events: NPCInteractEvent and NPCDamageEvent
    • Play animations on the statue
    • Make npc look at certain spots and entities (v1.1+)
    • Smooth pathfinding to locations! (see here, v1.2+)
    • Change equipment and item in hand from npc (v1.3+)
    • Cache all uuid's and textures for 30 minutes (v1.4+)
    Download, documentation and source code
    I recommend either downloading the source code and pasting i t into your plugin, or using maven.
    GitHub (source & documentation): https://github.com/lenis0012/NPCFactory
    Javadocs (v1.4): http://lenis0012.com/javadocs/npcfactory/ (Updated)

    Maven
    Add the following repository:
    View code (open)

    HTML:
    <repository>
        <id>dj-tcraft repository</id>
        <url>http://ci.dj-tcraft.nl/plugin/repository/everything/</url>
    </repository>

    And the following dependency (may need to update version):
    View code (open)

    HTML:
    <dependency>
        <groupId>com.lenis0012.bukkit</groupId>
        <artifactId>NPCFactory</artifactId>
        <version>1.4</version> <!-- Use LATEST for latest dev build -->
        <scope>compile</scope>
    </dependency>

    And if you want the code to be shaded into your plugin, add the following build plugin:
    View code (open)

    HTML:
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>1.4</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <relocations>
              <relocation>
                <pattern>NPCFactory</pattern>
                <shadedPattern>com.lenis0012.bukkit.npc</shadedPattern>
              </relocation>
            </relocations>
          </configuration>
        </execution>
      </executions>
    </plugin>
     
  2. Offline

    TwerkinCraft

  3. Offline

    thepaperboy99

    Thanks for this, very useful for what I'm doing. :)
     
  4. Offline

    lenis0012

    Glad i helped you.
    May i know what you are using it for?
    Just curious.

    Bug fix in this commit
    Please update your code if you haven't yet.

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

    thepaperboy99

    I was thinking I was going to use this for an RPG plugin I was thinking about. I'd rather use this then citizens anyways because it's a lot mor compact. But again, thanks!
     
  6. Offline

    lenis0012

    Maybe this photo can convince you:

    Right: Me (lenis0012)
    Left: NPC named lenis0012 with skin of Notch.
    [​IMG]

    You could make npcs with custom names that all have the same skin.
    And much more fancy stuff, the sky is the limit when using NPCFactory.
     
  7. Offline

    thepaperboy99

    Yup, you convinced me xD. You sir, are a genius.
     
  8. Offline

    Quaro

    How its possible? All told me that this is impossible. F***ing liers.
     
    Jamboozlez likes this.
  9. Offline

    lenis0012

    Not when you are called lenis0012 :p
     
    bobacadodl and KingFaris11 like this.
  10. Offline

    Quaro

    lenis0012 I recently asked this, and they told me "impossible", because skin is connected to nameplate. But now i see, its connected to uuid, not nameplate... Never trust this forum.
     
    Jamboozlez likes this.
  11. Offline

    lenis0012

    Its not connected to a uuid tho.
     
  12. Offline

    Phasesaber

    What is it connected to?
     
  13. Offline

    xTrollxDudex

    When did you ask
     
  14. Offline

    lenis0012

    A skin token, which you can receive by loading a player session.

    New update: v1.1
    • Updated javadocs
    • Added lookAt function to look at a specific location. (NPC.lookAt)
    • Added setTarget function to make npc's head follow the player. (NPC.setTarget & NPC.getTarget)
    Comment thoughts pls <3

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

    Onlineids

    maybe a walkTo(Location) method ;)
     
  16. Offline

    Quaro

    lenis0012 Oh you need thoughts. PM me how did you made custom skin independent to nameplate. :D
     
  17. Offline

    Onlineids

    Also check the git ;)
     
  18. Offline

    lenis0012

    player's dont have pathfinding by default.
    Id'd need to work around that.

    But i will look in to that next

    Take a look at this class:
    https://github.com/lenis0012/NPCFac...java/com/lenis0012/bukkit/npc/NPCProfile.java

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

    Quaro

    lenis0012 I know... Skin is based on uuid, which has to be changed in gameprofile.
     
  20. Offline

    lenis0012

    Quaro What do you want to know then?
     
  21. Offline

    bigteddy98

    You can do this pretty easy. Just diguise a mob as a player by cancelling the PacketPlayOutSpawnEntityLiving and send a PacketPlayOutNamedEntitySpawn. This way your "player" acts like a living entity. Living entities do have pathfinders, so you can add and remove your own ones this way too.
     
  22. Offline

    lenis0012

    You are right there.

    However players have heir own benefits too.
    Storing inventories.
    Dropping inventory on death.
    Being able to stand still in the sky.

    And much more.

    Small issue in v1.1
    fixed in last commit (1.2-SNAPSHOT)

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

    mr_snake302

    How I can create NPC with skin from url?
    [​IMG]
     
  24. Offline

    lenis0012

    You cant. Unless you add the skin to a premium mc account
     
  25. Offline

    Deleted user

    lenis0012
    When I made a NPC that follows a player, I had a Queue and every PlayerMove, I'd push the to location into the queue, and every tick, I'd pop a location and make the NPC walk there.

    Because you have no player, you could define a maximum walk distance per tick, then pathfind there by adding to the x, or adding to the z until you get there.
     
  26. Offline

    lenis0012

    You would walk through walls

    Making good progress on pathfinding :)

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

    Deleted user

    lenis0012
    Well, with my method, that's impossible because the player can't walk through walls.

    In order to adapt it, you could use BFS to find a path, and just check if the block you're trying to walk on is air or not.
     
  28. Offline

    lenis0012

    I get a fully generated path from craftbukkit.
    And i loop trhough the points, which are the points i am moving the entity to.
    See https://github.com/lenis0012/NPCFac...in/java/com/lenis0012/bukkit/npc/NPCPath.java
     
  29. Offline

    Deleted user

    lenis0012
    That is really neat!

    lenis0012
    :3 Minecon cape
    I'm so jelly.

    The code is pretty awesome too. Do NPCs obey gravity though?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 9, 2022
  30. Offline

    lenis0012

    Not yet.
    I will add a boolean for it later.

    New update 1.2
    • Added pathfidning to npc's
    • Fixed NPE when lookAt target entity logs out
    • Fixed non-entity damage not being applied
    • Added missing javadocs in NPC.java

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

Share This Page