ArmorStand with Packets ClickEvent possible?

Discussion in 'Spigot Plugin Development' started by MXbyme, May 23, 2017.

  1. Hello,
    I spawn Armorstands with Packets
    Code (Text):

            EntityArmorStand entity = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle(),loc.getX(), loc.getY(),loc.getZ());
            entity.setCustomName(name);
            entity.setCustomNameVisible(true);
            entity.setInvisible(true);
            entity.setNoGravity(true);
            entitylist.add(entity);
            for (EntityArmorStand armor : entitylist) {
                PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
            }
    and now i want to know if its possible to get an event when a player click on one of the Armorstands
     
  2. Sure, just listen to the right packets and filter out the packets that aren't targeting your entity.
     
  3. By listening to it. Start by implementing some kind of packet listener (i.e. by using ProtocolLib), ensure you only handle a specific packet type (which ProtocolLib does automatically), then check if the clicked entity was yours.