diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 00130355a..7250862ca 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -82,7 +82,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_18_2 = register(758, "1.18.2"); public static final ProtocolVersion v1_19 = register(759, "1.19"); public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/2", new VersionRange("1.19", 1, 2)); - public static final ProtocolVersion v1_19_3 = register(761, 104, "1.19.3"); + public static final ProtocolVersion v1_19_3 = register(761, 105, "1.19.3"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static ProtocolVersion register(int version, String name) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java index 77cf8b206..b1e5e73e2 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java @@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; -import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; import com.viaversion.viaversion.api.protocol.AbstractProtocol; @@ -39,19 +38,16 @@ import com.viaversion.viaversion.api.type.types.version.Types1_19_3; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.kyori.adventure.text.Component; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets.EntityPackets; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets.InventoryPackets; -import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.storage.NonceStorage; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.storage.ReceivedMessagesStorage; import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; -import com.viaversion.viaversion.util.CipherUtil; import java.util.UUID; @@ -233,51 +229,19 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { - final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY); - wrapper.write(Type.OPTIONAL_PROFILE_KEY, null); - if (profileKey == null) { - wrapper.user().put(new NonceStorage(null)); - } - }); - } - }); - registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() { - @Override - public void registerMap() { - map(Type.STRING); // Server id - handler(wrapper -> { - if (wrapper.user().has(NonceStorage.class)) { - return; - } - final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); - final byte[] nonce = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE); - wrapper.user().put(new NonceStorage(CipherUtil.encryptNonce(publicKey, nonce))); - }); + create(Type.OPTIONAL_PROFILE_KEY, null); } }); registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() { @Override public void registerMap() { map(Type.BYTE_ARRAY_PRIMITIVE); // Keys - handler(wrapper -> { - final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class); - if (nonceStorage.nonce() == null) { - return; - } - - final boolean isNonce = wrapper.read(Type.BOOLEAN); - wrapper.write(Type.BOOLEAN, true); - if (!isNonce) { // Should never be true at this point, but /shrug otherwise - wrapper.read(Type.LONG); // Salt - wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, nonceStorage.nonce()); - } - }); + create(Type.BOOLEAN, true); // Is nonce + map(Type.BYTE_ARRAY_PRIMITIVE); // Encrypted challenge } }); + cancelServerbound(ServerboundPackets1_19_3.CHAT_SESSION_UPDATE); cancelClientbound(ClientboundPackets1_19_1.DELETE_CHAT_MESSAGE); cancelClientbound(ClientboundPackets1_19_1.PLAYER_CHAT_HEADER); cancelClientbound(ClientboundPackets1_19_1.CHAT_PREVIEW); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/ServerboundPackets1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/ServerboundPackets1_19_3.java index e6b807a88..2f035e9ba 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/ServerboundPackets1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/ServerboundPackets1_19_3.java @@ -53,6 +53,7 @@ public enum ServerboundPackets1_19_3 implements ServerboundPacketType { ENTITY_ACTION, // 0x1D STEER_VEHICLE, // 0x1E PONG, // 0x1F + CHAT_SESSION_UPDATE, RECIPE_BOOK_DATA, // 0x20 SEEN_RECIPE, // 0x21 RENAME_ITEM, // 0x22 diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java index 9f2e23866..db2f6437a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java @@ -126,10 +126,13 @@ public final class EntityPackets extends EntityRewriter final int ping = wrapper.read(Type.VAR_INT); final JsonElement displayName = wrapper.read(Type.OPTIONAL_COMPONENT); final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY); - - // Salvage signed chat - wrapper.write(Type.UUID, UUID.randomUUID()); - wrapper.write(Type.OPTIONAL_PROFILE_KEY, profileKey); + if (profileKey != null) { + wrapper.write(Type.BOOLEAN, true); + wrapper.write(Type.UUID, UUID.randomUUID()); + wrapper.write(Type.PROFILE_KEY, profileKey); + } else { + wrapper.write(Type.BOOLEAN, false); + } wrapper.write(Type.VAR_INT, gamemode); wrapper.write(Type.BOOLEAN, true); // Also update listed diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/storage/NonceStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/storage/NonceStorage.java deleted file mode 100644 index dceed3e00..000000000 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/storage/NonceStorage.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2022 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.storage; - -import com.viaversion.viaversion.api.connection.StorableObject; -import org.checkerframework.checker.nullness.qual.Nullable; - -public final class NonceStorage implements StorableObject { - - private final byte[] nonce; - - public NonceStorage(final byte @Nullable[] nonce) { - this.nonce = nonce; - } - - public byte @Nullable [] nonce() { - return nonce; - } -} diff --git a/gradle.properties b/gradle.properties index b269f9bda..76f9e1a04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.5.0-22w42a-SNAPSHOT +projectVersion=4.5.0-22w43a-SNAPSHOT # Gradle properties org.gradle.daemon=true