Solved How to make armorstand follow player?

Discussion in 'Spigot Plugin Development' started by ElDub, Nov 14, 2017.

  1. Hello, I'm doing a miniatures plugin for my server, I want an armor stand to follow the player that invoked the armor stand, my code:

    Code (Text):
                  final ArmorStand a = (ArmorStand)player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
                  this.mini.add(player.getName());
                  this.panda.add(player.getName());
                  a.setSmall(true);
                  ItemStack skull1 = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
                  SkullMeta skullmeta = (SkullMeta)skull1.getItemMeta();
                  skullmeta.setOwner("Pandy");
                  skull1.setItemMeta(skullmeta);
                  a.setHelmet(skull1);
                  a.hasArms();
                  ItemStack whitehelmet = new ItemStack(Material.LEATHER_HELMET);
                  ItemStack whitechestplate = new ItemStack(Material.LEATHER_CHESTPLATE);
                  ItemStack whiteleggings = new ItemStack(Material.LEATHER_LEGGINGS);
                  ItemStack whiteboots = new ItemStack(Material.LEATHER_BOOTS);
                  LeatherArmorMeta whitehelmetmeta = (LeatherArmorMeta)whitehelmet.getItemMeta();
                  LeatherArmorMeta whitechestplatemeta = (LeatherArmorMeta)whitechestplate.getItemMeta();
                  LeatherArmorMeta whiteleggingsmeta = (LeatherArmorMeta)whiteleggings.getItemMeta();
                  LeatherArmorMeta whitebbootsmeta = (LeatherArmorMeta)whiteboots.getItemMeta();
                  whitehelmetmeta.setColor(Color.WHITE);
                  whitechestplatemeta.setColor(Color.BLACK);
                  whiteleggingsmeta.setColor(Color.WHITE);
                  whitebbootsmeta.setColor(Color.BLACK);
                  whitechestplate.setItemMeta(whitechestplatemeta);
                  whiteleggings.setItemMeta(whiteleggingsmeta);
                  whiteboots.setItemMeta(whitebbootsmeta);
                  a.setCustomName(player.getName());
                  a.setCustomNameVisible(false);
                  a.getCustomName();
                  a.setArms(true);
                  a.setChestplate(new ItemStack(whitechestplate));
                  a.setLeggings(new ItemStack(whiteleggings));
                  a.setBoots(new ItemStack(whiteboots));
                  a.setBasePlate(false);
                  a.setGravity(true);
                  player.sendMessage("§aYou spawned §b§lPanda");
                  // Code for follow here
    Can someone help?
     
  2. Not sure if this will help but here you can find how to make a living entity walk to a specific tile
     
  3. you can just tp the armor stand to the player location if he moves... i don't know how that works with performance & co.
     
  4. I tried it, but doesn't work the armorstand does not follow me
     
  5. Make an invisible zombie, give it the Pathfinder goal you need with @DestinedToSuffer 's solution and remove everything else. Then every tick, teleport the armorstand to the zombie or set it's velocity so it matches to the zombie. Also update the yaw.

    Make sure to also cancel damage to the zombie and stop it combusting.

    Good luck
     
  6. Hello, @ElDub !

    I use armor stand for miniatures in my resource called ProCosmetics. I use velocity to move the armor stand towards the player.
     
  7. Can I have an example code?
     
  8. It should be pretty simple, just use #setVelocity(). We try to avoid providing code here on the forums :)
     
  9. couldn't you just use a while loop for when the player is moving and to set the x, the y - 1 and the Z?
     
  10. If you can’t solve it by yourself I can help you.
     
  11. Yes, I need help, I'm still learning java, if you can help me I would appreciate it very much
     
  12. While loops on Bukkit servers are no bueno. They halt the main thread.

    Besides, this wouldn't even do what they are asking about.

    The difficulty depends what you're trying to do, really. Mind going into more detail?

    Note though that although we will help guide you in the right direction, we won't (or shouldn't, some of us do anyway..) give code examples or snippets beyond a line or two. Almost always, giving code doesn't help the learning developer progress; rather, it creates more issues when the learning developer doesn't understand the code and comes back for more help.
     
  13. Thanks for helping, I fixed it.
     

Share This Page