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

@ -289,7 +289,6 @@
<Content Include="Protocol\Dns\Records\totla.txt" />
<Content Include="Resources\AppIcon.ico" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>test - 192.168.1.29</StartArguments>
<StartArguments>TestBot - localhost</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>

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;
}