mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
More events (#1660)
* + OnBlockBreakAnimation * + OnBlockBreakAnimation * + OnEntityAnimation * Add checks * + OnBlockChange * + OnMultiBlockChange * Fix * Fix * Fix * add summary * Fix * fix other summary
This commit is contained in:
parent
c0f128f632
commit
48577bf034
4 changed files with 97 additions and 19 deletions
|
|
@ -115,6 +115,21 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Update() { }
|
public virtual void Update() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every player break block in gamemode 0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">Player</param>
|
||||||
|
/// <param name="location">Block location</param>
|
||||||
|
/// <param name="stage">Destroy stage, maximum 255</param>
|
||||||
|
public virtual void OnBlockBreakAnimation(Entity entity, Location location, byte stage) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every animations of the hit and place block
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">Player</param>
|
||||||
|
/// <param name="animation">0 = LMB, 1 = RMB (RMB Corrent not work)</param>
|
||||||
|
public virtual void OnEntityAnimation(Entity entity, byte animation) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Any text sent by the server will be sent here by MinecraftCom
|
/// Any text sent by the server will be sent here by MinecraftCom
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -211,6 +226,7 @@ namespace MinecraftClient
|
||||||
/// Called when an explosion occurs on the server
|
/// Called when an explosion occurs on the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="explode">Explosion location</param>
|
/// <param name="explode">Explosion location</param>
|
||||||
|
/// <param name="strength">Explosion strength</param>
|
||||||
/// <param name="recordcount">Amount of blocks blown up</param>
|
/// <param name="recordcount">Amount of blocks blown up</param>
|
||||||
public virtual void OnExplosion(Location explode, float strength, int recordcount) { }
|
public virtual void OnExplosion(Location explode, float strength, int recordcount) { }
|
||||||
|
|
||||||
|
|
@ -284,11 +300,11 @@ namespace MinecraftClient
|
||||||
/// <param name="slot"> Equipment slot. 0: main hand, 1: off hand, 2–5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)</param>
|
/// <param name="slot"> Equipment slot. 0: main hand, 1: off hand, 2–5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)</param>
|
||||||
/// <param name="item"> Item)</param>
|
/// <param name="item"> Item)</param>
|
||||||
public virtual void OnEntityEquipment(Entity entity, int slot, Item item) { }
|
public virtual void OnEntityEquipment(Entity entity, int slot, Item item) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an entity has effect applied
|
/// Called when an entity has effect applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entityid">entity ID</param>
|
/// <param name="entity">entity</param>
|
||||||
/// <param name="effect">effect id</param>
|
/// <param name="effect">effect id</param>
|
||||||
/// <param name="amplifier">effect amplifier</param>
|
/// <param name="amplifier">effect amplifier</param>
|
||||||
/// <param name="duration">effect duration</param>
|
/// <param name="duration">effect duration</param>
|
||||||
|
|
@ -367,7 +383,6 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">Entity</param>
|
/// <param name="entity">Entity</param>
|
||||||
/// <param name="metadata">The metadata of the entity</param>
|
/// <param name="metadata">The metadata of the entity</param>
|
||||||
/// <param name="protocolversion">Ptotocol version</param>
|
|
||||||
public virtual void OnEntityMetadata(Entity entity, Dictionary<int, object> metadata) { }
|
public virtual void OnEntityMetadata(Entity entity, Dictionary<int, object> metadata) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -181,8 +181,8 @@ namespace MinecraftClient
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.protocolversion = protocolversion;
|
this.protocolversion = protocolversion;
|
||||||
|
|
||||||
this.Log = Settings.LogToFile
|
this.Log = Settings.LogToFile
|
||||||
? new FileLogLogger(Settings.ExpandVars(Settings.LogFile), Settings.PrependTimestamp)
|
? new FileLogLogger(Settings.ExpandVars(Settings.LogFile), Settings.PrependTimestamp)
|
||||||
: new FilteredLogger();
|
: new FilteredLogger();
|
||||||
Log.DebugEnabled = Settings.DebugMessages;
|
Log.DebugEnabled = Settings.DebugMessages;
|
||||||
Log.InfoEnabled = Settings.InfoMessages;
|
Log.InfoEnabled = Settings.InfoMessages;
|
||||||
|
|
@ -975,7 +975,7 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
return inventories;
|
return inventories;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all Entities
|
/// Get all Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -989,11 +989,11 @@ namespace MinecraftClient
|
||||||
/// Get all players latency
|
/// Get all players latency
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>All players latency</returns>
|
/// <returns>All players latency</returns>
|
||||||
public Dictionary<string, int> GetPlayersLatency()
|
public Dictionary<string, int> GetPlayersLatency()
|
||||||
{
|
{
|
||||||
return playersLatency;
|
return playersLatency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get client player's inventory items
|
/// Get client player's inventory items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1397,7 +1397,7 @@ namespace MinecraftClient
|
||||||
upperStartSlot = 1;
|
upperStartSlot = 1;
|
||||||
upperEndSlot = 9;
|
upperEndSlot = 9;
|
||||||
break;
|
break;
|
||||||
// TODO: Define more container type here
|
// TODO: Define more container type here
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursor have item or not doesn't matter
|
// Cursor have item or not doesn't matter
|
||||||
|
|
@ -1679,7 +1679,7 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
return InvokeOnMainThread(() => handler.SelectTrade(selectedSlot));
|
return InvokeOnMainThread(() => handler.SelectTrade(selectedSlot));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update command block
|
/// Update command block
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1926,7 +1926,7 @@ namespace MinecraftClient
|
||||||
DispatchBotEvent(bot => bot.GetText(text));
|
DispatchBotEvent(bot => bot.GetText(text));
|
||||||
DispatchBotEvent(bot => bot.GetText(text, json));
|
DispatchBotEvent(bot => bot.GetText(text, json));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Received a connection keep-alive from the server
|
/// Received a connection keep-alive from the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1965,7 +1965,7 @@ namespace MinecraftClient
|
||||||
else
|
else
|
||||||
inventories.Remove(inventoryID);
|
inventories.Remove(inventoryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventoryID != 0)
|
if (inventoryID != 0)
|
||||||
{
|
{
|
||||||
Log.Info(Translations.Get("extra.inventory_close", inventoryID));
|
Log.Info(Translations.Get("extra.inventory_close", inventoryID));
|
||||||
|
|
@ -2118,7 +2118,7 @@ namespace MinecraftClient
|
||||||
entities.Add(entity.ID, entity);
|
entities.Add(entity.ID, entity);
|
||||||
DispatchBotEvent(bot => bot.OnEntitySpawn(entity));
|
DispatchBotEvent(bot => bot.OnEntitySpawn(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an entity effects
|
/// Called when an entity effects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2415,7 +2415,7 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
DispatchBotEvent(bot => bot.OnTitle(action, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json));
|
DispatchBotEvent(bot => bot.OnTitle(action, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when coreboardObjective
|
/// Called when coreboardObjective
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2429,7 +2429,7 @@ namespace MinecraftClient
|
||||||
objectivevalue = ChatParser.ParseText(objectivevalue);
|
objectivevalue = ChatParser.ParseText(objectivevalue);
|
||||||
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectivename, mode, objectivevalue, type, json));
|
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectivename, mode, objectivevalue, type, json));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when DisplayScoreboard
|
/// Called when DisplayScoreboard
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2502,6 +2502,34 @@ namespace MinecraftClient
|
||||||
DispatchBotEvent(bot => bot.OnTradeList(windowID, trades, villagerInfo));
|
DispatchBotEvent(bot => bot.OnTradeList(windowID, trades, villagerInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every player break block in gamemode 0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">Player ID</param>
|
||||||
|
/// <param name="location">Block location</param>
|
||||||
|
/// <param name="stage">Destroy stage, maximum 255</param>
|
||||||
|
public void OnBlockBreakAnimation(int entityId, Location location, byte stage)
|
||||||
|
{
|
||||||
|
if (entities.ContainsKey(entityId))
|
||||||
|
{
|
||||||
|
Entity entity = entities[entityId];
|
||||||
|
DispatchBotEvent(bot => bot.OnBlockBreakAnimation(entity, location, stage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every animations of the hit and place block
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityID">Player ID</param>
|
||||||
|
/// <param name="animation">0 = LMB, 1 = RMB (RMB Corrent not work)</param>
|
||||||
|
public void OnEntityAnimation(int entityID, byte animation)
|
||||||
|
{
|
||||||
|
if (entities.ContainsKey(entityID))
|
||||||
|
{
|
||||||
|
Entity entity = entities[entityID];
|
||||||
|
DispatchBotEvent(bot => bot.OnEntityAnimation(entity, animation));
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -628,7 +628,10 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
byte blockMeta = dataTypes.ReadNextByte(packetData);
|
byte blockMeta = dataTypes.ReadNextByte(packetData);
|
||||||
handler.GetWorld().SetBlock(new Location(blockX, blockY, blockZ), new Block(blockId, blockMeta));
|
handler.GetWorld().SetBlock(new Location(blockX, blockY, blockZ), new Block(blockId, blockMeta));
|
||||||
}
|
}
|
||||||
else handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData)));
|
else
|
||||||
|
{
|
||||||
|
handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.MapChunkBulk:
|
case PacketTypesIn.MapChunkBulk:
|
||||||
|
|
@ -1112,6 +1115,23 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
value = dataTypes.ReadNextVarInt(packetData);
|
value = dataTypes.ReadNextVarInt(packetData);
|
||||||
handler.OnUpdateScore(entityname, action3, objectivename2, value);
|
handler.OnUpdateScore(entityname, action3, objectivename2, value);
|
||||||
break;
|
break;
|
||||||
|
case PacketTypesIn.BlockBreakAnimation:
|
||||||
|
if (handler.GetEntityHandlingEnabled() && handler.GetTerrainEnabled())
|
||||||
|
{
|
||||||
|
int playerId = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
Location blockLocation = dataTypes.ReadNextLocation(packetData);
|
||||||
|
byte stage = dataTypes.ReadNextByte(packetData);
|
||||||
|
handler.OnBlockBreakAnimation(playerId, blockLocation, stage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PacketTypesIn.EntityAnimation:
|
||||||
|
if (handler.GetEntityHandlingEnabled())
|
||||||
|
{
|
||||||
|
int playerId2 = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
byte animation = dataTypes.ReadNextByte(packetData);
|
||||||
|
handler.OnEntityAnimation(playerId2, animation);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false; //Ignored packet
|
return false; //Ignored packet
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,22 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="text">Text received from the server</param>
|
/// <param name="text">Text received from the server</param>
|
||||||
/// <param name="isJson">TRUE if the text is JSON-Encoded</param>
|
/// <param name="isJson">TRUE if the text is JSON-Encoded</param>
|
||||||
void OnTextReceived(string text, bool isJson);
|
void OnTextReceived(string text, bool isJson);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every animations of the hit and place block
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityID">Player ID</param>
|
||||||
|
/// <param name="animation">0 = LMB, 1 = RMB (RMB Corrent not work)</param>
|
||||||
|
void OnEntityAnimation(int entityID, byte animation);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will be called every player break block in gamemode 0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entityId">Player ID</param>
|
||||||
|
/// <param name="location">Block location</param>
|
||||||
|
/// <param name="stage">Destroy stage, maximum 255</param>
|
||||||
|
void OnBlockBreakAnimation(int entityID, Location location, byte stage);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the protocol handler receives a title
|
/// This method is called when the protocol handler receives a title
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue