Util Advanced NPC Util. [1.17] (Packets)

Discussion in 'Resources' started by DanielTheDev, Jun 25, 2021.

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

    DanielTheDev

    Regarding the new 1.17 update that was recently released, I have decided to create a new NPC Wrapper for this minecraft version. In the past I made one for 1.12 but it was less advanced. But now I can proudly say that all interactive functionalities within the NPC Wrapper are included besides Path finding and Physics.

    Feel free to post any suggestions regarding this Wrapper.

    Find code here

    Functionalities
    • Custum tablist and nametag [Color support]
    • Tablist ping bar + head texture
    • Custom skin textures. [Mojang API Included]
    • Gamemode
    • Nametag visibility
    • Teleportation and rotation
    • Item Equipment
    • Animations
    • Passengers
    • Shaking
    • Potion effect color
    • Entity Arrows
    • Poses
    • Entity States
    • Custom name + visibility
    • Skin customization
    • Shoulder entities [Parrots]
    • Much more..... (see NPCMetaData class)




    Spawn NPC
    Code:
    Location spawnLocation = receiver.getLocation();
    NPC npc = new NPC(spawnLocation, "Steve");
    npc.setPing(NPC.Ping.FOUR_BARS);
    npc.setGameMode(NPC.Gamemode.CREATIVE);
    npc.spawnNPC(receiver);


    Delete NPC
    Code:
    Location spawnLocation = receiver.getLocation();
    NPC npc = new NPC(spawnLocation, "Steve");
    npc.spawnNPC(receiver);
    npc.destroyNPC(receiver);


    Set Skin
    Code:
    NPC.SkinTextures.getByUsername(this, "DanielTheDev", (success,skin)->{
    
       if(success) {
            Location spawnLocation = receiver.getLocation();
            NPC npc = new NPC(spawnLocation, "Steve");
            npc.setSkin(skin);
            npc.spawnNPC(receiver);
       }
    });

    Set Skin without callback
    Code:
    NPC npc = new NPC(spawnLocation, "Steve");
    npc.spawnNPC(receiver);
    npc.setASyncSkinByUsername(this, receiver, "DanielTheDev");



    Set Sleeping and Freezing

    Code:
    NPC npc = new NPC(spawnLocation, "Steve");
    npc.spawnNPC(receiver);
    npc.setASyncSkinByUsername(this, receiver, "DanielTheDev");
    npc.setNameTagVisibility(receiver, false);
    
    NPC.NPCMetaData metaData = npc.getMetadata();
    metaData.setSkinStatus(NPC.SkinStatus.HAT_ENABLED, NPC.SkinStatus.JACKET_ENABLED);
    metaData.setPose(NPC.Pose.SLEEPING);
    metaData.setShaking();
    npc.updateMetadata(receiver);
    [​IMG]




    Set Pose and Passengers
    Code:
    NPC.SkinTextures.getByUsername(this, "Notch", (success1, skin1) -> {
        NPC.SkinTextures.getByUsername(this, "DanielTheDev", (success2, skin2) -> {
    
            NPC npc1 = new NPC(spawnLocation, "Notch");
            NPC npc2 = new NPC(spawnLocation, "DanielTheDev");
    
            npc1.setSkin(skin1);
            npc1.spawnNPC(receiver);
    
            npc2.setSkin(skin2);
            npc2.spawnNPC(receiver);
    
            npc1.setPassenger(receiver, npc2.getEntityID());
    
            npc1.getMetadata().setPose(NPC.Pose.CROUCHING);
            npc1.updateMetadata(receiver);
       });
    });
    [​IMG]




    Set Equipment and play Animations
    Code:
    NPC.SkinTextures.getByUsername(this, "DanielTheDev", (success2, skin) -> {
    
       final NPC npc = new NPC(spawnLocation, "DanielTheDev");
    
        npc.setSkin(skin);
        npc.spawnNPC(receiver);
    
        npc.setEquipment(receiver, NPC.ItemSlot.HELMET, new ItemStack(Material.GOLD_BLOCK));
        npc.setEquipment(receiver, NPC.ItemSlot.CHESTPLATE, new ItemStack(Material.GOLDEN_CHESTPLATE));
        npc.setEquipment(receiver, NPC.ItemSlot.LEGGINGS, new ItemStack(Material.GOLDEN_LEGGINGS));
        npc.setEquipment(receiver, NPC.ItemSlot.BOOTS, new ItemStack(Material.GOLDEN_BOOTS));
        npc.setEquipment(receiver, NPC.ItemSlot.MAIN_HAND, new ItemStack(Material.GOLDEN_SWORD));
        npc.setEquipment(receiver, NPC.ItemSlot.OFF_HAND, new ItemStack(Material.GOLDEN_SWORD));
    
       new BukkitRunnable() {
    
           boolean left = true;
    
            @Override
           public void run() {
               if(left = !left) {
                    npc.playAnimation(receiver, NPC.Animation.SWING_MAIN_HAND);
               } else {
                    npc.playAnimation(receiver, NPC.Animation.SWING_OFFHAND);
               }
    
    
           }
       }.runTaskTimer(this, 20, 10);
    
    });
    [​IMG]




    Set shoulder entity
    Code:
    NPC.SkinTextures.getByUsername(this, "DanielTheDev", (success2, skin) -> {
    
       final NPC npc = new NPC(spawnLocation, "DanielTheDev");
    
        npc.setSkin(skin);
        npc.spawnNPC(receiver);
    
        npc.getMetadata().setParrotLeftShoulder((parrot -> {
            parrot.setVariant(Parrot.Variant.BLUE);
       }), receiver.getWorld());
    
        npc.getMetadata().setParrotRightShoulder((parrot -> {
            parrot.setVariant(Parrot.Variant.GREEN);
       }), receiver.getWorld());
    
        npc.updateMetadata(receiver);
    
    });
    [​IMG]
     
    cactuspy, davidclue and KarimAKL like this.
Thread Status:
Not open for further replies.

Share This Page