Only soft fail CUSTOM_PAYLOAD content reading (#3873)

Reading of the channel shouldn't be soft failed as the game code only try catches content reading
This commit is contained in:
EnZaXD 2024-05-22 09:44:38 +02:00 committed by GitHub
parent 01589b3c49
commit 9b1c97919c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,10 +81,14 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, new PacketHandlers() {
@Override
protected void register() {
map(Types.STRING); // Channel
handlerSoftFail(Protocol1_20To1_20_2::sanitizeCustomPayload);
}
});
registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, Protocol1_20To1_20_2::sanitizeCustomPayload);
registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, wrapper -> {
wrapper.passthrough(Types.STRING); // Channel
sanitizeCustomPayload(wrapper);
});
registerClientbound(ClientboundPackets1_19_4.RESOURCE_PACK, wrapper -> {
final String url = wrapper.passthrough(Types.STRING);
@ -205,7 +209,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
}
private static void sanitizeCustomPayload(final PacketWrapper wrapper) {
final String channel = Key.namespaced(wrapper.passthrough(Types.STRING));
final String channel = Key.namespaced(wrapper.get(Types.STRING, 0));
if (channel.equals("minecraft:brand")) {
wrapper.passthrough(Types.STRING);
wrapper.clearInputBuffer();