using System; using System.Collections.Generic; using System.Linq; using System.Text; using MinecraftClient.Crypto; using MinecraftClient.Mapping; using MinecraftClient.Inventory; namespace MinecraftClient.Protocol { /// /// Interface for the Minecraft protocol handler. /// A protocol handler is used to communicate with the Minecraft server. /// This interface allows to abstract from the underlying minecraft version in other parts of the program. /// The protocol handler will take care of parsing and building the appropriate network packets. /// public interface IMinecraftCom : IDisposable, IAutoComplete { /// /// Start the login procedure once connected to the server /// /// True if login was successful bool Login(); /// /// Disconnect from the server /// void Disconnect(); /// /// Get max length for chat messages /// /// Max length, in characters int GetMaxChatMessageLength(); /// /// Get the current protocol version. /// /// /// Version-specific operations should be handled inside the Protocol handled whenever possible. /// /// Minecraft Protocol version number int GetProtocolVersion(); /// /// Send a chat message or command to the server /// /// Text to send /// True if successfully sent bool SendChatMessage(string message); /// /// Allow to respawn after death /// /// True if packet successfully sent bool SendRespawnPacket(); /// /// Inform the server of the client being used to connect /// /// Client string describing the client /// True if brand info was successfully sent bool SendBrandInfo(string brandInfo); /// /// Inform the server of the client's Minecraft settings /// /// Client language eg en_US /// View distance, in chunks /// Game difficulty (client-side...) /// Chat mode (allows muting yourself) /// Show chat colors /// Show skin layers /// 1.9+ main hand /// True if client settings were successfully sent bool SendClientSettings(string language, byte viewDistance, byte difficulty, byte chatMode, bool chatColors, byte skinParts, byte mainHand); /// /// Send a location update telling that we moved to that location /// /// The new location /// True if the player is on the ground /// The new yaw (optional) /// The new pitch (optional) /// True if packet was successfully sent bool SendLocationUpdate(Location location, bool onGround, float? yaw, float? pitch); /// /// Send a plugin channel packet to the server. /// /// /// Channel to send packet on /// packet Data /// True if message was successfully sent bool SendPluginChannelPacket(string channel, byte[] data); /// /// Send Entity Action packet to the server. /// /// PlayerID /// Type of packet to send /// True if packet was successfully sent bool SendEntityAction(int EntityID, int type); /// /// Send a held item change packet to the server. /// /// New active slot in the inventory hotbar /// True if packet was successfully sent bool SendHeldItemChange(short slot); /// /// Send an entity interaction packet to the server. /// /// Entity ID to interact with /// Type of interaction (0: interact, 1: attack, 2: interact at) /// True if packet was successfully sent bool SendInteractEntity(int EntityID, int type); /// /// Send an entity interaction packet to the server. /// /// Entity ID to interact with /// Type of interaction (0: interact, 1: attack, 2: interact at) /// X coordinate for "interact at" /// Y coordinate for "interact at" /// Z coordinate for "interact at" /// Player hand (0: main hand, 1: off hand) /// True if packet was successfully sent bool SendInteractEntity(int EntityID, int type, float X, float Y, float Z, int hand); /// /// Send an entity interaction packet to the server. /// /// Entity ID to interact with /// Type of interaction (0: interact, 1: attack, 2: interact at) /// X coordinate for "interact at" /// Y coordinate for "interact at" /// Z coordinate for "interact at" /// True if packet was successfully sent bool SendInteractEntity(int EntityID, int type, float X, float Y, float Z); /// /// Send an entity interaction packet to the server. /// /// Entity ID to interact with /// Type of interaction (0: interact, 1: attack, 2: interact at) /// Only if Type is interact or interact at; 0: main hand, 1: off hand /// True if packet was successfully sent bool SendInteractEntity(int EntityID, int type, int hand); /// /// Send a use item packet to the server /// /// 0: main hand, 1: off hand /// True if packet was successfully sent bool SendUseItem(int hand); /// /// Send a click window slot packet to the server /// /// Id of the window being clicked /// Id of the clicked slot /// Action to perform /// Item in the clicked slot /// True if packet was successfully sent bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item); /// /// Request Creative Mode item creation into regular/survival Player Inventory /// /// (obviously) requires to be in creative mode /// Destination inventory slot /// Item type /// Item count /// Optional item NBT /// TRUE if item given successfully bool SendCreativeInventoryAction(int slot, ItemType itemType, int count, Dictionary nbt); /// /// Plays animation /// /// 0 for left arm, 1 for right arm /// Player Entity ID /// TRUE if item given successfully bool SendAnimation(int animation, int playerid); /// /// Send a close window packet to the server /// /// Id of the window being closed bool SendCloseWindow(int windowId); /// /// Send player block placement packet to the server /// /// 0: main hand, 1: off hand /// Location to place block at /// Block face /// True if packet was successfully sent bool SendPlayerBlockPlacement(int hand, Location location, Direction face); /// /// Send player blog digging packet to the server. This packet needs to be called at least twice: Once to begin digging, then a second time to finish digging /// /// 0 to start digging, 1 to cancel, 2 to finish ( https://wiki.vg/Protocol#Player_Digging ) /// Location /// Block face /// True if packet was succcessfully sent bool SendPlayerDigging(int status, Location location, Direction face); /// /// Change text on a sign /// /// Location of Sign block /// New line 1 /// New line 2 /// New line 3 /// New line 4 /// True if packet was succcessfully sent bool SendUpdateSign(Location location, string line1, string line2, string line3, string line4); /// /// Update command block /// /// command block location /// command /// command block mode /// command block flags bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags); /// /// Select villager trade /// /// The slot of the trade, starts at 0. bool SelectTrade(int selectedSlot); /// /// Get net read thread (main thread) ID /// /// Net read thread ID int GetNetReadThreadId(); } }