Handle server stop-sound packets through the existing sound engine

Decode source/event selection flags, including 26.3 UI source 10, and route them to Audio.stop_sounds. Compare all 36 native Java codec selections and round-trip their bytes; reject invalid sources and truncated packets.

Co-Authored-By: Codex (gpt-6.1-sol) <noreply@openai.com>
This commit is contained in:
RVZO6
2026-10-24 23:23:59 -04:00
parent f9e3244281
commit 07519df062
5 changed files with 136 additions and 0 deletions
@@ -0,0 +1,30 @@
package dev.horizonlab.parity;
import com.google.gson.*;
import io.netty.buffer.Unpooled;
import java.nio.file.*;
import java.util.*;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
import net.minecraft.resources.Identifier;
import net.minecraft.sounds.SoundSource;
/** Every source/event selection combination through the native stream codec. */
public final class VanillaStopSoundWireOracle {
public static void main(String[] args) throws Exception {
var out = new ArrayList<String>();
for (int source = -1; source < SoundSource.values().length; source++) {
for (String sound : new String[]{null, "minecraft:entity.pig.ambient", "example:custom"}) {
var packet = new ClientboundStopSoundPacket(sound == null ? null : Identifier.parse(sound), source < 0 ? null : SoundSource.values()[source]);
var buf = new FriendlyByteBuf(Unpooled.buffer());
ClientboundStopSoundPacket.STREAM_CODEC.encode(buf, packet);
byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); buf.release();
var result = new JsonObject(); result.addProperty("wire", HexFormat.of().formatHex(bytes));
result.add("source", source < 0 ? JsonNull.INSTANCE : new JsonPrimitive(source));
result.add("sound", sound == null ? JsonNull.INSTANCE : new JsonPrimitive(sound));
out.add(new Gson().toJson(result));
}
}
Files.write(Path.of(args[0]), out);
}
}