|
1 |
| -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections.Concurrent;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.Diagnostics;
|
@@ -72,7 +72,7 @@ class Protocol18Handler : IMinecraftCom
|
72 | 72 | internal const int MC_1_20_2_Version = 764;
|
73 | 73 | internal const int MC_1_20_4_Version = 765;
|
74 | 74 |
|
75 |
| - private int compression_treshold = 0; |
| 75 | + private int compression_treshold = -1; |
76 | 76 | private int autocomplete_transaction_id = 0;
|
77 | 77 | private readonly Dictionary<int, short> window_actions = new();
|
78 | 78 | private CurrentState currentState = CurrentState.Login;
|
@@ -345,7 +345,7 @@ internal Tuple<int, Queue<byte>> ReadNextPacket()
|
345 | 345 |
|
346 | 346 | //Handle packet decompression
|
347 | 347 | if (protocolVersion >= MC_1_8_Version
|
348 |
| - && compression_treshold > 0) |
| 348 | + && compression_treshold >= 0) |
349 | 349 | {
|
350 | 350 | var sizeUncompressed = dataTypes.ReadNextVarInt(packetData);
|
351 | 351 | if (sizeUncompressed != 0) // != 0 means compressed, let's decompress
|
@@ -2196,6 +2196,14 @@ private bool HandlePlayPackets(int packetId, Queue<byte> packetData)
|
2196 | 2196 | if (handler.GetEntityHandlingEnabled())
|
2197 | 2197 | {
|
2198 | 2198 | var entity = dataTypes.ReadNextEntity(packetData, entityPalette, false);
|
| 2199 | + |
| 2200 | + if (protocolVersion >= MC_1_20_2_Version) |
| 2201 | + { |
| 2202 | + if (entity.Type == EntityType.Player) |
| 2203 | + handler.OnSpawnPlayer(entity.ID, entity.UUID, entity.Location, (byte)entity.Yaw, (byte)entity.Pitch); |
| 2204 | + break; |
| 2205 | + } |
| 2206 | + |
2199 | 2207 | handler.OnSpawnEntity(entity);
|
2200 | 2208 | }
|
2201 | 2209 |
|
@@ -2759,7 +2767,7 @@ private void SendPacket(int packetId, IEnumerable<byte> packetData)
|
2759 | 2767 | //The inner packet
|
2760 | 2768 | var thePacket = dataTypes.ConcatBytes(DataTypes.GetVarInt(packetId), packetData.ToArray());
|
2761 | 2769 |
|
2762 |
| - if (compression_treshold > 0) //Compression enabled? |
| 2770 | + if (compression_treshold >= 0) //Compression enabled? |
2763 | 2771 | {
|
2764 | 2772 | thePacket = thePacket.Length >= compression_treshold
|
2765 | 2773 | ? dataTypes.ConcatBytes(DataTypes.GetVarInt(thePacket.Length), ZlibUtils.Compress(thePacket))
|
|
0 commit comments