using System; using System.Collections.Generic; using System.Linq; using System.Text; using MinecraftClient.Mapping; using MinecraftClient.Inventory; namespace MinecraftClient.Protocol { /// /// Interface for the MinecraftCom Handler. /// It defines some callbacks that the MinecraftCom handler must have. /// It allows the protocol handler to abstract from the other parts of the program. /// public interface IMinecraftComHandler { /* The MinecraftCom Handler must * provide these getters */ int GetServerPort(); string GetServerHost(); string GetUsername(); string GetUserUUID(); string GetSessionID(); string[] GetOnlinePlayers(); Dictionary GetOnlinePlayersWithUUID(); Location GetCurrentLocation(); World GetWorld(); bool GetTerrainEnabled(); bool SetTerrainEnabled(bool enabled); bool GetInventoryEnabled(); bool SetInventoryEnabled(bool enabled); bool GetEntityHandlingEnabled(); bool SetEntityHandlingEnabled(bool enabled); /// /// Called when a server was successfully joined /// void OnGameJoined(); /// /// This method is called when the protocol handler receives a chat message /// /// Text received from the server /// TRUE if the text is JSON-Encoded void OnTextReceived(string text, bool isJson); /// /// Called when receiving a connection keep-alive from the server /// void OnServerKeepAlive(); /// /// Called when an inventory is opened /// void OnInventoryOpen(int inventoryID, Container inventory); /// /// Called when an inventory is closed /// void OnInventoryClose(int inventoryID); /// /// Called when the player respawns, which happens on login, respawn and world change. /// void OnRespawn(); /// /// This method is called when a new player joins the game /// /// UUID of the player /// Name of the player void OnPlayerJoin(Guid uuid, string name); /// /// This method is called when a player has left the game /// /// UUID of the player void OnPlayerLeave(Guid uuid); /// /// Called when the server sets the new location for the player /// /// New location of the player /// New yaw /// New pitch void UpdateLocation(Location location, float yaw, float pitch); /// /// This method is called when the connection has been lost /// void OnConnectionLost(ChatBot.DisconnectReason reason, string message); /// /// Called ~10 times per second (10 ticks per second) /// Useful for updating bots in other parts of the program /// void OnUpdate(); /// /// Registers the given plugin channel for the given bot. /// /// The channel to register. /// The bot to register the channel for. void RegisterPluginChannel(string channel, ChatBot bot); /// /// Unregisters the given plugin channel for the given bot. /// /// The channel to unregister. /// The bot to unregister the channel for. void UnregisterPluginChannel(string channel, ChatBot bot); /// /// Sends a plugin channel packet to the server. /// See http://wiki.vg/Plugin_channel for more information about plugin channels. /// /// The channel to send the packet on. /// The payload for the packet. /// Whether the packet should be sent even if the server or the client hasn't registered it yet. /// Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered. bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false); /// /// Called when a plugin channel message was sent from the server. /// /// The channel the message was sent on /// The data from the channel void OnPluginChannelMessage(string channel, byte[] data); /// /// Called when a non-living entity has spawned /// /// Entity ID /// Entity Type ID /// Entity UUID /// Entity location void OnSpawnEntity(int EntityID, int EntityType, Guid UUID, Location location); /// /// Called when a living entity has spawned /// /// Entity ID /// Entity Type ID /// Entity UUID /// Entity location void OnSpawnLivingEntity(int EntityID, int EntityType, Guid UUID, Location location); /// /// Called when a player has spawned /// /// Entity ID /// Entity UUID /// Entity location /// Player head yaw /// Player head pitch void OnSpawnPlayer(int EntityID, Guid UUID, Location location, byte Yaw, byte Pitch); /// /// Called when entities have despawned /// /// List of Entity ID that have despawned void OnDestroyEntities(int[] EntityID); /// /// Called when an entity moved by coordinate offset /// /// Entity ID /// X offset /// Y offset /// Z offset /// TRUE if on ground void OnEntityPosition(int EntityID, Double Dx, Double Dy, Double Dz,bool onGround); /// /// Called when an entity moved to fixed coordinates /// /// Entity ID /// X /// Y /// Z /// TRUE if on ground void OnEntityTeleport(int EntityID, Double X, Double Y, Double Z, bool onGround); /// /// Called when additional properties have been received for an entity /// /// Entity ID /// Dictionary of properties void OnEntityProperties(int EntityID, Dictionary prop); /// /// Called when the world age has been updated /// /// World age /// Time of Day void OnTimeUpdate(long WorldAge, long TimeOfDay); /// /// Called when inventory items have been received /// /// Inventory ID /// Item list void OnWindowItems(byte inventoryID, Dictionary itemList); /// /// Called when a single slot has been updated inside an inventory /// /// Window ID /// Slot ID /// Item (may be null for empty slot) void OnSetSlot(byte inventoryID, short slotID, Item item); void OnUpdateHealth(float health, int Food); /// /// Called when the Player entity ID has been received from the server /// /// Player entity ID void SetPlayerEntityID(int EntityID); } }