Skip to content

Missing STOP_SOUND / WrapperPlayServerStopSound #1547

Description

@WouterGritter

Unfortunately, it seems like currently there is no packet wrapper for the "stop sound" packet.

// PacketType line 1408
STOP_SOUND(null),

Is there a (historical) reason for this? Would there be anything that would prevent this packet from being added? For my usecase, I'd like to be able to send this packet through packetevents to stop all currently active sounds on the client.

I had Claude Opus 4.8 have a go and it suggested the following implementation. Happy to make a PR if this looks like the right direction.

public class WrapperPlayServerStopSound extends PacketWrapper<WrapperPlayServerStopSound> {

    private @Nullable SoundCategory category; // null = all categories
    private @Nullable ResourceLocation sound; // null = all sounds

    public WrapperPlayServerStopSound(@Nullable SoundCategory category, @Nullable ResourceLocation sound) {
        super(PacketType.Play.Server.STOP_SOUND);
        this.category = category;
        this.sound = sound;
    }

    public WrapperPlayServerStopSound(PacketSendEvent event) {
        super(event);
    }

    @Override
    public void write() {
        int flags = (category != null ? 0x01 : 0) | (sound != null ? 0x02 : 0);
        writeByte(flags);
        if (category != null) writeVarInt(category.ordinal());
        if (sound != null)    writeIdentifier(sound);
    }

    @Override
    public void read() {
        int flags = readByte();
        category = (flags & 0x01) != 0 ? SoundCategory.values()[readVarInt()] : null;
        sound = (flags & 0x02) != 0 ? readIdentifier() : null;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions