66using System . Threading ;
77using System . IO ;
88using System . Net ;
9+ using MinecraftClient . ChatBots ;
910using MinecraftClient . Protocol ;
1011using MinecraftClient . Proxy ;
1112using MinecraftClient . Protocol . Handlers . Forge ;
@@ -170,6 +171,7 @@ private void StartClient(string user, string uuid, string sessionID, string serv
170171 if ( Settings . AutoAttack_Enabled ) { BotLoad ( new ChatBots . AutoAttack ( ) ) ; }
171172 if ( Settings . AutoFishing_Enabled ) { BotLoad ( new ChatBots . AutoFishing ( ) ) ; }
172173 if ( Settings . AutoEat_Enabled ) { BotLoad ( new ChatBots . AutoEat ( Settings . AutoEat_hungerThreshold ) ) ; }
174+
173175 //Add your ChatBot here by uncommenting and adapting
174176 //BotLoad(new ChatBots.YourBot());
175177 }
@@ -324,6 +326,7 @@ private void TimeoutDetector()
324326 }
325327 while ( true ) ;
326328 }
329+
327330
328331 /// <summary>
329332 /// Perform an internal MCC command (not a server command, use SendText() instead for that!)
@@ -334,6 +337,7 @@ private void TimeoutDetector()
334337 /// <returns>TRUE if the command was indeed an internal MCC command</returns>
335338 public bool PerformInternalCommand ( string command , ref string response_msg , Dictionary < string , object > localVars = null )
336339 {
340+
337341 /* Load commands from the 'Commands' namespace */
338342
339343 if ( cmds . Count == 0 )
@@ -382,12 +386,28 @@ public bool PerformInternalCommand(string command, ref string response_msg, Dict
382386 else if ( cmds . ContainsKey ( command_name ) )
383387 {
384388 response_msg = cmds [ command_name ] . Run ( this , command , localVars ) ;
389+ foreach ( ChatBot bot in bots . ToArray ( ) )
390+ {
391+ try
392+ {
393+ bot . OnInternalCommand ( command_name , string . Join ( " " , Command . getArgs ( command ) ) , response_msg ) ;
394+ }
395+ catch ( Exception e )
396+ {
397+ if ( ! ( e is ThreadAbortException ) )
398+ {
399+ ConsoleIO . WriteLogLine ( "OnInternalCommand: Got error from " + bot . ToString ( ) + ": " + e . ToString ( ) ) ;
400+ }
401+ else throw ; //ThreadAbortException should not be caught
402+ }
403+ }
385404 }
386405 else
387406 {
388407 response_msg = "Unknown command '" + command_name + "'. Use '" + ( Settings . internalCmdChar == ' ' ? "" : "" + Settings . internalCmdChar ) + "help' for help." ;
389408 return false ;
390409 }
410+
391411 return true ;
392412 }
393413
@@ -1356,6 +1376,7 @@ public void OnEntityPosition(int EntityID, Double Dx, Double Dy, Double Dz,bool
13561376 }
13571377
13581378 }
1379+
13591380 /// <summary>
13601381 /// Called when an entity moved over 8 block.
13611382 /// </summary>
@@ -1469,6 +1490,14 @@ public void SetPlayerEntityID(int EntityID)
14691490 playerEntityID = EntityID ;
14701491 }
14711492
1493+ /// <summary>
1494+ /// Send the Entity Action packet with the Specified ID
1495+ /// </summary>
1496+ /// <returns>TRUE if the item was successfully used</returns>
1497+ public bool sendEntityAction ( EntityActionType entityAction )
1498+ {
1499+ return handler . SendEntityAction ( playerEntityID , ( int ) entityAction ) ;
1500+ }
14721501 /// <summary>
14731502 /// Use the item currently in the player's hand
14741503 /// </summary>
0 commit comments