[1.13.2] Hitting ArmorStand with no sound

Discussion in 'Spigot Plugin Development' started by i998979, Oct 21, 2019.

  1. So recently I am trying to replicate something like this, and I made most of the parts I need.

    What I am trying to do is, when player Left-click the armor stand, it won't make any sound.

    I've thought the following method:
    - Cancel the Sound packet (not tried yet)
    - Apply as.setMarker(true);, but the side effect is the armor stand will disappear when the player is close to the armor stand, which I don't want to
    - Send ArmorStand as a packet (Every player should be able to see the armor stand and arrow can deal damage to the armor stand, so this shouldn't be a solution)
    - Resize the Hitbox of the armor stand (Code copied from VehiclePlusLite)
    Code (Text):
    public void setHitbox(ArmorStand a, Vector v) {
            EntityArmorStand seat = ((CraftArmorStand)a).getHandle();
            seat.setSize(v.getBlockX(), v.getBlockX());
    I am sure that it is possible to remove the sound when hitting ArmorStand, so is it only possible to cancel the Sound packet?
    If yes, how?

    Thank you.
  2. Yea that's possible. The packet you're proabably looking for is the Named Sound Effect. Which you can cancel from sending. The easiest solution would be to just use ProtocolLib for that. Add a packet listener for PacketType.Play.Server.NAMED_SOUND_EFFECT, check for the name of the sound (there's a link to all sounds and their names in the wiki i linked you) and cancel the event.
  3. Thanks for your reply. But I want to ask how can I cancel the exact sound packet when the player attacks the armor stand?