From 87b2d3bf4ab0ae67fbc56b086c41aa9629f1dce8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=94=D0=B0=D0=BD=D0=B8=D0=BB?=
=?UTF-8?q?=D0=BE=D0=B2?= <35975332+Nekiplay@users.noreply.github.com>
Date: Tue, 26 May 2020 14:02:09 +0500
Subject: [PATCH] new command /animation (#1026)
---
MinecraftClient/ChatBot.cs | 10 +
MinecraftClient/Commands/Animation.cs | 43 ++
MinecraftClient/McTcpClient.cs | 10 +
MinecraftClient/MinecraftClient.csproj | 617 +++++++++---------
.../Protocol/Handlers/PacketOutgoingType.cs | 3 +-
.../Protocol/Handlers/Protocol16.cs | 5 +-
.../Protocol/Handlers/Protocol18.cs | 22 +
.../Handlers/Protocol18PacketTypes.cs | 3 +-
MinecraftClient/Protocol/IMinecraftCom.cs | 7 +
9 files changed, 409 insertions(+), 311 deletions(-)
create mode 100644 MinecraftClient/Commands/Animation.cs
diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs
index b790ebd4..b68c6157 100644
--- a/MinecraftClient/ChatBot.cs
+++ b/MinecraftClient/ChatBot.cs
@@ -899,6 +899,16 @@ namespace MinecraftClient
return Handler.DoCreativeGive(slot, itemType, count);
}
+ ///
+ /// Plays animation
+ ///
+ /// <0|1>
+ /// TRUE animation done
+ protected bool SendAnimation(int animation)
+ {
+ return Handler.DoAnimation(animation);
+ }
+
///
/// Use item currently in the player's hand (active inventory bar slot)
///
diff --git a/MinecraftClient/Commands/Animation.cs b/MinecraftClient/Commands/Animation.cs
new file mode 100644
index 00000000..8ee3c195
--- /dev/null
+++ b/MinecraftClient/Commands/Animation.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MinecraftClient.Commands
+{
+ public class Animation : Command
+ {
+ public override string CMDName { get { return "animation"; } }
+ public override string CMDDesc { get { return "animation <|<0|1>>"; } }
+
+ public override string Run(McTcpClient handler, string command, Dictionary localVars)
+ {
+ if (hasArg(command))
+ {
+ string[] args = getArgs(command);
+ if (args.Length > 0)
+ {
+ if (args[0] == "mainhand" || args[0] == "0")
+ {
+ handler.DoAnimation(0);
+ return "Done";
+ }
+ else if (args[0] == "offhand" || args[0] == "1")
+ {
+ handler.DoAnimation(1);
+ return "Done";
+ }
+ else
+ {
+ return CMDDesc;
+ }
+ }
+ else
+ {
+ return CMDDesc;
+ }
+ }
+ else return CMDDesc;
+ }
+ }
+}
diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs
index 9853a145..742005e9 100644
--- a/MinecraftClient/McTcpClient.cs
+++ b/MinecraftClient/McTcpClient.cs
@@ -1481,6 +1481,16 @@ namespace MinecraftClient
public bool DoCreativeGive(int slot, ItemType itemType, int count)
{
return handler.SendCreativeInventoryAction(slot, itemType, count);
+ }
+
+ ///
+ /// Plays animation
+ ///
+ /// <0|1>
+ /// TRUE if item given successfully
+ public bool DoAnimation(int animation)
+ {
+ return handler.SendAnimation(animation);
}
///
diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj
index f549f177..e3520ef4 100644
--- a/MinecraftClient/MinecraftClient.csproj
+++ b/MinecraftClient/MinecraftClient.csproj
@@ -1,315 +1,316 @@
-
-
-
- Debug
- x86
- 8.0.30703
- 2.0
- {1E2FACE4-F5CA-4323-9641-740C6A551770}
- Exe
- Properties
- MinecraftClient
- MinecraftClient
- v4.0
- Client
- 512
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
- x86
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- x86
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- false
-
-
- Resources\AppIcon.ico
-
-
- MinecraftClient.Program
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
- Microsoft .NET Framework 4 Client Profile %28x86 and x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
-
-
-
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {1E2FACE4-F5CA-4323-9641-740C6A551770}
+ Exe
+ Properties
+ MinecraftClient
+ MinecraftClient
+ v4.0
+ Client
+ 512
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ x86
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ x86
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ false
+
+
+ Resources\AppIcon.ico
+
+
+ MinecraftClient.Program
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4 Client Profile %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
+
+
+
+ -->
\ No newline at end of file
diff --git a/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs b/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs
index 6a6e7328..2db1efbb 100644
--- a/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs
+++ b/MinecraftClient/Protocol/Handlers/PacketOutgoingType.cs
@@ -27,6 +27,7 @@ namespace MinecraftClient.Protocol.Handlers
ClickWindow,
CloseWindow,
PlayerBlockPlacement,
- CreativeInventoryAction
+ CreativeInventoryAction,
+ Animation
}
}
diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs
index 87284d0e..8eda1b26 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol16.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs
@@ -692,7 +692,10 @@ namespace MinecraftClient.Protocol.Handlers
{
return false; //Currently not implemented
}
-
+ public bool SendAnimation(int animation)
+ {
+ return false; //Currently not implemented
+ }
public bool SendCreativeInventoryAction(int slot, ItemType item, int count)
{
return false; //Currently not implemented
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 28487bcb..570db1a2 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -1391,6 +1391,28 @@ namespace MinecraftClient.Protocol.Handlers
catch (ObjectDisposedException) { return false; }
}
+ public bool SendAnimation(int animation)
+ {
+ try
+ {
+ if (animation == 0 || animation == 1)
+ {
+ List packet = new List();
+ packet.AddRange(dataTypes.GetVarInt(animation));
+
+ SendPacket(PacketOutgoingType.Animation, packet);
+ return true;
+ }
+ else;
+ {
+ return false;
+ }
+ }
+ catch (SocketException) { return false; }
+ catch (System.IO.IOException) { return false; }
+ catch (ObjectDisposedException) { return false; }
+ }
+
public bool SendCloseWindow(int windowId)
{
try
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs
index eef0045d..46fe90f4 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18PacketTypes.cs
@@ -417,7 +417,8 @@ namespace MinecraftClient.Protocol.Handlers
case PacketOutgoingType.PlayerBlockPlacement: return 0x2C;
case PacketOutgoingType.ClickWindow: return 0x09;
case PacketOutgoingType.CloseWindow: return 0x0A;
- case PacketOutgoingType.EntityAction: return 0x1B;
+ case PacketOutgoingType.EntityAction: return 0x1B;
+ case PacketOutgoingType.Animation: return 0x2A;
}
}
diff --git a/MinecraftClient/Protocol/IMinecraftCom.cs b/MinecraftClient/Protocol/IMinecraftCom.cs
index 9a44441d..74b9fd11 100644
--- a/MinecraftClient/Protocol/IMinecraftCom.cs
+++ b/MinecraftClient/Protocol/IMinecraftCom.cs
@@ -159,6 +159,13 @@ namespace MinecraftClient.Protocol
/// TRUE if item given successfully
bool SendCreativeInventoryAction(int slot, ItemType itemType, int count);
+ ///
+ /// Plays animation
+ ///
+ /// <0|1>
+ /// TRUE if item given successfully
+ bool SendAnimation(int animation);
+
///
/// Send a close window packet to the server
///