[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

    CeramicTitan

    Pull Request made! :)
     
  2. Offline

    MiniDigger

  3. Offline

    Deleted user

    lenis0012
    Are you sure it's possible to spawn in an NPC with a custom skin that differs from the NPC username?

    I can't seem to get it to work
     
  4. Offline

    lenis0012

    It looks like it broke in 1.7.10

    1.4-SNAPSHOT does not crash clients.
    However sometimes it does not show the skin, beause mojang returns an error message saying to many requests were send

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

    MiniDigger

    lenis0012 I'll test that

    lenis0012 It's worked, thank you.

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

    Deleted user

    lenis0012
    I think the problem is in how the Client renders players. I took a look and this is what I found:

    When the client receives a "S0CPacketSpawnPlayer", it creates a new AbstractClientPlayer instance.

    Code:
     
        public AbstractClientPlayer(World p_i45074_1_, GameProfile p_i45074_2_)
        {
            super(p_i45074_1_, p_i45074_2_);
            this.setupCustomSkin();
        }
     
        protected void setupCustomSkin()
        {
            String var1 = this.getCommandSenderName();
     
            if (!var1.isEmpty())
            {
                this.locationSkin = getLocationSkin(var1);
                this.locationCape = getLocationCape(var1);
                this.downloadImageSkin = getDownloadImageSkin(this.locationSkin, var1);
                this.downloadImageCape = getDownloadImageCape(this.locationCape, var1);
            }
        }
    
    getCommandSenderName() returns GameProfile#getName()

    Therefore, the skin will always be relative to the username
     
  7. Offline

    lenis0012

    zombiekiller753 Not true.
    I am able to create lenis0012 npc with notch skin like shown above.
    It just doesn't allways work anymore.

    The source code you view is most likely MCP for 1.7.2
    you need 1.7.9+
     
  8. Offline

    Deleted user

    lenis0012
    Hmm. Come to think of it, I have a client that switches back and forth between 1.7.2 and 1.7.9. Let me try with vanilla 1.7.9 and get back to you :p

    EDIT:
    :O
    Turns out the client may have used native 1.7.2 code with packet translation.

    Sorry for all this now-useless talk xD
     
  9. Offline

    CeramicTitan

  10. Offline

    lenis0012

    I couldn't find it.
    Can you send me a link?
     
  11. Offline

    Binyon13

    Is it possible to make the NPC use the swing animation to do damage to players?
     
  12. Offline

    CeramicTitan

  13. Offline

    lenis0012

    Thought i already accepted that one o.o
    I accepted & merged it.

    Yes.
    If you make your own AI that has this basic idea:
    IF npc in x bloxks away from target
    lookat target
    swing arm
    damage target

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

    CeramicTitan

    You could also do collision checking, but that gets a little hard.
     
  15. Offline

    skyrimfan1

    How would I remove a single NPC? I know NPCFactory has the global despawnAll(), but I am not looking for that.

    I've tried calling remove() on the bukkit entity for the NPC, but it just crashes my client (and the server).

    Help?
     
  16. Offline

    lenis0012

    skyrimfan1 remove should work...
    Whats the error?
     
  17. Offline

    BlueMustache

    lenis0012
    Your Java doc is down.
    Great lib btw, but what am I doing wrong here?

    Code:java
    1. public void onPlace(BlockPlaceEvent e){
    2. Block blk = e.getBlockPlaced();
    3. e.setCancelled(true);
    4. UUID uuid = UUID.fromString("44f9d513-268f-433d-b8b9-7b5d3ab6b54d");
    5. NPCFactory fac = new NPCFactory(this);
    6. NPCProfile prof = new NPCProfile("Obama", uuid, "Dinnerbone");
    7. NPC npc = fac.spawnHumanNPC(blk.getLocation(), prof);
    8. npc.setTarget(e.getPlayer());
    9. }


    And I imported everything correctly.
    Please help.
    -Blue

    Also, do I really need a fake uuid?
     
  18. Offline

    lenis0012

    BlueMustache I am doing an update soon.
    There is a few things you need to know:
    For now, use v1.4-SNAPSHOT for 1.7.9 only.
    I recomment parsing: name, name in if you want a different skin and name.
    And you can only create 1 npc per minute as of now, due to the fact that the sessionserver has a crazy delay

    If you follow these rules it will work.
    Ill put javadocs back up soon
     
  19. Offline

    BlueMustache

  20. Offline

    lenis0012

    BlueMustache

    A new 1.4-SNAPSHOT is out.

    You now need to use:
    NPCProfile profile = NPCProfile.loadProfile(displayName, skinOwner);
    Takes care of everything, caches UUID and textures, generates random UUID for metadata, always works.

    Try it out!
     
  21. Offline

    BlueMustache

  22. Offline

    lenis0012

    BlueMustache 1.7.10
    [​IMG]

    Updated to v1.4!
    1.7.10 Only!

    Javadocs is back!

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

    BlueMustache

    lenis0012
    Glad to hear it's back.
    And I noticed it was 1.7.10.
    Also, could you please provide a gist example of how to make a simple NPC.
    Because I have no idea why this is not working.
    Am I just sleep deprived and overlooking something?

    Code:java
    1. public void onPlace(BlockPlaceEvent e){
    2. Block blk = e.getBlockPlaced();
    3. e.setCancelled(true);
    4. NPCFactory fac = new NPCFactory(this);
    5. NPCProfile prof;
    6. try {
    7. prof = NPCProfile.loadProfile("Obama", "Dinnerbone");
    8. NPC npc = fac.spawnHumanNPC(blk.getLocation(), prof);
    9. npc.setTarget(e.getPlayer());
    10. } catch (ExecutionException e1) {
    11. }
    12.  
    13. }


    I did this just as a test.
    The block place isn't being cancelled.
    Tnx,
    -Blue
     
  24. Offline

    skyrimfan1

    BlueMustache
    I think you're just tired.
    Code:java
    1. @EventHandler
    2. public void onPlace(BlockPlaceEvent e){
    3. Block blk = e.getBlockPlaced();
    4. e.setCancelled(true);
    5. NPCFactory fac = new NPCFactory(this);
    6. NPCProfile prof;
    7. ...


    And did you register your listener?
     
  25. Offline

    BlueMustache

    skyrimfan1

    yep.

    Code:
    public class PluginCore extends JavaPlugin
      implements Listener
    {
      public void onEnable()
      {
        getLogger().info("is now enabled");
        PluginManager pm = getServer().getPluginManager();
        pm.registerEvents(this, this);
      }
     
  26. Offline

    CeramicTitan

    What are you doing?

    Code:java
    1. NPCProfile prof;
    2. try {
    3. prof = NPCProfile.loadProfile("Obama", "Dinnerbone");
     
  27. Offline

    BlueMustache

    CeramicTitan
    Just trying to test the LIB.
    How are you guys testing it?
    I have made tons of private plugin stuff, and have great experience.
    I have no idea why this isn't working.
     
  28. Offline

    skyrimfan1

    BlueMustache
    You also forgot to add an EventHandler annotation to the method? I vaguely displayed it in my previous post but forgot to touch on it. That's the only plausible reason I can think of as to why it doesn't work, since you seem to be doing everything else correctly.
     
  29. Offline

    BlueMustache

    skyrimfan1
    Your right!
    Gosh, I have never overlooked anything like that before.
    Won't happen again!
    Thanks, :)
    -Blue

    BlueMustache
    I tested it, it works!
    Finally, I can make an army of combine!

    skyrimfan1
    Lol, above. :D
    Thanks, that was meant for you.

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

    jimbo8

    lenis0012

    Okay, so i'm developing a plugin and i'm trying to open a inventory menu when a player right clicks the NPC, but i don't know which type of entity the NPC is. How can i get the entity type of the NPC to compare?

    I'm using PlayerInteractEntityEvent to compare and open the inventory.

    Edit:

    Tried to print the name of the entity, but it returned null.
     
Thread Status:
Not open for further replies.

Share This Page