Add GetShort() method in dataTypes

This commit is contained in:
ReinforceZwei 2020-03-27 13:24:52 +08:00 committed by ORelio
parent 311815be9f
commit 137855a71d
4 changed files with 14 additions and 6 deletions

View file

@ -412,6 +412,18 @@ namespace MinecraftClient.Protocol.Handlers
return bytes.ToArray();
}
/// <summary>
/// Get byte array representing a short
/// </summary>
/// <param name="number">Short to process</param>
/// <returns>Array ready to send</returns>
public byte[] GetShort(short number)
{
byte[] theShort = BitConverter.GetBytes(number);
Array.Reverse(theShort);
return theShort;
}
/// <summary>
/// Get byte array representing a double
/// </summary>

View file

@ -1366,10 +1366,7 @@ namespace MinecraftClient.Protocol.Handlers
try
{
List<byte> packet = new List<byte>();
// short to byte (?
byte[] b = BitConverter.GetBytes(slot);
Array.Reverse(b);
packet.AddRange(b);
packet.AddRange(dataTypes.GetShort(slot));
SendPacket(PacketOutgoingType.HeldItemChange, packet);
return true;
}