Added Entity Action handling, and A TSneak command that will Toggle Sneak.

This commit is contained in:
CarbonNeuron 2020-05-01 08:28:22 -05:00
parent 9dae40153c
commit 384c804e54
10 changed files with 176 additions and 5 deletions

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Protocol
{
public enum ActionType
{
StartSneaking,
StopSneaking,
LeaveBed,
StartSprinting,
StopSprinting
}
}

View file

@ -17,6 +17,7 @@ namespace MinecraftClient.Protocol.Handlers
ClientSettings,
PluginMessage,
TabComplete,
EntityAction,
PlayerPosition,
PlayerPositionAndLook,
TeleportConfirm,
@ -27,4 +28,4 @@ namespace MinecraftClient.Protocol.Handlers
CloseWindow,
PlayerBlockPlacement
}
}
}

View file

@ -239,6 +239,10 @@ namespace MinecraftClient.Protocol.Handlers
}
else return "";
}
public bool SendEntityAction(int PlayerEntityID, int ActionID)
{
return true;
}
private byte[] readNextByteArray()
{

View file

@ -965,6 +965,22 @@ namespace MinecraftClient.Protocol.Handlers
catch (System.IO.IOException) { return false; }
catch (ObjectDisposedException) { return false; }
}
public bool SendEntityAction(int PlayerEntityID, int ActionID)
{
try
{
List<byte> fields = new List<byte>();
fields.AddRange(dataTypes.GetVarInt(PlayerEntityID));
fields.AddRange(dataTypes.GetVarInt(ActionID));
fields.AddRange(dataTypes.GetVarInt(0));
SendPacket(PacketOutgoingType.EntityAction, fields);
return true;
}
catch (SocketException) { return false; }
catch (System.IO.IOException) { return false; }
catch (ObjectDisposedException) { return false; }
}
/// <summary>
/// Send a respawn packet to the server

View file

@ -85,7 +85,15 @@ namespace MinecraftClient.Protocol
/// <param name="data">packet Data</param>
/// <returns>True if message was successfully sent</returns>
bool SendPluginChannelPacket(string channel, byte[] data);
/// <summary>
/// Send Entity Action packet to the server.
/// </summary>
/// <param name="entityID">PlayerID</param>
/// <param name="type">Type of packet to send</param>
/// <returns>True if packet was successfully sent</returns>
bool SendEntityAction(int EntityID, int type);
/// <summary>
/// Send a held item change packet to the server.
/// </summary>