2014-05-31 01:59:03 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2015-11-27 17:16:33 +01:00
|
|
|
|
using MinecraftClient.Mapping;
|
2020-03-26 15:01:42 +08:00
|
|
|
|
using MinecraftClient.Inventory;
|
2014-05-31 01:59:03 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Protocol
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 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.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
|
public interface IMinecraftComHandler
|
|
|
|
|
|
{
|
2016-02-07 14:24:01 -08:00
|
|
|
|
/* The MinecraftCom Handler must
|
2014-05-31 01:59:03 +02:00
|
|
|
|
* provide these getters */
|
|
|
|
|
|
|
2015-06-20 22:58:18 +02:00
|
|
|
|
int GetServerPort();
|
|
|
|
|
|
string GetServerHost();
|
|
|
|
|
|
string GetUsername();
|
|
|
|
|
|
string GetUserUUID();
|
|
|
|
|
|
string GetSessionID();
|
2016-08-27 15:46:34 +02:00
|
|
|
|
string[] GetOnlinePlayers();
|
2019-03-30 10:47:59 -04:00
|
|
|
|
Dictionary<string, string> GetOnlinePlayersWithUUID();
|
2015-11-27 17:16:33 +01:00
|
|
|
|
Location GetCurrentLocation();
|
2015-11-30 15:30:49 +01:00
|
|
|
|
World GetWorld();
|
2019-04-28 21:32:03 +02:00
|
|
|
|
bool GetTerrainEnabled();
|
|
|
|
|
|
bool SetTerrainEnabled(bool enabled);
|
2019-05-26 10:36:46 -04:00
|
|
|
|
bool GetInventoryEnabled();
|
2019-05-30 11:34:08 +02:00
|
|
|
|
bool SetInventoryEnabled(bool enabled);
|
2020-03-23 19:59:00 +08:00
|
|
|
|
bool GetEntityHandlingEnabled();
|
2014-11-11 00:32:32 +11:00
|
|
|
|
|
2015-09-30 20:01:57 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a server was successfully joined
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnGameJoined();
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when the protocol handler receives a chat message
|
|
|
|
|
|
/// </summary>
|
2016-10-07 19:52:28 +02:00
|
|
|
|
/// <param name="text">Text received from the server</param>
|
2017-05-31 20:54:16 +02:00
|
|
|
|
/// <param name="isJson">TRUE if the text is JSON-Encoded</param>
|
|
|
|
|
|
void OnTextReceived(string text, bool isJson);
|
2014-05-31 01:59:03 +02:00
|
|
|
|
|
2019-09-15 17:01:53 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when receiving a connection keep-alive from the server
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnServerKeepAlive();
|
|
|
|
|
|
|
2019-05-26 10:36:46 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when an inventory is opened
|
|
|
|
|
|
/// </summary>
|
2020-03-26 15:01:42 +08:00
|
|
|
|
void OnInventoryOpen(Container inventory);
|
2019-05-26 10:36:46 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when an inventory is closed
|
2019-05-25 17:45:59 -04:00
|
|
|
|
/// </summary>
|
2019-09-15 17:01:53 +02:00
|
|
|
|
void OnInventoryClose(byte inventoryID);
|
2019-05-25 17:45:59 -04:00
|
|
|
|
|
2019-04-28 21:32:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the player respawns, which happens on login, respawn and world change.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnRespawn();
|
|
|
|
|
|
|
2014-11-10 20:43:00 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when a new player joins the game
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uuid">UUID of the player</param>
|
2016-08-27 15:46:34 +02:00
|
|
|
|
/// <param name="name">Name of the player</param>
|
|
|
|
|
|
void OnPlayerJoin(Guid uuid, string name);
|
2014-11-10 20:43:00 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when a player has left the game
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uuid">UUID of the player</param>
|
|
|
|
|
|
void OnPlayerLeave(Guid uuid);
|
|
|
|
|
|
|
2015-11-27 17:16:33 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the server sets the new location for the player
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="location">New location of the player</param>
|
2019-04-09 18:01:00 -07:00
|
|
|
|
/// <param name="yaw">New yaw</param>
|
|
|
|
|
|
/// <param name="pitch">New pitch</param>
|
|
|
|
|
|
void UpdateLocation(Location location, float yaw, float pitch);
|
2015-11-27 17:16:33 +01:00
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when the connection has been lost
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnConnectionLost(ChatBot.DisconnectReason reason, string message);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called ~10 times per second (10 ticks per second)
|
|
|
|
|
|
/// Useful for updating bots in other parts of the program
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnUpdate();
|
2016-02-07 14:24:01 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Registers the given plugin channel for the given bot.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to register.</param>
|
|
|
|
|
|
/// <param name="bot">The bot to register the channel for.</param>
|
|
|
|
|
|
void RegisterPluginChannel(string channel, ChatBot bot);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Unregisters the given plugin channel for the given bot.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to unregister.</param>
|
|
|
|
|
|
/// <param name="bot">The bot to unregister the channel for.</param>
|
|
|
|
|
|
void UnregisterPluginChannel(string channel, ChatBot bot);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2016-03-10 13:29:05 +01:00
|
|
|
|
/// Sends a plugin channel packet to the server.
|
|
|
|
|
|
/// See http://wiki.vg/Plugin_channel for more information about plugin channels.
|
2016-02-07 14:24:01 -08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to send the packet on.</param>
|
|
|
|
|
|
/// <param name="data">The payload for the packet.</param>
|
|
|
|
|
|
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
|
|
|
|
|
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
|
|
|
|
|
bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a plugin channel message was sent from the server.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel the message was sent on</param>
|
|
|
|
|
|
/// <param name="data">The data from the channel</param>
|
|
|
|
|
|
void OnPluginChannelMessage(string channel, byte[] data);
|
2020-03-21 18:41:48 +08:00
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a non-living entity has spawned
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="EntityType">Entity Type ID</param>
|
|
|
|
|
|
/// <param name="UUID">Entity UUID</param>
|
|
|
|
|
|
/// <param name="location">Entity location</param>
|
2020-03-22 20:12:06 +08:00
|
|
|
|
void OnSpawnEntity(int EntityID, int EntityType, Guid UUID, Location location);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a living entity has spawned
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="EntityType">Entity Type ID</param>
|
|
|
|
|
|
/// <param name="UUID">Entity UUID</param>
|
|
|
|
|
|
/// <param name="location">Entity location</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void OnSpawnLivingEntity(int EntityID, int EntityType, Guid UUID, Location location);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a player has spawned
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="UUID">Entity UUID</param>
|
|
|
|
|
|
/// <param name="location">Entity location</param>
|
|
|
|
|
|
/// <param name="Yaw">Player head yaw</param>
|
|
|
|
|
|
/// <param name="Pitch">Player head pitch</param>
|
2020-03-26 15:01:42 +08:00
|
|
|
|
void OnSpawnPlayer(int EntityID, Guid UUID, Location location, byte Yaw, byte Pitch);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when entities have despawned
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">List of Entity ID that have despawned</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void OnDestroyEntities(int[] EntityID);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when an entity moved by coordinate offset
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="Dx">X offset</param>
|
|
|
|
|
|
/// <param name="Dy">Y offset</param>
|
|
|
|
|
|
/// <param name="Dz">Z offset</param>
|
|
|
|
|
|
/// <param name="onGround">TRUE if on ground</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void OnEntityPosition(int EntityID, Double Dx, Double Dy, Double Dz,bool onGround);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when an entity moved to fixed coordinates
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="Dx">X</param>
|
|
|
|
|
|
/// <param name="Dy">Y</param>
|
|
|
|
|
|
/// <param name="Dz">Z</param>
|
|
|
|
|
|
/// <param name="onGround">TRUE if on ground</param>
|
|
|
|
|
|
void OnEntityTeleport(int EntityID, Double X, Double Y, Double Z, bool onGround);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when additional properties have been received for an entity
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Entity ID</param>
|
|
|
|
|
|
/// <param name="prop">Dictionary of properties</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void OnEntityProperties(int EntityID, Dictionary<string, Double> prop);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the world age has been updated
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="WorldAge">World age</param>
|
|
|
|
|
|
/// <param name="TimeOfDay">Time of Day</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void OnTimeUpdate(long WorldAge, long TimeOfDay);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when inventory items have been received
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type">Inventory type</param>
|
|
|
|
|
|
/// <param name="itemList">Item list</param>
|
2020-03-26 15:01:42 +08:00
|
|
|
|
void OnWindowItems(int type, Dictionary<int, MinecraftClient.Inventory.Item> itemList);
|
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a single slot has been cleared inside an inventory
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="WindowID">Inventory ID</param>
|
|
|
|
|
|
/// <param name="SlotID">Slot ID</param>
|
|
|
|
|
|
void OnSlotClear(byte WindowID, short SlotID);
|
2020-03-22 23:19:31 +08:00
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a single slot has been updated inside an inventory
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="WindowID">Inventory ID</param>
|
|
|
|
|
|
/// <param name="SlotID">Slot ID</param>
|
|
|
|
|
|
/// <param name="ItemID">Item ID</param>
|
|
|
|
|
|
/// <param name="Count">Item Count</param>
|
|
|
|
|
|
/// <param name="NBT">Item Metadata</param>
|
|
|
|
|
|
void OnSetSlot(byte WindowID, short SlotID, int ItemID, byte Count, Dictionary<string, object> NBT);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the Player entity ID has been received from the server
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EntityID">Player entity ID</param>
|
2020-03-21 18:41:48 +08:00
|
|
|
|
void SetPlayerEntityID(int EntityID);
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|