Skip to content

Commit 937a2a2

Browse files
authored
Fix server links button not visible in 1.21.5->1.21.6 (ViaVersion#4536)
The Minecraft 1.21.6 client will only show the server links if the the server_links dialog has been sent
1 parent bee45ef commit 937a2a2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

common/src/main/java/com/viaversion/viaversion/protocols/v1_21_5to1_21_6/rewriter/EntityPacketRewriter1_21_6.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package com.viaversion.viaversion.protocols.v1_21_5to1_21_6.rewriter;
1919

20+
import com.viaversion.nbt.tag.CompoundTag;
21+
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
2022
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
2123
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_6;
2224
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_5;
@@ -52,6 +54,14 @@ public void registerPackets() {
5254
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol);
5355
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, registryDataRewriter::handle);
5456

57+
protocol.registerFinishConfiguration(ClientboundConfigurationPackets1_21.FINISH_CONFIGURATION, wrapper -> {
58+
// send server links dialog as vanilla doesn't show server links by default otherwise
59+
final PacketWrapper dialogsPacket = PacketWrapper.create(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper.user());
60+
dialogsPacket.write(Types.STRING, "minecraft:dialog");
61+
dialogsPacket.write(Types.REGISTRY_ENTRY_ARRAY, new RegistryEntry[]{serverLinksDialog()});
62+
dialogsPacket.send(Protocol1_21_5To1_21_6.class);
63+
});
64+
5565
protocol.appendClientbound(ClientboundPackets1_21_5.RESPAWN, wrapper -> {
5666
wrapper.user().get(SneakStorage.class).setSneaking(false);
5767
});
@@ -76,6 +86,30 @@ public void registerPackets() {
7686
});
7787
}
7888

89+
private RegistryEntry serverLinksDialog() {
90+
final CompoundTag serverLinksDialog = new CompoundTag();
91+
serverLinksDialog.putString("type", "minecraft:server_links");
92+
93+
final CompoundTag title = new CompoundTag();
94+
title.putString("translate", "menu.server_links.title");
95+
serverLinksDialog.put("title", title);
96+
97+
final CompoundTag externalTitle = new CompoundTag();
98+
externalTitle.putString("translate", "menu.server_links");
99+
serverLinksDialog.put("external_title", externalTitle);
100+
101+
final CompoundTag exitAction = new CompoundTag();
102+
exitAction.putInt("width", 200);
103+
final CompoundTag exitActionLabel = new CompoundTag();
104+
exitActionLabel.putString("translate", "gui.back");
105+
exitAction.put("label", exitActionLabel);
106+
serverLinksDialog.put("exit_action", exitAction);
107+
108+
serverLinksDialog.putInt("columns", 1);
109+
serverLinksDialog.putInt("button_width", 310);
110+
return new RegistryEntry("server_links", serverLinksDialog);
111+
}
112+
79113
@Override
80114
protected void registerRewrites() {
81115
final EntityDataTypes1_21_5 entityDataTypes = VersionedTypes.V1_21_6.entityDataTypes;

0 commit comments

Comments
 (0)