From 3b9ac89d73c5f28b8eefe12f8dc0d9cbaf4647f9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 7 Dec 2023 11:14:04 +0100 Subject: [PATCH] Create pack uuid from hash Fixes #3554 --- .../Protocol1_20_2To1_20.java | 2 ++ .../Protocol1_20_3To1_20_2.java | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java index 8193a41c3..5dd463850 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java @@ -151,6 +151,8 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol { - 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); }; }