Solved EntityArmorStand#setEquipment() not working?

Discussion in 'Spigot Plugin Development' started by minecraftguy719, Feb 19, 2020.

  1. Hello all I am trying to spawn in an armor stand using packets however I cannot get an item to display in the armor stand's hand. I have tried making it visible to no avail.

    Code (Text):

    private void spawnArmorStand(Player player, Material itemMaterial) {
            CraftWorld worldRaw = (CraftWorld)player.getWorld();
            EntityArmorStand stand = new EntityArmorStand(worldRaw.getHandle(), player.getLocation().getX(),      player.getLocation().getY(), player.getLocation().getZ());
           
            Material headBlock = itemMaterial;
            ItemStack headStack = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(headBlock));
           
            stand.setInvisible(true);
            stand.setEquipment(EnumItemSlot.MAINHAND, headStack);
           
            PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(stand);
            sendPacket(spawnPacket, player);
        }
     
     
  2. Every second post here about armor stands using packets will tell you that you will also have to send out the MetadataPacket
     
  3. I am so sorry I forgot about the MetadataPacket I will try it now
     
  4. your own nms entities must be registerd to bukkit

    do you mean `stand.setInvisible(true);`?! `setInvisible(bool)` makes an entity "INVISIBLE"! to the given bool. Every entity has this value to false as default.
     
  5. I managed to fix this with the following code:
    Code (Text):

    PacketPlayOutEntityEquipment equipment = new PacketPlayOutEntityEquipment(stand.getId(), EnumItemSlot.MAINHAND, headStack);
     
     
    • Informative Informative x 1