diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs
index dd45f9b4..8c60ff44 100644
--- a/MinecraftClient/ChatBots/AutoAttack.cs
+++ b/MinecraftClient/ChatBots/AutoAttack.cs
@@ -22,8 +22,9 @@ namespace MinecraftClient.ChatBots
private float health = 100;
private bool singleMode = true;
private bool priorityDistance = true;
+ private InteractType interactMode;
- public AutoAttack(string mode, string priority, bool overrideAttackSpeed = false, double cooldownSeconds = 1)
+ public AutoAttack(string mode, string priority, bool overrideAttackSpeed = false, double cooldownSeconds = 1, InteractType interaction = InteractType.Attack)
{
if (mode == "single")
singleMode = true;
@@ -37,6 +38,8 @@ namespace MinecraftClient.ChatBots
priorityDistance = false;
else LogToConsoleTranslated("bot.autoAttack.priority", priority);
+ interactMode = interaction;
+
if (overrideAttackSpeed)
{
if (cooldownSeconds <= 0)
@@ -103,7 +106,7 @@ namespace MinecraftClient.ChatBots
// check entity distance and health again
if (shouldAttackEntity(entitiesToAttack[priorityEntity]))
{
- InteractEntity(priorityEntity, 1); // hit the entity!
+ InteractEntity(priorityEntity, interactMode); // hit the entity!
SendAnimation(Inventory.Hand.MainHand); // Arm animation
}
}
@@ -114,7 +117,7 @@ namespace MinecraftClient.ChatBots
// check that we are in range once again.
if (shouldAttackEntity(entity.Value))
{
- InteractEntity(entity.Key, 1); // hit the entity!
+ InteractEntity(entity.Key, interactMode); // hit the entity!
}
}
SendAnimation(Inventory.Hand.MainHand); // Arm animation
diff --git a/MinecraftClient/Commands/Entitycmd.cs b/MinecraftClient/Commands/Entitycmd.cs
index 222316c8..8aebdaf1 100644
--- a/MinecraftClient/Commands/Entitycmd.cs
+++ b/MinecraftClient/Commands/Entitycmd.cs
@@ -33,10 +33,10 @@ namespace MinecraftClient.Commands
switch (action)
{
case "attack":
- handler.InteractEntity(entityID, 1);
+ handler.InteractEntity(entityID, InteractType.Attack);
return Translations.Get("cmd.entityCmd.attacked");
case "use":
- handler.InteractEntity(entityID, 0);
+ handler.InteractEntity(entityID, InteractType.Interact);
return Translations.Get("cmd.entityCmd.used");
default:
Entity entity = handler.GetEntities()[entityID];
@@ -113,13 +113,13 @@ namespace MinecraftClient.Commands
: "list";
if (action == "attack")
{
- handler.InteractEntity(entity2.Key, 1);
+ handler.InteractEntity(entity2.Key, InteractType.Attack);
actionst = "cmd.entityCmd.attacked";
actioncount++;
}
else if (action == "use")
{
- handler.InteractEntity(entity2.Key, 0);
+ handler.InteractEntity(entity2.Key, InteractType.Interact);
actionst = "cmd.entityCmd.used";
actioncount++;
}
diff --git a/MinecraftClient/Mapping/InteractType.cs b/MinecraftClient/Mapping/InteractType.cs
new file mode 100644
index 00000000..02876e8f
--- /dev/null
+++ b/MinecraftClient/Mapping/InteractType.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MinecraftClient.Mapping
+{
+ public enum InteractType
+ {
+ Interact = 0,
+ Attack = 1,
+ InteractAt = 2,
+ }
+}
diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs
index 82276f25..5a9b66db 100644
--- a/MinecraftClient/McClient.cs
+++ b/MinecraftClient/McClient.cs
@@ -212,7 +212,7 @@ namespace MinecraftClient
if (Settings.ScriptScheduler_Enabled) { BotLoad(new ChatBots.ScriptScheduler(Settings.ExpandVars(Settings.ScriptScheduler_TasksFile))); }
if (Settings.RemoteCtrl_Enabled) { BotLoad(new ChatBots.RemoteControl()); }
if (Settings.AutoRespond_Enabled) { BotLoad(new ChatBots.AutoRespond(Settings.AutoRespond_Matches)); }
- if (Settings.AutoAttack_Enabled) { BotLoad(new ChatBots.AutoAttack(Settings.AutoAttack_Mode, Settings.AutoAttack_Priority, Settings.AutoAttack_OverrideAttackSpeed, Settings.AutoAttack_CooldownSeconds)); }
+ if (Settings.AutoAttack_Enabled) { BotLoad(new ChatBots.AutoAttack(Settings.AutoAttack_Mode, Settings.AutoAttack_Priority, Settings.AutoAttack_OverrideAttackSpeed, Settings.AutoAttack_CooldownSeconds, Settings.AutoAttack_Interaction)); }
if (Settings.AutoFishing_Enabled) { BotLoad(new ChatBots.AutoFishing()); }
if (Settings.AutoEat_Enabled) { BotLoad(new ChatBots.AutoEat(Settings.AutoEat_hungerThreshold)); }
if (Settings.Mailer_Enabled) { BotLoad(new ChatBots.Mailer()); }
@@ -1632,23 +1632,23 @@ namespace MinecraftClient
/// Interact with an entity
///
///
- /// 0: interact, 1: attack, 2: interact at
+ /// Type of interaction (interact, attack...)
/// Hand.MainHand or Hand.OffHand
/// TRUE if interaction succeeded
- public bool InteractEntity(int entityID, int type, Hand hand = Hand.MainHand)
+ public bool InteractEntity(int entityID, InteractType type, Hand hand = Hand.MainHand)
{
if (InvokeRequired)
return InvokeOnMainThread(() => InteractEntity(entityID, type, hand));
if (entities.ContainsKey(entityID))
{
- if (type == 0)
+ if (type == InteractType.Interact)
{
- return handler.SendInteractEntity(entityID, type, (int)hand);
+ return handler.SendInteractEntity(entityID, (int)type, (int)hand);
}
else
{
- return handler.SendInteractEntity(entityID, type);
+ return handler.SendInteractEntity(entityID, (int)type);
}
}
else return false;
diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj
index e7947ff9..4ea125d4 100644
--- a/MinecraftClient/MinecraftClient.csproj
+++ b/MinecraftClient/MinecraftClient.csproj
@@ -1,67 +1,67 @@
-
-
- net6.0
- Exe
- publish\
- false
- default
- enable
- true
- true
-
-
- false
-
-
- Resources\AppIcon.ico
-
-
- MinecraftClient.Program
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ net6.0
+ Exe
+ publish\
+ false
+ default
+ enable
+ true
+ true
+
+
+ false
+
+
+ Resources\AppIcon.ico
+
+
+ MinecraftClient.Program
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MinecraftClient/Resources/config/MinecraftClient.ini b/MinecraftClient/Resources/config/MinecraftClient.ini
index 5187d9b3..2b93abf6 100644
--- a/MinecraftClient/Resources/config/MinecraftClient.ini
+++ b/MinecraftClient/Resources/config/MinecraftClient.ini
@@ -196,6 +196,7 @@ enabled=false
mode=single # single or multi. single target one mob per attack. multi target all mobs in range per attack
priority=distance # health or distance. Only needed when using single mode
cooldownseconds=auto # How long to wait between each attack. Use auto to let MCC calculate it
+interaction=Attack # Possible values: Interact, Attack (default), InteractAt (Interact and Attack)
[AutoFishing]
# Automatically catch fish using a fishing rod
diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs
index 5b6471a9..ffda9560 100644
--- a/MinecraftClient/Scripting/ChatBot.cs
+++ b/MinecraftClient/Scripting/ChatBot.cs
@@ -1190,7 +1190,20 @@ namespace MinecraftClient
/// 0: interact, 1: attack, 2: interact at
/// Hand.MainHand or Hand.OffHand
/// TRUE in case of success
+ [Obsolete("Prefer using InteractType enum instead of int for interaction type")]
protected bool InteractEntity(int EntityID, int type, Hand hand = Hand.MainHand)
+ {
+ return Handler.InteractEntity(EntityID, (InteractType)type, hand);
+ }
+
+ ///
+ /// Interact with an entity
+ ///
+ ///
+ /// Interaction type (InteractType.Interact, Attack or AttackAt)
+ /// Hand.MainHand or Hand.OffHand
+ /// TRUE in case of success
+ protected bool InteractEntity(int EntityID, InteractType type, Hand hand = Hand.MainHand)
{
return Handler.InteractEntity(EntityID, type, hand);
}
diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs
index aa5cadfe..6f0f6654 100644
--- a/MinecraftClient/Settings.cs
+++ b/MinecraftClient/Settings.cs
@@ -6,6 +6,7 @@ using System.IO;
using System.Text.RegularExpressions;
using MinecraftClient.Protocol.Session;
using MinecraftClient.Protocol;
+using MinecraftClient.Mapping;
namespace MinecraftClient
{
@@ -192,6 +193,7 @@ namespace MinecraftClient
public static string AutoAttack_Priority = "distance";
public static bool AutoAttack_OverrideAttackSpeed = false;
public static double AutoAttack_CooldownSeconds = 1;
+ public static InteractType AutoAttack_Interaction = InteractType.Attack;
//Auto Fishing
public static bool AutoFishing_Enabled = false;
@@ -693,6 +695,8 @@ namespace MinecraftClient
AutoAttack_CooldownSeconds = str2float(argValue);
}
return true;
+ case "interaction":
+ return Enum.TryParse(argValue, true, out AutoAttack_Interaction);
}
break;