Set EntityArmorStand's Equipment

Discussion in 'Spigot Plugin Development' started by BigBlaster10, Jun 10, 2015.

  1. Currently I am trying to send a fake ArmorStand packet to the client. Things such as setting the head position works fine, but setting the armor and item in hand does not seem to work.
    Current Code:
    Code (Text):
    ItemStack head = new ItemStack(Material.LEATHER_HELMET, 1);
    this.stand.setEquipment(0, CraftItemStack.asNMSCopy(head));
    I have tried all values (0-4) for the method, but to no avail. The getEquipment() method does seem to work though which is odd. All help will be greatly appreciated.

    EDIT:
    After a bit of testing, I found a solution that works.
    Code (Text):
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(stand.getId(), slot, new net.minecraft.server.v1_8_R3.ItemStack(Blocks.DIAMOND_BLOCK, 1));
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);    
    Slots:
    0: Hand
    1: boots
    2: leggings
    3: chestplate
    4: helmet
     
    #1 BigBlaster10, Jun 10, 2015
    Last edited: Jun 11, 2015
    • Informative Informative x 2
  2. For newer versions the code is similar:

    Code (Text):
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(this.armorStand.getId(), EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(itemStack));

    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);