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 fa9174a15..b47d3c9f9 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 @@ -46,6 +46,7 @@ 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 com.viaversion.viaversion.rewriter.TagRewriter; import java.util.BitSet; import java.util.UUID; @@ -64,6 +65,9 @@ public Protocol1_20_2To1_20_3() { protected void registerPackets() { super.registerPackets(); + final TagRewriter tagRewriter = new TagRewriter<>(this); + tagRewriter.registerGeneric(ClientboundPackets1_20_3.TAGS); + final SoundRewriter soundRewriter = new SoundRewriter<>(this); soundRewriter.register1_19_3Sound(ClientboundPackets1_20_3.SOUND); soundRewriter.registerEntitySound(ClientboundPackets1_20_3.ENTITY_SOUND); @@ -305,24 +309,15 @@ public void register() { cancelClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_POP.getId()); registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.RESOURCE_PACK, resourcePackStatusHandler()); registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_PUSH.getId(), ServerboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), resourcePackHandler()); + registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.UPDATE_TAGS.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), tagRewriter.getGenericHandler()); // 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 resourcePackStatusHandler() { return wrapper -> { final ResourcepackIDStorage storage = wrapper.user().get(ResourcepackIDStorage.class); wrapper.write(Type.UUID, storage != null ? storage.uuid() : UUID.randomUUID()); - - final int action = wrapper.read(Type.VAR_INT); - if (action == 4) { // Downloaded - wrapper.cancel(); - } else if (action > 4) { // Invalid url, failed reload, and discarded - wrapper.write(Type.VAR_INT, 2); // Failed download - } else { - wrapper.write(Type.VAR_INT, action); - } }; } diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java index c8ec6f5e4..9d126d064 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To_99.java @@ -28,9 +28,9 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.data.entity.EntityTrackerBase; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_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; @@ -43,7 +43,7 @@ // Protocol1_20_3To1_20_2 (the ViaVersion protocol class the mappings depend on) // ClientboundPackets1_20_3 // ServerboundPackets1_20_3 -// ClientboundConfigurationPackets1_20_2 +// ClientboundConfigurationPackets1_20_3 // ServerboundConfigurationPackets1_20_2 // EntityTypes1_19_4 (UNMAPPED type) // 1.99, 1.98 @@ -114,7 +114,7 @@ public TranslatableRewriter getTranslatableRewriter() @Override protected ClientboundPacketType clientboundFinishConfigurationPacket() { - return ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION; + return ClientboundConfigurationPackets1_20_3.FINISH_CONFIGURATION; } @Override diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java index 46eeaaffb..b7470c58c 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/EntityPacketRewriter1_99.java @@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_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; // Replace if needed @@ -43,7 +43,7 @@ public void registerPackets() { registerMetadataRewriter(ClientboundPackets1_20_3.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_3.METADATA_LIST); // Specify old and new metadata list if changed registerRemoveEntities(ClientboundPackets1_20_3.REMOVE_ENTITIES); - protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, new PacketHandlers() { + protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() { @Override protected void register() { map(Type.COMPOUND_TAG); // Registry data