Util Advanced and Custom NPC Util, Create Fake Players. [1.12+] (Packets)

Discussion in 'Resources' started by DanielTheDev, May 9, 2018.

Thread Status:
Not open for further replies.
  1. A long time ago a youtuber called GerVobis made a turtorial video about how to make a custom npc with packets. It was a great success but now in the present the util is outdated and I have not seen any Npc util in 1.12 so I had to update it, and give it a fresh new start in 1.12.

    NPC | FakePlayer erstellen (Packets) - Bukkit/Spigot Plugin Programmieren #85 [Minecraft 1.8] (open)

    I have seen many people attemping to do the same way as he did, I was one of them.
    Then I figured out that the code was changed in the newest NMS (1.12).
    It took me awhile to create / update the code to 1.12 and many people can now use this Util without any issue or NMS changes. The code might not be completely error free but I will keep changing the code if I discover more problems.

    I also added lots of useful functions you can use and I also put descriptions above the methods.
    If there is anything I should change or add to the file just put it down in the comments.
    You can find the link to the source code at the bottom of the post.

    Features:

    - Animation:
    • swing main hand
    • take damage
    • leave bed
    • swing offhand
    • critical effect
    • magic critical effect
    - Status:
    • hurt
    • die
    - Action (These Actions can be stacked up in the Action Builder):
    • on_fire
    • crouched
    • sprinting
    • invisible
    • glowing
    • flying (elyta)
    - Functions:
    • rotateHead
    • teleport
    • setEffect
    • destroy
    • setSleep
    • setEquipment
    • setSkin
    • setDisplayNameAboveHead
    • setTablistName
    • setDisplayName
    - Other Functions:
    • reloadNpc
    • updateProfile
    • removeFromTabList
    • updateToTabList
    • addToTabList

    - Extra: Add/Remove recipients (must set setRecipientType to LISTED_RECIPIENTS or it will be ALL and that means all Online players)


    Code example:
    Code:
            Player player = (Player) //PLAYER;
            Location location = player.getLocation();
            Plugin plugin = this;
    
            final boolean fixhead = true;
            final boolean tablist = true;
    
            NPC npc = new NPC("name", location, plugin);
    
            npc.setRecipientType(Recipient.LISTED_RECIPIENTS); //EDIT THE PACKET RECEIVERS
            npc.addRecipient(player); //ADDING PLAYER TO PACKET RECEIVERS
            npc.setSkin("(texture)", "(signature)"); //SET THE SKIN TEXTURES AND SIGNATURE
            //PRE - INIT
    
            npc.spawn(tablist, fixhead);
            npc.setAnimation(NPCAnimation.SWING_MAIN_HAND);
    
            try {
                npc.setDisplayName("myglobalname");
                npc.setDisplayNameAboveHead("name above head");
            } catch (IOException e) {
                e.printStackTrace();
            }
            npc.setTablistName("my new tablist name");
            npc.setAction(new Action()
                    .setCrouched(true)
                    .setGlowing(true)
                    );
            npc.setEquipment(EnumItemSlot.MAINHAND, new ItemStack(Item.getById(1)));
            npc.setStatus(NPCStatus.HURT);
    
    
            npc.destroy(); //TO DELETE NPC


    Support version: 1.12 / v1_12_R1
    Source Code: NPC.jar
     
    Last edited: Jan 6, 2019
  2. Offline

    PhantomUnicorns

    This is really cool! I'll definitely be saving this. Have you thought about making it with reflection?
     
    Last edited: May 9, 2018
  3. @PhantomUnicorns
    I did make the packets with reflections, and it would be a risk to make the packet instances with reflections because the previous versions do not have a proper variables.
     
  4. The link for sources is not accessible.
     
    DanielTheDev likes this.
  5. I changed it now, it should be fixed.
    Thank you for letting me know
     
  6. Offline

    terturl890

    In 1.13 the skin fails to load, was there an update in code to skins in MC 1.13 causing this to not show?

    The player spawns with the custom name, tablist, and if I have a skin set it will show in the tab list. But I just can't see the skin of the player. The shadow is even there.
     
  7. How can I select an NPC standing in my world? Thanks in Advance
     
Thread Status:
Not open for further replies.

Share This Page