mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
ChatBot API: OnScoreboardObjective, OnEntityEffect, OnUpdateScore, EntityInteract, Hand list (#1097)
* Create Effect.cs * Rename Effect.cs to Effects.cs * Update MinecraftClient.csproj * Update Effects.cs * Update Effects.cs * add EntityEffect * Update McClient.cs * Update Protocol18.cs + EntityEffect * Update IMinecraftComHandler.cs * Update Protocol18PacketTypes.cs + EntityEffect * Update ChatBot.cs + OnEntityEquipment * Update PacketIncomingType.cs + ScoreboardObjective * Update Protocol18PacketTypes.cs * Update Protocol18.cs * Update IMinecraftComHandler.cs + OnScoreboardObjective * Update McClient.cs + OnScoreboardObjective * Update ChatBot.cs + OnScoreboardObjective event * Update Protocol18.cs: fix scoreboard * Update McClient.cs * Update ChatBot.cs * Update PacketIncomingType.cs * Update ChatBot.cs + OnUpdateScore * Update McClient.cs + OnUpdateScore * Update IMinecraftComHandler.cs + OnUpdateScore * Update Protocol18.cs * Update Protocol18PacketTypes.cs * Update Protocol18.cs + fix micro lags * Update Protocol18.cs * Update Protocol18.cs * Update Protocol18.cs * Update Protocol16.cs * Update Protocol18.cs * Update McClient.cs * Update IMinecraftCom.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update ChatBot.cs + GetEntities() * Create Hand.cs * Update MinecraftClient.csproj * Update McClient.cs * Update ChatBot.cs * Update Protocol18.cs * Update ChatBot.cs * Update ChatBot.cs * Update ChatBot.cs * Update ChatBot.cs * Update ChatBot.cs: fix * Update AutoAttack.cs: Fix * Update McClient.cs: compile fix * Update ChatBot.cs * Update AutoAttack.cs * Update ChatBot.cs * Update Protocol18.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update ChatBot.cs * Update Protocol18.cs * Update IMinecraftComHandler.cs * Update ChatBot.cs * Update McClient.cs * Update McClient.cs: remove check distance * Update EntityActionType.cs: more actions * Create CommandBlockMode.cs * Create CommandBlockFlags.cs * Update IMinecraftCom.cs * Update McClient.cs * Update ChatBot.cs * Update Protocol18.cs * Update Protocol16.cs * Update PacketOutgoingType.cs * Update Protocol18PacketTypes.cs * Update Protocol18.cs
This commit is contained in:
parent
572191dcd2
commit
fb50b0d5cb
16 changed files with 469 additions and 78 deletions
|
|
@ -759,6 +759,15 @@ namespace MinecraftClient
|
|||
{
|
||||
return inventories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all Entityes
|
||||
/// </summary>
|
||||
/// <returns>All Entities</returns>
|
||||
public Dictionary<int, Entity> GetEntities()
|
||||
{
|
||||
return entities;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get client player's inventory items
|
||||
|
|
@ -825,7 +834,7 @@ namespace MinecraftClient
|
|||
{
|
||||
lock (locationLock)
|
||||
{
|
||||
if (allowSmallTeleport && location.DistanceSquared(this.location) <= 32)
|
||||
if (allowSmallTeleport)
|
||||
{
|
||||
// Allow small teleport within a range of 8 blocks. 1-step path to the desired location without checking anything
|
||||
UpdateLocation(location, location); // Update yaw and pitch to look at next step
|
||||
|
|
@ -1037,10 +1046,22 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
/// <param name="EntityID"></param>
|
||||
/// <param name="type">0: interact, 1: attack, 2: interact at</param>
|
||||
/// <param name="hand">Hand.MainHand or Hand.OffHand</param>
|
||||
/// <returns>TRUE if interaction succeeded</returns>
|
||||
public bool InteractEntity(int EntityID, int type)
|
||||
public bool InteractEntity(int EntityID, int type, Hand hand = Hand.MainHand)
|
||||
{
|
||||
return handler.SendInteractEntity(EntityID, type);
|
||||
if (entities.ContainsKey(EntityID))
|
||||
{
|
||||
if (type == 0)
|
||||
{
|
||||
return handler.SendInteractEntity(EntityID, type, (int)hand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return handler.SendInteractEntity(EntityID, type);
|
||||
}
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1049,9 +1070,9 @@ namespace MinecraftClient
|
|||
/// <param name="location">Location to place block to</param>
|
||||
/// <param name="blockFace">Block face (e.g. Direction.Down when clicking on the block below to place this block)</param>
|
||||
/// <returns>TRUE if successfully placed</returns>
|
||||
public bool PlaceBlock(Location location, Direction blockFace)
|
||||
public bool PlaceBlock(Location location, Direction blockFace, Hand hand = Hand.MainHand)
|
||||
{
|
||||
return handler.SendPlayerBlockPlacement(0, location, blockFace);
|
||||
return handler.SendPlayerBlockPlacement((int)hand, location, blockFace);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1104,7 +1125,18 @@ namespace MinecraftClient
|
|||
// TODO Open sign editor first https://wiki.vg/Protocol#Open_Sign_Editor
|
||||
return handler.SendUpdateSign(location, line1, line2, line3, line4);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update command block
|
||||
/// </summary>
|
||||
/// <param name="location">command block location</param>
|
||||
/// <param name="command">command</param>
|
||||
/// <param name="mode">command block mode</param>
|
||||
/// <param name="flags">command block flags</param>
|
||||
public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
|
||||
{
|
||||
return handler.UpdateCommandBlock(location, command, mode, flags);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Event handlers: An event occurs on the Server
|
||||
|
|
@ -1325,7 +1357,7 @@ namespace MinecraftClient
|
|||
DispatchBotEvent(bot => bot.GetText(text));
|
||||
DispatchBotEvent(bot => bot.GetText(text, json));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Received a connection keep-alive from the server
|
||||
/// </summary>
|
||||
|
|
@ -1478,6 +1510,15 @@ namespace MinecraftClient
|
|||
entities.Add(entity.ID, entity);
|
||||
DispatchBotEvent(bot => bot.OnEntitySpawn(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when an entity effects
|
||||
/// </summary>
|
||||
public void OnEntityEffect(int entityid, Effects effect, int amplifier, int duration, byte flags)
|
||||
{
|
||||
if (entities.ContainsKey(entityid))
|
||||
DispatchBotEvent(bot => bot.OnEntityEffect(entities[entityid], effect, amplifier, duration, flags));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a player spawns or enters the client's render distance
|
||||
|
|
@ -1724,7 +1765,32 @@ namespace MinecraftClient
|
|||
{
|
||||
DispatchBotEvent(bot => bot.OnTitle(action, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when coreboardObjective
|
||||
/// </summary>
|
||||
/// <param name="objectivename">objective name</param>
|
||||
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
||||
/// <param name="objectivevalue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
||||
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
||||
public void OnScoreboardObjective(string objectivename, byte mode, string objectivevalue, int type)
|
||||
{
|
||||
string json = objectivevalue;
|
||||
objectivevalue = ChatParser.ParseText(objectivevalue);
|
||||
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectivename, mode, objectivevalue, type, json));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when DisplayScoreboard
|
||||
/// </summary>
|
||||
/// <param name="entityname">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
||||
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
||||
/// <param name="objectivename">The name of the objective the score belongs to</param>
|
||||
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||
public void OnUpdateScore(string entityname, byte action, string objectivename, int value)
|
||||
{
|
||||
DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue