From 0949ff4ba957f73557166c710aeed61659203f40 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 20 Nov 2023 19:09:05 +0100 Subject: [PATCH] 1.20.3-pre1 (maybe) --- .../Protocol1_20_2To1_20_3.java | 27 +++++++++++-- .../storage/ResourcepackIDStorage.java | 38 ++++++++++++++++++ .../data/mappings-1.20.3to1.20.2.nbt | Bin 7630 -> 7646 bytes gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/storage/ResourcepackIDStorage.java diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java index 5c6693ce..af56bd67 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java @@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.BlockItemPacketRewriter1_20_3; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3; +import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.storage.ResourcepackIDStorage; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_3; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; @@ -40,11 +41,13 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.Clientbou import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2; +import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundConfigurationPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPackets1_20_3; import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import java.util.BitSet; +import java.util.UUID; public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol { @@ -228,9 +231,8 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol { + final ResourcepackIDStorage storage = wrapper.user().get(ResourcepackIDStorage.class); + wrapper.write(Type.UUID, storage != null ? storage.uuid() : UUID.randomUUID()); + }); + + cancelClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_POP.getId()); + registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.RESOURCE_PACK, wrapper -> { + final ResourcepackIDStorage storage = wrapper.user().get(ResourcepackIDStorage.class); + wrapper.write(Type.UUID, storage != null ? storage.uuid() : UUID.randomUUID()); + }); + registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_PUSH.getId(), ServerboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), resourcePackHandler()); + // TODO Auto map via packet types provider + registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.UPDATE_ENABLED_FEATURES.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_ENABLED_FEATURES.getId()); + registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.UPDATE_TAGS.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId()); } private PacketHandler resourcePackHandler() { return wrapper -> { + final UUID uuid = wrapper.read(Type.UUID); + wrapper.user().put(new ResourcepackIDStorage(uuid)); + wrapper.passthrough(Type.STRING); // Url wrapper.passthrough(Type.STRING); // Hash wrapper.passthrough(Type.BOOLEAN); // Required @@ -331,7 +352,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol. + */ +package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.storage; + +import com.viaversion.viaversion.api.connection.StorableObject; +import java.util.UUID; + +public final class ResourcepackIDStorage implements StorableObject { + private final UUID uuid; + + public ResourcepackIDStorage(final UUID uuid) { + this.uuid = uuid; + } + + public UUID uuid() { + return uuid; + } + + @Override + public boolean clearOnServerSwitch() { + return false; + } +} diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.20.3to1.20.2.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.20.3to1.20.2.nbt index 9e60ea7effc5f4b61612b73a08eaba862d1bd5cb..ef11fb53c3d7b89fda250cadee6e7b14d96de8ed 100644 GIT binary patch delta 37 ncmX?Seb0Ksc@|C=1_p*|Age%{N#C7=hGB*0