[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

    MiniDigger

    lenis0012 Ah, thank you, Sir.
    EDIT: This did not solve everything. I still get disconnected when I create the NPC.
    Code:
    [22:58:05 INFO]: MiniDigger issued server command: /npc spawn
    [22:58:05 INFO]: MiniDigger lost connection: Internal Exception: net.minecraft.util.io.netty.handler.codec.EncoderException: java.lang.RuntimeException: An internal error occured.
    [22:58:06 INFO]: MiniDigger left the game.
    [22:58:23 INFO]: MiniDigger[/127.0.0.1:56230] logged in with entity id 20198 at ([Spawn] 969.0, 108.0, 85.0)
    [22:58:23 INFO]: MiniDigger lost connection: Internal Exception: net.minecraft.util.io.netty.handler.codec.EncoderException: java.lang.RuntimeException: An internal error occured.
    [22:58:23 INFO]: MiniDigger left the game.
    Here is my spawn code http://pastebin.com/RNV49t9z
     
  2. Offline

    Goblom

    MiniDigger What server version are you running? 1.7.10 currently breaks NPCs and causes an error like that.
     
  3. Offline

    CeramicTitan Retired Staff

    Pull Request made! :)
     
  4. Offline

    MiniDigger

  5. Offline

    zombiekiller753

    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
     
  6. 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
  7. 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
  8. Offline

    zombiekiller753

    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
     
  9. 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+
     
  10. Offline

    zombiekiller753

    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
     
  11. Offline

    CeramicTitan Retired Staff

  12. Offline

    lenis0012

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

    Binyon13

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

    CeramicTitan Retired Staff

  15. 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
  16. Offline

    CeramicTitan Retired Staff

    You could also do collision checking, but that gets a little hard.
     
  17. 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?
     
  18. Offline

    lenis0012

    skyrimfan1 remove should work...
    Whats the error?
     
  19. 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?
     
  20. 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
     
  21. Offline

    BlueMustache

  22. 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!
     
  23. Offline

    BlueMustache

  24. 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
  25. 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
     
  26. 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?
     
  27. 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);
      }
     
  28. Offline

    CeramicTitan Retired Staff

    What are you doing?

    Code:java
    1. NPCProfile prof;
    2. try {
    3. prof = NPCProfile.loadProfile("Obama", "Dinnerbone");
     
  29. 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.
     
  30. 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.
     
Thread Status:
Not open for further replies.

Share This Page