3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-16 04:50:08 +01:00

Rewrite display name component in player info packet in 1.20.3->.5 (#4136)

Dieser Commit ist enthalten in:
EnZaXD 2024-09-04 20:27:38 +02:00 committet von GitHub
Ursprung 369b076cad
Commit d0b49009e5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 39 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -103,6 +103,7 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol<ClientboundPa
componentRewriter.registerBossEvent(ClientboundPackets1_20_3.BOSS_EVENT); componentRewriter.registerBossEvent(ClientboundPackets1_20_3.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISCONNECT); componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_20_3.TAB_LIST); componentRewriter.registerTabList(ClientboundPackets1_20_3.TAB_LIST);
componentRewriter.registerPlayerInfoUpdate1_20_3(ClientboundPackets1_20_3.PLAYER_INFO_UPDATE);
componentRewriter.registerPing(); componentRewriter.registerPing();
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, wrapper -> { registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, wrapper -> {

Datei anzeigen

@ -40,6 +40,7 @@ import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.SerializerVersion; import com.viaversion.viaversion.util.SerializerVersion;
import com.viaversion.viaversion.util.TagUtil; import com.viaversion.viaversion.util.TagUtil;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
/** /**
* Handles json and tag components, containing methods to override certain parts of the handling. * Handles json and tag components, containing methods to override certain parts of the handling.
@ -139,6 +140,43 @@ public class ComponentRewriter<C extends ClientboundPacketType> implements com.v
}); });
} }
public void registerPlayerInfoUpdate1_20_3(final C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
final BitSet actions = wrapper.passthrough(Types.PROFILE_ACTIONS_ENUM);
if (!actions.get(5)) { // Update display name
return;
}
final int entries = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < entries; i++) {
wrapper.passthrough(Types.UUID);
if (actions.get(0)) {
wrapper.passthrough(Types.STRING); // Player Name
final int properties = wrapper.passthrough(Types.VAR_INT);
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Types.STRING); // Name
wrapper.passthrough(Types.STRING); // Value
wrapper.passthrough(Types.OPTIONAL_STRING); // Signature
}
}
if (actions.get(1) && wrapper.passthrough(Types.BOOLEAN)) {
wrapper.passthrough(Types.UUID); // Session UUID
wrapper.passthrough(Types.PROFILE_KEY);
}
if (actions.get(2)) {
wrapper.passthrough(Types.VAR_INT); // Gamemode
}
if (actions.get(3)) {
wrapper.passthrough(Types.BOOLEAN); // Listed
}
if (actions.get(4)) {
wrapper.passthrough(Types.VAR_INT); // Latency
}
processTag(wrapper.user(), wrapper.passthrough(Types.OPTIONAL_TAG));
}
});
}
public void registerPlayerCombatKill(final C packetType) { public void registerPlayerCombatKill(final C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() { protocol.registerClientbound(packetType, new PacketHandlers() {
@Override @Override