3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-25 15:50:12 +01:00

Handle chat and horse container changes

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-05-29 18:29:21 +02:00
Ursprung 9873f279a4
Commit 8fb814ef11
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 55 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -25,7 +25,9 @@ import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.BlockItemPack
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.EntityPacketRewriter1_21;
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.minecraft.item.data.ChatType;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
import com.viaversion.viaversion.api.type.Types;
@ -81,7 +83,6 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerTabList(ClientboundPackets1_21.TAB_LIST);
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISGUISED_CHAT);
translatableRewriter.registerPing();
// Format change we can't properly map - all this really results in is a desync one version earlier
@ -92,6 +93,51 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPac
cancelClientbound(ClientboundConfigurationPackets1_21.CUSTOM_REPORT_DETAILS);
cancelClientbound(ClientboundConfigurationPackets1_21.SERVER_LINKS);
registerClientbound(ClientboundPackets1_21.DISGUISED_CHAT, wrapper -> {
translatableRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.TAG)); // Message
final Holder<ChatType> chatType = wrapper.read(ChatType.TYPE);
if (chatType.isDirect()) {
// Oh well
wrapper.write(Types.VAR_INT, 0);
return;
}
wrapper.write(Types.VAR_INT, chatType.id());
});
registerClientbound(ClientboundPackets1_21.PLAYER_CHAT, wrapper -> {
wrapper.passthrough(Types.UUID); // Sender
wrapper.passthrough(Types.VAR_INT); // Index
wrapper.passthrough(Types.OPTIONAL_SIGNATURE_BYTES); // Signature
wrapper.passthrough(Types.STRING); // Plain content
wrapper.passthrough(Types.LONG); // Timestamp
wrapper.passthrough(Types.LONG); // Salt
final int lastSeen = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < lastSeen; i++) {
final int index = wrapper.passthrough(Types.VAR_INT);
if (index == 0) {
wrapper.passthrough(Types.SIGNATURE_BYTES);
}
}
wrapper.passthrough(Types.OPTIONAL_TAG); // Unsigned content
final int filterMaskType = wrapper.passthrough(Types.VAR_INT);
if (filterMaskType == 2) {
wrapper.passthrough(Types.LONG_ARRAY_PRIMITIVE); // Mask
}
final Holder<ChatType> chatType = wrapper.read(ChatType.TYPE);
if (chatType.isDirect()) {
// Oh well
wrapper.write(Types.VAR_INT, 0);
return;
}
wrapper.write(Types.VAR_INT, chatType.id());
});
registerClientbound(ClientboundPackets1_21.UPDATE_ATTRIBUTES, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Entity ID

Datei anzeigen

@ -81,6 +81,14 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
registerExplosion(ClientboundPackets1_21.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
protocol.registerClientbound(ClientboundPackets1_21.HORSE_SCREEN_OPEN, wrapper -> {
wrapper.passthrough(Types.UNSIGNED_BYTE); // Container id
// From columns to size
final int columns = wrapper.read(Types.VAR_INT);
wrapper.write(Types.VAR_INT, columns * 3 + 1);
});
protocol.registerClientbound(ClientboundPackets1_21.LEVEL_EVENT, wrapper -> {
final int event = wrapper.passthrough(Types.INT);
wrapper.passthrough(Types.BLOCK_POSITION1_14);