Create pack uuid from hash

Fixes #3554
This commit is contained in:
Nassim Jahnke 2023-12-07 11:14:04 +01:00
parent 23ba848a69
commit 3b9ac89d73
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 12 additions and 6 deletions

View File

@ -151,6 +151,8 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
configurationState.setClientInformation(clientInformation);
wrapper.cancel();
});
// If these are not queued, they may be received before the server switched its listener state to play
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PLUGIN_MESSAGE));
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.KEEP_ALIVE.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.KEEP_ALIVE));
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.PONG.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PONG));

View File

@ -66,6 +66,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.Entit
import com.viaversion.viaversion.rewriter.SoundRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
@ -352,16 +353,19 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
private PacketHandler resourcePackHandler(final ClientboundPacketType popType) {
return wrapper -> {
wrapper.write(Type.UUID, UUID.randomUUID());
wrapper.passthrough(Type.STRING); // Url
wrapper.passthrough(Type.STRING); // Hash
wrapper.passthrough(Type.BOOLEAN); // Required
convertOptionalComponent(wrapper);
// Drop old resource packs first
final PacketWrapper dropPacksPacket = wrapper.create(popType);
dropPacksPacket.write(Type.OPTIONAL_UUID, null);
dropPacksPacket.send(Protocol1_20_3To1_20_2.class);
// Use the hash to write a pack uuid
final String url = wrapper.read(Type.STRING);
final String hash = wrapper.read(Type.STRING);
wrapper.write(Type.UUID, UUID.nameUUIDFromBytes(hash.getBytes(StandardCharsets.UTF_8)));
wrapper.write(Type.STRING, url);
wrapper.write(Type.STRING, hash);
wrapper.passthrough(Type.BOOLEAN); // Required
convertOptionalComponent(wrapper);
};
}