More events (#1660)

* + OnBlockBreakAnimation

* + OnBlockBreakAnimation

* + OnEntityAnimation

* Add checks

* + OnBlockChange

* + OnMultiBlockChange

* Fix

* Fix

* Fix

* add summary

* Fix

* fix other summary
This commit is contained in:
Рома Данилов 2021-07-04 11:26:41 +05:00 committed by GitHub
parent c0f128f632
commit 48577bf034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 19 deletions

View file

@ -628,7 +628,10 @@ namespace MinecraftClient.Protocol.Handlers
byte blockMeta = dataTypes.ReadNextByte(packetData);
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;
case PacketTypesIn.MapChunkBulk:
@ -1112,6 +1115,23 @@ namespace MinecraftClient.Protocol.Handlers
value = dataTypes.ReadNextVarInt(packetData);
handler.OnUpdateScore(entityname, action3, objectivename2, value);
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:
return false; //Ignored packet
}

View file

@ -83,7 +83,22 @@ namespace MinecraftClient.Protocol
/// <param name="text">Text received from the server</param>
/// <param name="isJson">TRUE if the text is JSON-Encoded</param>
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>
/// This method is called when the protocol handler receives a title
/// </summary>