Fix indentation level, 3

This commit is contained in:
ORelio 2020-06-29 21:59:04 +02:00
parent 2752e0d21b
commit 2dfc08b45b
2 changed files with 95 additions and 95 deletions

View file

@ -204,8 +204,8 @@ namespace MinecraftClient.Protocol.Handlers
public byte[] ReadNextByteArray(Queue<byte> cache) public byte[] ReadNextByteArray(Queue<byte> cache)
{ {
int len = protocolversion >= Protocol18Handler.MC18Version int len = protocolversion >= Protocol18Handler.MC18Version
? ReadNextVarInt(cache) ? ReadNextVarInt(cache)
: ReadNextShort(cache); : ReadNextShort(cache);
return ReadData(len, cache); return ReadData(len, cache);
} }

View file

@ -263,7 +263,7 @@ namespace MinecraftClient.Protocol.Handlers
//Hide system messages or xp bar messages? //Hide system messages or xp bar messages?
byte messageType = dataTypes.ReadNextByte(packetData); byte messageType = dataTypes.ReadNextByte(packetData);
if ((messageType == 1 && !Settings.DisplaySystemMessages) if ((messageType == 1 && !Settings.DisplaySystemMessages)
|| (messageType == 2 && !Settings.DisplayXPBarMessages)) || (messageType == 2 && !Settings.DisplayXPBarMessages))
break; break;
} }
catch (ArgumentOutOfRangeException) { /* No message type */ } catch (ArgumentOutOfRangeException) { /* No message type */ }
@ -330,8 +330,8 @@ namespace MinecraftClient.Protocol.Handlers
int chunkZ = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData);
bool chunksContinuous = dataTypes.ReadNextBool(packetData); bool chunksContinuous = dataTypes.ReadNextBool(packetData);
ushort chunkMask = protocolversion >= MC19Version ushort chunkMask = protocolversion >= MC19Version
? (ushort)dataTypes.ReadNextVarInt(packetData) ? (ushort)dataTypes.ReadNextVarInt(packetData)
: dataTypes.ReadNextUShort(packetData); : dataTypes.ReadNextUShort(packetData);
if (protocolversion < MC18Version) if (protocolversion < MC18Version)
{ {
ushort addBitmap = dataTypes.ReadNextUShort(packetData); ushort addBitmap = dataTypes.ReadNextUShort(packetData);
@ -343,7 +343,7 @@ namespace MinecraftClient.Protocol.Handlers
else else
{ {
if (protocolversion >= MC114Version) if (protocolversion >= MC114Version)
dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above
if (protocolversion >= MC115Version && chunksContinuous) if (protocolversion >= MC115Version && chunksContinuous)
dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above
int dataSize = dataTypes.ReadNextVarInt(packetData); int dataSize = dataTypes.ReadNextVarInt(packetData);
@ -352,82 +352,82 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketIncomingType.MapData: case PacketIncomingType.MapData:
int mapid = dataTypes.ReadNextVarInt(packetData); int mapid = dataTypes.ReadNextVarInt(packetData);
byte scale = dataTypes.ReadNextByte(packetData); byte scale = dataTypes.ReadNextByte(packetData);
bool trackingposition = dataTypes.ReadNextBool(packetData); bool trackingposition = dataTypes.ReadNextBool(packetData);
bool locked = false; bool locked = false;
if (protocolversion >= MC114Version) if (protocolversion >= MC114Version)
{ {
locked = dataTypes.ReadNextBool(packetData); locked = dataTypes.ReadNextBool(packetData);
} }
int iconcount = dataTypes.ReadNextVarInt(packetData); int iconcount = dataTypes.ReadNextVarInt(packetData);
handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); handler.OnMapData(mapid, scale, trackingposition, locked, iconcount);
break; break;
case PacketIncomingType.Title: case PacketIncomingType.Title:
if (protocolversion >= MC18Version) if (protocolversion >= MC18Version)
{
int action2 = dataTypes.ReadNextVarInt(packetData);
string titletext = String.Empty;
string subtitletext = String.Empty;
string actionbartext = String.Empty;
string json = String.Empty;
int fadein = -1;
int stay = -1;
int fadeout = -1;
if (protocolversion >= MC110Version)
{ {
if (action2 == 0) int action2 = dataTypes.ReadNextVarInt(packetData);
string titletext = String.Empty;
string subtitletext = String.Empty;
string actionbartext = String.Empty;
string json = String.Empty;
int fadein = -1;
int stay = -1;
int fadeout = -1;
if (protocolversion >= MC110Version)
{ {
json = titletext; if (action2 == 0)
titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); {
json = titletext;
titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
else if (action2 == 1)
{
json = subtitletext;
subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
else if (action2 == 2)
{
json = actionbartext;
actionbartext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
else if (action2 == 3)
{
fadein = dataTypes.ReadNextInt(packetData);
stay = dataTypes.ReadNextInt(packetData);
fadeout = dataTypes.ReadNextInt(packetData);
}
} }
else if (action2 == 1) else
{ {
json = subtitletext; if (action2 == 0)
subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); {
} json = titletext;
else if (action2 == 2) titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
{ }
json = actionbartext; else if (action2 == 1)
actionbartext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); {
} json = subtitletext;
else if (action2 == 3) subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
{ }
fadein = dataTypes.ReadNextInt(packetData); else if (action2 == 2)
stay = dataTypes.ReadNextInt(packetData); {
fadeout = dataTypes.ReadNextInt(packetData); fadein = dataTypes.ReadNextInt(packetData);
stay = dataTypes.ReadNextInt(packetData);
fadeout = dataTypes.ReadNextInt(packetData);
}
} }
handler.OnTitle(action2, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json);
} }
else break;
{
if (action2 == 0)
{
json = titletext;
titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
else if (action2 == 1)
{
json = subtitletext;
subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
else if (action2 == 2)
{
fadein = dataTypes.ReadNextInt(packetData);
stay = dataTypes.ReadNextInt(packetData);
fadeout = dataTypes.ReadNextInt(packetData);
}
}
handler.OnTitle(action2, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json);
}
break;
case PacketIncomingType.MultiBlockChange: case PacketIncomingType.MultiBlockChange:
if (handler.GetTerrainEnabled()) if (handler.GetTerrainEnabled())
{ {
int chunkX = dataTypes.ReadNextInt(packetData); int chunkX = dataTypes.ReadNextInt(packetData);
int chunkZ = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData);
int recordCount = protocolversion < MC18Version int recordCount = protocolversion < MC18Version
? (int)dataTypes.ReadNextShort(packetData) ? (int)dataTypes.ReadNextShort(packetData)
: dataTypes.ReadNextVarInt(packetData); : dataTypes.ReadNextVarInt(packetData);
for (int i = 0; i < recordCount; i++) for (int i = 0; i < recordCount; i++)
{ {
@ -504,8 +504,8 @@ namespace MinecraftClient.Protocol.Handlers
chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData); chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData);
addBitmaps[chunkColumnNo] = protocolversion < MC18Version addBitmaps[chunkColumnNo] = protocolversion < MC18Version
? dataTypes.ReadNextUShort(packetData) ? dataTypes.ReadNextUShort(packetData)
: (ushort)0; : (ushort)0;
} }
//Process chunk records //Process chunk records
@ -694,14 +694,14 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketIncomingType.EntityEquipment: case PacketIncomingType.EntityEquipment:
if (handler.GetEntityHandlingEnabled()) if (handler.GetEntityHandlingEnabled())
{ {
int entityid = dataTypes.ReadNextVarInt(packetData); int entityid = dataTypes.ReadNextVarInt(packetData);
int slot2 = dataTypes.ReadNextVarInt(packetData); int slot2 = dataTypes.ReadNextVarInt(packetData);
Item item = dataTypes.ReadNextItemSlot(packetData); Item item = dataTypes.ReadNextItemSlot(packetData);
handler.OnEntityEquipment(entityid, slot2, item); handler.OnEntityEquipment(entityid, slot2, item);
} }
break; break;
case PacketIncomingType.SpawnLivingEntity: case PacketIncomingType.SpawnLivingEntity:
if (handler.GetEntityHandlingEnabled()) if (handler.GetEntityHandlingEnabled())
{ {
@ -860,13 +860,13 @@ namespace MinecraftClient.Protocol.Handlers
if (innerException is ThreadAbortException || innerException is SocketException || innerException.InnerException is SocketException) if (innerException is ThreadAbortException || innerException is SocketException || innerException.InnerException is SocketException)
throw; //Thread abort or Connection lost rather than invalid data throw; //Thread abort or Connection lost rather than invalid data
throw new System.IO.InvalidDataException( throw new System.IO.InvalidDataException(
String.Format("Failed to process incoming packet of type {0}. (PacketID: {1}, Protocol: {2}, LoginPhase: {3}, InnerException: {4}).", String.Format("Failed to process incoming packet of type {0}. (PacketID: {1}, Protocol: {2}, LoginPhase: {3}, InnerException: {4}).",
Protocol18PacketTypes.GetPacketIncomingType(packetID, protocolversion), Protocol18PacketTypes.GetPacketIncomingType(packetID, protocolversion),
packetID, packetID,
protocolversion, protocolversion,
login_phase, login_phase,
innerException.GetType()), innerException.GetType()),
innerException); innerException);
} }
} }
@ -1175,8 +1175,8 @@ namespace MinecraftClient.Protocol.Handlers
public int GetMaxChatMessageLength() public int GetMaxChatMessageLength()
{ {
return protocolversion > MC110Version return protocolversion > MC110Version
? 256 ? 256
: 100; : 100;
} }
/// <summary> /// <summary>
@ -1271,8 +1271,8 @@ namespace MinecraftClient.Protocol.Handlers
fields.AddRange(dataTypes.GetString(language)); fields.AddRange(dataTypes.GetString(language));
fields.Add(viewDistance); fields.Add(viewDistance);
fields.AddRange(protocolversion >= MC19Version fields.AddRange(protocolversion >= MC19Version
? dataTypes.GetVarInt(chatMode) ? dataTypes.GetVarInt(chatMode)
: new byte[] { chatMode }); : new byte[] { chatMode });
fields.Add(chatColors ? (byte)1 : (byte)0); fields.Add(chatColors ? (byte)1 : (byte)0);
if (protocolversion < MC18Version) if (protocolversion < MC18Version)
{ {
@ -1317,8 +1317,8 @@ namespace MinecraftClient.Protocol.Handlers
dataTypes.GetDouble(location.X), dataTypes.GetDouble(location.X),
dataTypes.GetDouble(location.Y), dataTypes.GetDouble(location.Y),
protocolversion < MC18Version protocolversion < MC18Version
? dataTypes.GetDouble(location.Y + 1.62) ? dataTypes.GetDouble(location.Y + 1.62)
: new byte[0], : new byte[0],
dataTypes.GetDouble(location.Z), dataTypes.GetDouble(location.Z),
yawpitch, yawpitch,
new byte[] { onGround ? (byte)1 : (byte)0 })); new byte[] { onGround ? (byte)1 : (byte)0 }));
@ -1410,9 +1410,9 @@ namespace MinecraftClient.Protocol.Handlers
{ {
if (protocolversion < MC19Version) if (protocolversion < MC19Version)
return false; // Packet does not exist prior to MC 1.9 return false; // Packet does not exist prior to MC 1.9
// According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement // According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement
// MC 1.7 does this using Player Block Placement with special values // MC 1.7 does this using Player Block Placement with special values
// TODO once Player Block Placement is implemented for older versions // TODO once Player Block Placement is implemented for older versions
try try
{ {
List<byte> packet = new List<byte>(); List<byte> packet = new List<byte>();